X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=mqtt-arp.c;h=de0fcccea27cce24f0f2b4ffb3aeb6fcda8cc2b0;hb=8742da72f15ac87fc3f61acaa1ad02e2964c1868;hp=19da3304117ace9589b3d17cf148cf89484aaaad;hpb=6121bfeaf48b68f62c814ca094f5ffb2d32b7dc2;p=mqtt-arp.git diff --git a/mqtt-arp.c b/mqtt-arp.c index 19da330..de0fccc 100644 --- a/mqtt-arp.c +++ b/mqtt-arp.c @@ -197,19 +197,20 @@ void main_loop(struct ma_config *config, struct mosquitto *mosq, int sock) nd->ndm_type); } attr = (struct nlattr *) (nd + 1); - while (attr->nla_len > 0) { - data = (((uint8_t *) attr) + 4); + while (((uint8_t *) attr - buf) < hdr->nlmsg_len) { + data = (((uint8_t *) attr) + NLA_HDRLEN); if (attr->nla_type == NDA_LLADDR && nd->ndm_state == NUD_REACHABLE) { mqtt_mac_presence(config, mosq, data, true); } - attr = (struct nlattr *) - (((uint8_t *) attr) + attr->nla_len); + attr = (struct nlattr *) (((uint8_t *) attr) + + NLA_ALIGN(attr->nla_len)); } break; case RTM_DELNEIGH: case RTM_GETNEIGH: + break; default: printf("Unknown message type: %d\n", hdr->nlmsg_type); } @@ -365,9 +366,9 @@ int main(int argc, char *argv[]) if (!config.mqtt_host) config.mqtt_host = MQTT_HOST; if (!config.mqtt_topic) - config.mqtt_host = MQTT_TOPIC; + config.mqtt_topic = MQTT_TOPIC; if (!config.location) - config.mqtt_host = LOCATION; + config.location = LOCATION; signal(SIGTERM, shutdown_request);