⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usrnetwork.c

📁 ixp2400 bsp for vxworks
💻 C
📖 第 1 页 / 共 5 页
字号:
        { "med", medattach, (char*)IO_ADRS_DBETH, INT_VEC_DBETH, INT_LVL_DBETH},#endif	/* INCLUDE_MED */#ifdef  INCLUDE_ELC	{ "elc", elcattach, (char*)IO_ADRS_ELC, INT_VEC_ELC, INT_LVL_ELC,	  MEM_ADRS_ELC, MEM_SIZE_ELC, CONFIG_ELC},#endif  /* INCLUDE_ELC */#ifdef  INCLUDE_ULTRA	{ "ultra", ultraattach, (char*)IO_ADRS_ULTRA, INT_VEC_ULTRA,	  INT_LVL_ULTRA, MEM_ADRS_ULTRA, MEM_SIZE_ULTRA, CONFIG_ULTRA},#endif  /* INCLUDE_ULTRA */#ifdef  INCLUDE_EEX	{ "eex", eexattach, (char*)IO_ADRS_EEX, INT_VEC_EEX, INT_LVL_EEX,	  NTFDS_EEX, CONFIG_EEX},#endif  /* INCLUDE_EEX */#ifdef  INCLUDE_ELT	{ "elt", eltattach, (char*)IO_ADRS_ELT, INT_VEC_ELT, INT_LVL_ELT,	  NRF_ELT, CONFIG_ELT},#endif  /* INCLUDE_ELT */#ifdef  INCLUDE_QU	{ "qu", quattach, (char*)IO_ADRS_QU_EN, INT_VEC_QU_EN, QU_EN_SCC,	  QU_EN_TX_BD, QU_EN_RX_BD, QU_EN_TX_OFF, QU_EN_RX_OFF, QU_EN_MEM},#endif  /* INCLUDE_QU */#ifdef  INCLUDE_ENE	{ "ene", eneattach, (char*)IO_ADRS_ENE, INT_VEC_ENE, INT_LVL_ENE},#endif  /* INCLUDE_ENE */#ifdef  INCLUDE_ESMC	{ "esmc", esmcattach, (char*)IO_ADRS_ESMC, INT_VEC_ESMC, INT_LVL_ESMC,	  CONFIG_ESMC, RX_MODE_ESMC},#endif  /* INCLUDE_ESMC */#ifdef  INCLUDE_SN        { "sn", snattach, (char*)IO_ADRS_SN, INT_VEC_SN },#endif	/* INCLUDE_SN */#ifdef  INCLUDE_FN        { "fn", fnattach },#endif	/* INCLUDE_FN */#ifdef  INCLUDE_SM_NET        { "sm", smNetAttach2, 0, 0, 0, 0, 0, 0, 0, 0 },#endif  /* INCLUDE_SM_NET */#ifdef	INCLUDE_PCMCIA	{ "pcmcia", pcmciaattach, 0, 0, 0, 0, 0, 0 },#endif	/* INCLUDE_PCMCIA */#ifdef	INCLUDE_PPP	{"ppp", 0, 0, 0, 0, 0},#endif	/* INCLUDE_PPP */#ifdef	INCLUDE_SLIP	{"sl", 0, 0, 0, 0, 0},#endif	/* INCLUDE_SLIP */	{ "lo", loattach  },	{ 0, 0, 0, 0, 0, 0 },    };/* forward declarations */STATUS usrNetProtoInit (void);#ifdef INCLUDE_DNS_RESOLVERLOCAL STATUS usrResolvInit (void);#endif /* INCLUDE_DNS_RESOLVER */#ifdef INCLUDE_NET_SHOWconst UINT rtMem = RT_DISPLAY_MEMORY;const BOOL bufferedRtShow = RT_BUFFERED_DISPLAY;#endif#if defined (INCLUDE_DHCPS) || defined (INCLUDE_DHCPR)/* * The following table lists the IP addresses which will receive DHCP * messages forwarded across network boundaries by a DHCP server or * relay agent. */DHCP_TARGET_DESC dhcpTargetTbl [] =    {    /*     IP address of DHCP target servers     ---------------------------------     */     /* {"90.11.42.2"}, */     { NULL } /* List terminator, must be last */     };struct ifnet *devlist[1];int dhcpMaxHops = DHCP_MAX_HOPS;int dhcpSPort = DHCPS_SPORT;int dhcpCPort = DHCPS_CPORT;#endif	/* INCLUDE_DHCPS || INCLUDE_DHCPR */#ifdef INCLUDE_DHCPRLOCAL int dhcpTargetTblSize = (NELEMENTS(dhcpTargetTbl));#endif	/* INCLUDE_DHCPR *//* * Example cache routine - should store records of active leases *                         across reboots. *//*#ifdef INCLUDE_DHCPSSTATUS dhcpsDummyCache (int, char *, int);STATUS dhcpsDummyCache (int op, char *name, int length)    {    printf("Cache called with op %d on %d bytes.\n", op, length);    if (op == DHCPS_STORAGE_READ)        return (ERROR);          /@ Simulated end-of-file. @/    return (OK);    }#endif	/@ INCLUDE_DHCPS @/*/#ifdef INCLUDE_DHCPS/*  * This table contains a list of interfaces that the server * will listen to. The boot device is used when the table's      * first entry is the null string. */DHCPS_IF_DESC dhcpsIfTbl [] =    {    {""}                             /* Use primary interface */    /* Sample interface entries. */    /*  {"fei1"}, */    /*  {"ln0"} */    };DHCPS_LEASE_DESC dhcpsLeaseTbl [] =    {    /*    Name        Start IP      End IP          Parameters    ----        ----------    ------          -----------		                     see man pages		                (timers, bootfile, etc.)    */    /*     * Host requirements defaults needed for RFC compliance - DO NOT REMOVE!!     */   {"dflt",    NULL, NULL, DHCPS_DEFAULT_ENTRY},    /* Sample database entries. *//* {"ent1", "90.11.42.24", "90.11.42.24", "clid=\"1:0x08003D21FE90\":maxl=90:dfll=60"},   *//* {"ent2", "90.11.42.25", "90.11.42.26", "snmk=255.255.255.0:maxl=90:dfll=70:file=/vxWorks"}, *//* {"ent3", "90.11.42.27", "90.11.42.27", "maxl=0xffffffff:file=/vxWorks"}, *//* {"entry4", "90.11.42.28", "90.11.42.29", "albp=true:file=/vxWorks"}      */    };/* * If the DHCP server will receive messages from relay agents, * the following table must be filled in by the user. */DHCPS_RELAY_DESC dhcpsRelayTbl [] =    {    /*     IP address of agent              Subnet Number     --------------------             -------------     */    /* {"90.11.42.254",               "90.11.42.0"}, */    { NULL,                           NULL } /* List terminator, must be last */    };LOCAL int dhcpsTaskPriority  = 56;      /* Priority level of DHCP server */LOCAL int dhcpsTaskOptions   = 0;       /* Option settings for DHCP server */LOCAL int dhcpsTaskStackSize = 5000;    /* Stack size for DHCP server task */#ifndef INCLUDE_VIRTUAL_STACKIMPORT void dhcpsStart (void);#else IMPORT void dhcpsStart (int);IMPORT int myStackNum;#endif /* INCLUDE_VIRTUAL_STACK *//* * Default configurations parameters for dhcps, definitions are in h/dhcpsLib.h */DHCPS_CFG_PARAMS dhcpsDfltCfgParams =    {    DHCP_MAX_HOPS,    DHCPS_SPORT,    DHCPS_CPORT,    DHCPS_MAX_MSGSIZE,    DHCPS_DEFAULT_LEASE,    DHCPS_MAX_LEASE,    DHCPS_LEASE_HOOK,    DHCPS_ADDRESS_HOOK,    dhcpsIfTbl,    NELEMENTS(dhcpsIfTbl),    dhcpsLeaseTbl,    NELEMENTS(dhcpsLeaseTbl),    dhcpTargetTbl,    NELEMENTS(dhcpTargetTbl),    dhcpsRelayTbl,    NELEMENTS(dhcpsRelayTbl),    };#endif	/* INCLUDE_DHCPS */#ifdef INCLUDE_DHCPR                   /* Relay agent settings. */#ifndef INCLUDE_DHCPS                  /* Server is superset of relay agent. */LOCAL int dhcprTaskPriority  = 56;    /* Priority level of DHCP relay agent */LOCAL int dhcprTaskOptions   = 0;     /* Option settings for DHCP relay agent */LOCAL int dhcprTaskStackSize = 2500;  /* Stack size for DHCP relay agent */IMPORT STATUS dhcprLibInit (int);IMPORT STATUS dhcprInit (struct ifnet **, int, DHCP_TARGET_DESC *, int);IMPORT void dhcprStart (void);#endif	/* INCLUDE_DHCPS */#endif	/* INCLUDE_DHCPR */#ifdef INCLUDE_VIRTUAL_STACK#include "netinet/vsLib.h"              /* VSID definition             */VSID mgmtStackId;		/* Management stack identifier */STATUS usrVirtualStackInit ()    {    if (virtualStackLibInit () == ERROR)        {        logMsg ("usrVirtualStackInit: unable to initialize virtual stack support.\n",	 0, 0, 0, 0, 0, 0);        return (ERROR);        }    if (virtualStackCreate ("stack0", &mgmtStackId) == ERROR)       {       logMsg ("usrVirtualStackInit: Unable to setup management stack.\n", 	0, 0, 0, 0, 0, 0);       return (ERROR);       }         return (OK);    }#endif /* INCLUDE_VIRTUAL_STACK *//********************************************************************************* usrNetInit - system-dependent network initialization** This routine initializes the network.  The ethernet and backplane drivers* and the TCP/IP software are configured.  It also adds hosts (analogous to* the /etc/hosts file in UNIX), gateways (analogous to /etc/gateways), sets* up our access rights on the host system (with iam()), optionally* initializes telnet, rlogin, RPC, and NFS support.** The boot string parameter is normally left behind by the boot ROMs,* at address BOOT_LINE_ADRS.** Unless the STANDALONE option is selected in usrConfig.c, this routine* will automatically be called by the root task usrRoot().** RETURNS:* OK, or* ERROR if there is a problem in the boot string, or initializing network.** SEE ALSO:  "Network" chapter of the VxWorks Programmer's Guide** NOMANUAL*/STATUS usrNetInit    (    char *bootString		/* boot parameter string */    )    {    BOOT_PARAMS	params;    char	numString [30]; 	/* buffer for numeric strings */    char * 	pNetDev = NULL; 	/* Name of network device to setup */    char *	pBootString;       /* IP address settings from boot string */    int		netmask;#if  defined (INCLUDE_SM_NET) || defined (INCLUDE_PROXY_SERVER)    int 	proxymask; 	/* mask for backplane and/or proxy net */#endif    char	devName [MAX_FILENAME_LENGTH];	/* device name */#ifdef INCLUDE_NET_REM_IO    int		protocol;#endif /* INCLUDE_NET_REM_IO */#ifdef INCLUDE_DHCPC    BOOL 	dhcpBoot = FALSE;       /* Lease obtained during startup? */#endif  /* INCLUDE_DHCPC */#ifdef INCLUDE_DHCPS    STATUS dhcpsResult;#endif	/* INCLUDE_DHCPS */#ifdef INCLUDE_DHCPR#ifndef INCLUDE_DHCPS              /* Server is superset of relay agent. */    STATUS dhcprResult;#endif	/* INCLUDE_DHCPS */#endif	/* INCLUDE_DHCPR */#ifdef INCLUDE_END    int         count;    END_TBL_ENTRY* pDevTbl;    END_OBJ*      pCookie = NULL;    END_OBJ*   pEnd;#endif /* INCLUDE_END */    BOOL	backplaneBoot = FALSE;    BOOL 	attachFlag = FALSE;   /* Device configuration required? */    /* interpret boot command */    if (bootString == NULL)	bootString = BOOT_LINE_ADRS;    if (usrBootLineCrack (bootString, &params) != OK)	{	NET_DIAG(("usrBootLineCrack() returned errno = 0x%x\n", errno));	return (ERROR);	}    /* fill in any default values specified in configAll */    if ((params.hostName [0] == EOS) &&			/* host name */        (strcmp (HOST_NAME_DEFAULT, "") != 0))	{	strncpy (params.hostName, HOST_NAME_DEFAULT, BOOT_HOST_LEN);	printf ("Host Name: %s \n", params.hostName);	}    if ((params.targetName [0] == EOS) &&		/* targetname */        (strcmp (TARGET_NAME_DEFAULT, "") != 0))	{	strncpy (params.targetName, TARGET_NAME_DEFAULT, BOOT_HOST_LEN);	printf ("Target Name: %s \n", params.targetName);	}    if ((params.usr [0] == EOS) &&			/* user name (u) */        (strcmp (HOST_USER_DEFAULT, "") != 0))	{	strncpy (params.usr, HOST_USER_DEFAULT, BOOT_USR_LEN);	printf ("User: %s \n", params.usr);	}    if ((params.startupScript [0] == EOS) &&		/* startup script (s) */        (strcmp (SCRIPT_DEFAULT, "") != 0))	{	strncpy (params.startupScript, SCRIPT_DEFAULT, BOOT_FILE_LEN);	printf ("StartUp Script: %s \n", params.startupScript);	}    if ((params.other [0] == EOS) &&			/* other (o) */        (strcmp (OTHER_DEFAULT, "") != 0))	{	strncpy (params.other, OTHER_DEFAULT, BOOT_OTHER_LEN);	printf ("Other: %s \n", params.other);	}    if (params.passwd [0] == EOS)			/* password */	strncpy (params.passwd, HOST_PASSWORD_DEFAULT, BOOT_PASSWORD_LEN);    /* fill in system-wide variables */    bcopy ((char *) &params, (char *) &sysBootParams, sizeof (sysBootParams));    sysFlags = params.flags;    strcpy (sysBootHost, params.hostName);	/* backwards compatibility */    strcpy (sysBootFile, params.bootFile);	/* backwards compatibility */    /* set processor number: may establish vme bus access, etc. */    if (_procNumWasSet != TRUE)	{    	sysProcNumSet (params.procNum);	_procNumWasSet = TRUE;	}    /* start the network */    /* initialize the generic socket library */    if (sockLibInit (NUM_FILES) == ERROR)	{	NET_DIAG(("sockLibInit(%d) returned errno = 0x%x\n", NUM_FILES, errno));	return (ERROR);	}#ifdef INCLUDE_VIRTUAL_STACK    if (usrVirtualStackInit () == ERROR)        {	logMsg("usrVirtualStackInit() returned error\n", 0, 0, 0, 0, 0, 0);	return (ERROR);	}#endif /* INCLUDE_VIRTUAL_STACK */    ifIndexLibInit ();    arpMaxEntries = ARP_MAX_ENTRIES;#ifdef INCLUDE_BSD_SOCKET#ifdef BSD43_COMPATIBLE    bsdSock43ApiFlag = TRUE;#endif  /* BSD43_COMPATIBLE */    somaxconn = SOMAXCONN_CFG;    /* add the BSD socket library interface */    if (sockLibAdd ((FUNCPTR) bsdSockLibInit, AF_INET_BSD, AF_INET) == ERROR)	{	NET_DIAG(("sockLibAdd(..., AF_INET_BSD, AF_INET) returned errno = 0x%x\n",		errno));        return (ERROR);	}#if defined (INCLUDE_ROUTE_SOCK)    if (sockLibAdd ((FUNCPTR) bsdSockLibInit, AF_ROUTE, AF_ROUTE) == ERROR)	{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -