]> git.feebdaed.xyz Git - linuxyz.git/commitdiff
neigh lladdr
authorseantywork <seantywork@gmail.com>
Fri, 25 Jul 2025 04:16:44 +0000 (13:16 +0900)
committerseantywork <seantywork@gmail.com>
Fri, 25 Jul 2025 04:16:44 +0000 (13:16 +0900)
sock-netlink/arp.c

index f9f435e74f3457b438d083ecbb356b223fb33584..b5b9fe9e99fc4fa6feb8bd5680cf2653ce2a40cb 100644 (file)
@@ -54,16 +54,28 @@ void process_message(char *buf ,int raw_msg_len){
         }
 
         rtmp = (struct ndmsg *)NLMSG_DATA(nlmp);
-        rtatp = (struct rtattr *)IFA_RTA(rtmp);
+        //rtatp = (struct rtattr *)IFA_RTA(rtmp);
+        rtatp = (struct rtattr *)RTM_RTA(rtmp);
 
-        rtattrlen = IFA_PAYLOAD(nlmp) ;
+        //rtattrlen = IFA_PAYLOAD(nlmp) ;
+        rtattrlen = RTM_PAYLOAD(nlmp) ;
 
         for (;RTA_OK(rtatp, rtattrlen); rtatp = RTA_NEXT(rtatp, rtattrlen)){
             if(rtatp->rta_type == NDA_DST){
                 inp = (struct in_addr *) RTA_DATA(rtatp);
                 inet_ntop(AF_INET, inp, ipv4string, INET_ADDRSTRLEN);
                 printf("addr: %s\n", ipv4string);
+                continue;
             }
+            if(rtatp->rta_type == NDA_LLADDR){
+                printf("lladdr: ");
+                for(int i=0;i<RTA_PAYLOAD(rtatp);i++){
+                    printf("%02x ", ((unsigned char*)RTA_DATA(rtatp))[i]);
+                }
+                printf("\n");
+                continue;
+            }
+            printf("neigh nda: %d\n", rtatp->rta_type);
         }
 
         raw_msg_len -= NLMSG_ALIGN(len);