C.7. Sending the VRRP Advertisement

 /********************************************************* NAME : vrrp_send_pkt *********************************************************/ static int vrrp_send_pkt( vrrp_rt *vsrv, char *buffer, int buflen ) { struct sockaddr from; int len; int fd = socket(PF_PACKET, SOCK_PACKET, 0x300); /* 0x300 is magic */ if( fd < 0 ){ perror( "socket" ); return -1; } /* build the address */ memset( &from, 0 , sizeof(from)); strcpy( from.sa_data, vsrv->vif.ifname ); /* send the data */ len = sendto( fd, buffer, buflen, 0, &from, sizeof(from) ); close( fd ); return len; } /********************************************************* NAME : vrrp_send_adv *********************************************************/ static int vrrp_send_adv( ...

Get VRRP: Increasing Reliability and Failover with the Virtual Router Redundance Protocol now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.