#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <signal.h>
#include <stdlib.h>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <linux/if.h>
#include <linux/if_packet.h>
#include <sys/errno.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
void syncdbBfdMonitorClientRegister(void)
{
int rc;
{
exit (1);
}
{
exit (1);
}
}
{
uint32_t ip4_addr;
uint8_t addr8[16];
int af;
{
af = AF_INET;
ip4_addr = htonl(addr->
addr.
ipv4);
memcpy(addr8, &ip4_addr, sizeof(ip4_addr));
break;
af = AF_INET6;
memcpy(addr8, addr->addr.
ipv6.
u.
addr8,
sizeof(addr8));
break;
default:
return(NULL);
}
return(inet_ntop(af, addr8, buffer, INET6_ADDRSTRLEN));
}
{
char src_ip[256];
char dst_ip[256];
char next_hop[256];
const char *rc1, *rc2, *rc3;
if (delete_pending == 0)
{
printf("Event Type: Add/Change\n");
} else
{
printf("Event Type: Delete\n");
}
rc1 = ipAddressFormat (&bfd_info->
key.
srcIpAddr, src_ip);
if (rc1 == 0)
{
sprintf (src_ip, "None");
}
rc2 = ipAddressFormat (&bfd_info->
key.
dstIpAddr, dst_ip);
if (rc2 == 0)
{
sprintf (dst_ip, "None");
}
if (rc3 == 0)
{
sprintf (next_hop, "None");
}
printf (
"Session State:%d\n", bfd_info->
state);
printf (
"Diag Code:%d\n", bfd_info->
diag);
printf (
"SA Family:%d\n", bfd_info->
key.srcIpAddr.family);
printf ("Source IP Address:%s\n", src_ip);
printf ("Destination IP Address:%s\n", dst_ip);
printf ("Next Hop IP Address:%s\n", next_hop);
printf ("MPLS Label Stack:%d %d %d\n",
bfd_info->
key.
mpls_label.
label[0],
bfd_info->
key.mpls_label.label[1],
bfd_info->
key.mpls_label.label[2]);
printf ("\n");
}
void bfdEventHandle (void)
{
int rc;
int delete_pending;
do
{
&bfd_info, sizeof (bfd_info),
&delete_pending);
{
exit (1);
}
{
routerBfdEventLog(&bfd_info, delete_pending);
}
do
{
memset (&bfd_info, 0, sizeof (bfd_info));
do
{
&bfd_info, sizeof (bfd_info),
&delete_pending);
{
exit (1);
}
{
routerBfdEventLog(&bfd_info, delete_pending);
}
} while (1);
}
int main(int argc, char **argv)
{
int pid, status;
do
{
pid = fork ();
if (pid == 0)
{
syncdbBfdMonitorClientRegister ();
bfdEventHandle ();
} else
{
do
{
pid = waitpid (pid, &status, 0);
} while ((-1 == pid) && (EINTR == errno));
}
printf ("The NOS is not running. Retry in 1 second...\n");
sleep (1);
} while (1);
return 0;
}