#include <stdlib.h>
#include <unistd.h>
#include "rpcclt_openapi.h"
#include "proc_util.h"
#define PKT_LEN (128)
int
main (int argc, char **argv)
{
uint32_t ifNum, maxIfNum;
char switch_os_revision_string[100];
char destMac[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5};
char srcMac[] = {0x6, 0x7, 0x8, 0x9, 0xa, 0xb};
char *data, *pkt;
if (argc != 2)
{
printf("Usage: %s <ifnum> \n", argv[0]);
exit (1);
}
ifNum = atoi(argv[1]);
l7proc_crashlog_register ();
{
printf ("\nFailed to initialize RPC to OpEN. Exiting (result = %d)\n", result);
exit (2);
}
{
sleep (1);
}
L7PROC_LOGF (L7PROC_LOG_SEVERITY_INFO, 0,
"Starting packet transmit API example application");
{
printf ("Can't get Interface Count.\n");
exit (2);
}
else if (ifNum > maxIfNum)
{
printf ("Invalid interface. Interface can not exceed %d.\n", maxIfNum);
exit (2);
}
printf ("\n");
switch_os_revision.
pstart = switch_os_revision_string;
switch_os_revision.
size =
sizeof (switch_os_revision_string);
{
printf ("Network OS version = %s\n", switch_os_revision_string);
}
else
{
printf ("Network OS version retrieve error\n");
}
printf ("\n");
data = (char *) malloc(PKT_LEN);
if (data == ((void *)0))
{
printf("Failed to allocate memory\n");
return 1;
}
memset(data, 0, PKT_LEN);
pkt = data;
memcpy (pkt, destMac, sizeof(destMac));
pkt += sizeof(destMac);
memcpy(pkt, srcMac, sizeof(srcMac));
pkt += sizeof(srcMac);
memset(pkt, 0xcc, PKT_LEN - 12);
buffDesc.size = PKT_LEN;
buffDesc.pstart = (char *) data;
{
printf(" Bad return code trying transmit the packet on interface %d. (result = %d)\n",ifNum,result);
return 1;
}
else
{
printf("packet transmitted on interface : %d\n",ifNum);
}
L7PROC_LOGF (L7PROC_LOG_SEVERITY_INFO, 0,
"Stopping transmit packet API example application");
return 0;
}