Re: Registering a socket for neighbour updates callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bharati Bhole wrote:
Could anyone please tell me, how to register a socket to get neighbour
table update call back.

For example, one can get route table update, by creating a netlink
socket and registering it in "nl_groups" and then setting function
pointer "sk_data_ready" from sk.
This invoks the function pointer by "sk_data_ready" whenever route
table is modified.

Could somebody please tell the procedure to get the neighbour table callbacks .

You mean neighbour discovery table? (radvd)?
Iam not sure if this is what ur looking for, but you can do something like

   int fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);


   memset(&localaddrinfo, 0, sizeof(struct sockaddr_nl));
   memset(&in6pAddr, '\0', sizeof(in6pAddr));

   groups |= RTMGRP_IPV6_IFADDR;
   groups |= RTMGRP_IPV6_PREFIX;
   localaddrinfo.nl_family = AF_NETLINK;
   localaddrinfo.nl_groups = groups;

if (bind(fd, (struct sockaddr*)&localaddrinfo, sizeof(localaddrinfo)) < 0) {
       snmp_log(LOG_ERR,"Bind failed. Exiting thread\n");
       exit(0);
   }

   memset(&req, 0, sizeof(req));
   req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
   req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT;
   req.n.nlmsg_type = RTM_GETLINK;
   req.r.ifi_family = AF_INET6;
   rta = (struct rtattr *)(((char *)&req) + NLMSG_ALIGN(req.n.nlmsg_len));
   rta->rta_len = RTA_LENGTH(16);

   status = send(fd, &req, req.n.nlmsg_len, 0);
   if (status < 0) {
       snmp_log(LOG_ERR,"Send failed. Exiting thread\n");
       exit(0);
   }

Regards,
Varun
Regards,
Bharati.
--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux