📄 usbnc1080test.c
字号:
/* usbNC1080Test.c - Test routines for the USB NetChip Ethernet Driver *//* Copyright 1999-2001 Wind River Systems, Inc. *//*Modification history--------------------01a,01may01,wef Created*//*DESCRIPTION This file contains test routines for use in testing the NetChip USB Ethernetdriver. This code allows a NetChip USB Network adapter to be used in a vxWorkssystem. For more information refer to the.I "vxWorks Network Programmer's Guide",.I "Writing and Enhanced Network Driver" and.I "USB Developer's Kit User's Guide"*//* includes */#undef ETHER_MAP_IP_MULTICAST#include "etherMultiLib.h" /* multicast stuff. */#include "drv/usb/usbNC1080End.h"/* defines */#define ADDR_STRING_NETCHIP "10.0.0.2"#define ADDR_STRING_NETCHIP2 "10.0.0.3" /* externals */extern int ipAttach ();/* locals */LOCAL END_OBJ* pEnd;/******************************************************************************** sysUsbNc1080EndLoad - load (create) USB NetChip 1080 device** This routine loads the usb end device with initial parameters specified by* values given in the BSP configuration files (config.h).** RETURNS: pointer to END object or ERROR.** SEE ALSO: usbNC1080Load ()*/END_OBJ * sysUsbNc1080EndLoad ( char * pParamStr, /* ptr to initialization parameter string */ void * unused /* unused optional argument */ ) { /* * The usbEnd driver END_LOAD_STRING should be: * "<vendorId>:<productId>:<macadrs>" * Note that unit string is prepended by the mux, so we * don't put it here. * <noofRxbuffers> are the no of input buffers should get allocated * <noofIRPs> are the no of IRP s should be created */ char paramStr [END_INIT_STR_MAX]; /* from end.h */ static char usbEndParam[] = "%d:%d:%d:%d:%d:%d:%d:%d"; END_OBJ * pEnd; if (strlen (pParamStr) == 0) { /* * muxDevLoad() calls us twice. If the string is * zero length, then this is the first time through * this routine, so we just return the device name. */ logMsg (" usbNC1080Load got called for First time\n", 0, 0, 0, 0, 0, 0); pEnd = usbNC1080Load ((char *) pParamStr); } else { /* * On the second pass though here, we actually create * the initialization parameter string on the fly. * Note that we will be handed our unit number on the * second pass through and we need to preserve that information. * So we use the unit number handed from the input string. */ sprintf(paramStr,"%c:", * pParamStr); /*sabbana*/ sprintf(usbEndParam,"%d:%d:%d:%d:%d:%d:%d:%d", NETCHIP_VENDOR_ID, NETCHIP_PRODUCT_ID, 0x0, 0x03, 0x98, 0x8e, 0xe0, 0xcb); strcat(paramStr,usbEndParam); if ((pEnd = usbNC1080Load ((char *) paramStr )) == (END_OBJ *)NULL) { logMsg("Error: usbNC1080Load failed :-( .\n", 0, 0, 0, 0, 0, 0); } } return (pEnd); }void test ( int unitNum, /* unit number */ char * pAddrString, /* enet address */ int netmask /* netmask */ ) { char * pDevName ="netChip"; /* Device name */ char * pTgtName= "sabbana"; /* Host Name */ char * pIpAddress = "172.16.12.222"; /* ping address*/ char * pNetRoute = "10.0.0.0"; /* netroute */ M2_INTERFACETBL endM2Tbl; pEnd = endFindByName (pDevName, unitNum); if (pEnd == NULL) { logMsg ("SD..Could not find %s%d\n", pDevName, unitNum, 0, 0, 0, 0); return; } if (muxIoctl(pEnd, EIOCGMIB2, (caddr_t) &endM2Tbl) == ERROR) { logMsg ("SD..Cannot perform EIOCMIB2 ioctl.\n", 0, 0, 0, 0, 0, 0); return; } if (ipAttach(unitNum, pDevName) != OK) { logMsg ("SD..Failed to attach to device %s", pDevName, 0, 0, 0, 0, 0); return; } if (usrNetIfConfig (pDevName, unitNum, pAddrString, pTgtName, netmask) != OK) { logMsg ("SD..Failed to configure %s%d for IP.\n", pDevName, unitNum, 0, 0, 0, 0); return; } logMsg ("Attached TCP/IP interface to %s unit %d\n", pDevName, unitNum, 0, 0, 0, 0);}/* * This function is taken from usrEndLibInit() and modified suitably to load * the end driver when USB Ethernet device is dynamically attached or detached. * Its basically a sample fuction in the way which user should follow the to * load Netchip device dynamically. * */STATUS loadNetChip(int unitNum, USB_NC1080_DEV * pDev) { END_OBJ* pCookie = NULL; /* Add our default address resolution functions. */#ifdef INCLUDE_NT_ULIP muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, ntResolv);#else muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, arpresolve);#endifif (pDev->productId == NETCHIP_PRODUCT_ID && pDev->vendorId == NETCHIP_VENDOR_ID) pCookie = (END_OBJ *) muxDevLoad(unitNum, sysUsbNc1080EndLoad, NULL, 1, NULL); if (pCookie == NULL) { logMsg ("muxDevLoad failed for NETCHIP device \n", 0, 0, 0, 0, 0, 0); return(ERROR); } else { if (muxDevStart(pCookie) == ERROR) { logMsg ("muxDevStart failed for NETCHIP device \n", 0, 0, 0, 0, 0, 0); return(ERROR); } } return (OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -