#include "vxWorks.h" #include "ioLib.h" #include "logLib.h" #include "memLib.h" #include "socket.h" #include "sockLib.h" #include "stdio.h" #include "stdlib.h" #include "string.h" #include "ifLib.h" void ifLib_test(char *deviceName, char *ppp) { char addr[16],dstaddr[16],brdaddr[16]; int netmask,flags,metric, failed_count=0,test_count=0;; if(deviceName == NULL || ppp == NULL) return; ifconfig(deviceName); printf("Beginning ifLib tests..\n"); test_count++; if(ifAddrGet(deviceName,addr)!= OK) { failed_count++; printf("ifAddrGet failed for device %s \n",deviceName); } else { printf("ifAddrGet:%s \n",addr); } test_count++; if(ifBroadcastGet(deviceName,brdaddr)!=OK) { failed_count++; printf("ifBrdAddrGet failed for device %s \n",deviceName); } else { printf("ifBroadcastGet:%s \n",brdaddr); } test_count++; if(ifMaskGet(deviceName,&netmask)!= OK) { failed_count++; printf("ifMaskget failed for device %s \n",deviceName); } else { printf("ifMaskGet:%x \n",netmask); } test_count++; if(ifAddrDelete(deviceName,addr)!=OK) { failed_count++; printf("ifAddrDelete failed for device %s address %s \n",deviceName,addr); } else { printf("ifAddrDelete:OK. \n"); } ifconfig(deviceName); test_count++; if(ifAddrAdd(deviceName,addr,brdaddr,netmask) != OK) { failed_count++; printf("ifAddrAdd failed for device %s address %s broadcastaddr %s netmask %x \n",deviceName,addr,brdaddr,netmask); } else printf("ifAddrAdd:OK. \n"); ifconfig(deviceName); test_count++; if(ifAddrSet(deviceName,"192.168.1.3") != OK) { failed_count++; printf("ifAddrSet failed for device %s address %s \n",deviceName,"192.168.1.3"); } else printf("ifAddrSet:%s \n","192.168.1.3"); ifconfig(deviceName); test_count++; if(ifDstAddrSet(ppp,"192.168.2.3") != OK) { failed_count++; printf("ifDstAddrSet failed for device %s address %s \n ",deviceName,"192.168.2.3"); } else printf("ifDstAddrSet:%s \n","192.168.2.3"); ifconfig(deviceName); test_count++; if(ifDstAddrGet(ppp,dstaddr)!= OK) { failed_count++; printf("ifDstAddrGet failed for device %s \n",deviceName); } else printf("ifDstAddrGet:%s \n",dstaddr); test_count++; if(ifBroadcastSet(deviceName,"192.168.1.0") != OK) { failed_count++; printf("ifBroadcastSet failed for device %s address %s \n",deviceName,"192.168.1.0"); } else printf("ifBroadcastSet:%s \n","192.168.1.0"); ifconfig(deviceName); test_count++; netmask = 0xffff0000; if(ifMaskSet(deviceName,netmask)!= OK) { failed_count++; printf("ifMaskset failed for device %s mask %x \n",deviceName,netmask); } else printf("ifMaskSet:%x \n",netmask); ifconfig(deviceName); test_count++; if(ifFlagGet(deviceName,&flags)!=OK) { failed_count++; printf("ifFlagGet failed for device %s \n",deviceName); } else printf("ifFlagGet:%x \n",flags); test_count++; flags = 0x01; if(ifFlagSet(deviceName,flags)!=OK) { failed_count++; printf("ifFlagSet failed for device %s %x \n",deviceName,flags); } else printf("ifFlagSet:%x \n",flags); ifconfig(deviceName); test_count++; if(ifFlagChange(deviceName,flags,TRUE)!=OK) { failed_count++; printf("ifFlagChange failed for device %s flag:%x status:%s \n",deviceName,flags,"ON"); } else printf("ifFlagChange:OK. \n"); ifconfig(deviceName); test_count++; if(ifMetricGet(deviceName,&metric)!=OK) { failed_count++; printf("ifMetricGet failed for device %s \n",deviceName); } else printf("ifMetricGet:%d \n",metric); metric=20; test_count++; if(ifMetricSet(deviceName,metric)!=OK) { failed_count++; printf("ifMetricSet failed for device %s %d \n",deviceName,metric); } else printf("ifMetricSet:%d \n",metric); ifconfig(deviceName); printf(" Total tests: %d \n",test_count); printf(" Failed tests: %d \n",failed_count); printf(" Passed tests: %d \n",test_count - failed_count); }