O'Reilly logo

VRRP: Increasing Reliability and Failover with the Virtual Router Redundance Protocol by Adnan Adam Onart, Ayikudy Srikanth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C.17. Other Helper Routines

These are implementation-specific, device-specific and Socket I/O routines that are provided here for completeness and full readability of code. No explanations are provided for these.

 /********************************************************* NAME : get_dev_from_ip *********************************************************/ static uint32_t ifname_to_ip( char *ifname ) { struct ifreq ifr; int fd = socket(AF_INET, SOCK_DGRAM, 0); uint32_t addr = 0; if (fd < 0) return (-1); strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) == 0) { struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr; addr = ntohl(sin->sin_addr.s_addr); } close(fd); return addr; } /********************************************************* ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required