📄 usrnetwork.c
字号:
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 */IMPORT void dhcpsStart (void);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 */#include "bootpGet.c"/********************************************************************************* 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, ¶ms) != 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 *) ¶ms, (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); } ifIndexLibInit (); arpMaxEntries = ARP_MAX_ENTRIES;#ifdef INCLUDE_BSD_SOCKET#ifdef BSD43_COMPATIBLE bsdSock43ApiFlag = TRUE;#endif /* BSD43_COMPATIBLE */ /* 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) { NET_DIAG(("sockLibAdd(..., AF_ROUTE, AF_ROUTE) returned errno = 0x%x\n", errno)); return (ERROR); } routeSockLibInit () ;#endif /* INCLUDE_ROUTE_SOCK */#endif /* INCLUDE_BSD_SOCKET */ /* install default socket library interface */#ifndef DEFAULT_STREAMS_SOCKET if (sockLibAdd ((FUNCPTR) bsdSockLibInit, AF_INET, AF_INET) == ERROR) { NET_DIAG(("sockLibAdd(..., AF_INET, AF_INET) returned errno = 0x%x\n", errno)); return (ERROR); }#endif /* DEFAULT_STREAMS_SOCKET *//* set max link header reserved by BSD socket layer */ max_linkhdr = USR_MAX_LINK_HDR; hostTblInit (); /* initialize host table */ usrNetProtoInit (); /* initialize various protocols */ netLibInit ();#ifdef INCLUDE_MIB2_IP m2IpInit (MIB2IP_MAX_ROUTE_TBL_SIZE); /* the IP group */#endif /* MIB_IP */#ifdef INCLUDE_ARP_API arpLibInit ();#endif#ifdef INCLUDE_NET_SHOW netShowInit ();#endif#if defined(INCLUDE_END) muxMaxBinds = MUX_MAX_BINDS; if (muxLibInit() == ERROR) { NET_DIAG(("muxLibInit() returned errno = 0x%x\n", errno)); return (ERROR); } /* Add our default address resolution functions. */#ifdef INCLUDE_NT_ULIP muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, ntResolv);#else muxAddrResFuncAdd (M2_ifType_ethernet_csmacd, 0x800, ipEtherResolvRtn);#endif /* Add in mux ENDs. */ for (count = 0, pDevTbl = endDevTbl; pDevTbl->endLoadFunc != END_TBL_END; pDevTbl++, count++) { /* Make sure that WDB has not already installed the device. */ if (!pDevTbl->processed) { pCookie = muxDevLoad(pDevTbl->unit, pDevTbl->endLoadFunc, pDevTbl->endLoadString, pDevTbl->endLoan, pDevTbl->pBSP); if (pCookie == NULL) { printf("muxDevLoad failed for device entry %d!\n", count); } else { pDevTbl->processed = TRUE; if (muxDevStart(pCookie) == ERROR) { printf("muxDevStart failed for device entry %d!\n", count); } } } }#endif /* INCLUDE_END */#ifdef INCLUDE_PPP#ifdef INCLUDE_PPP_CRYPT cryptRtnInit (&pppCryptRtn); /* install crypt() routine */#endif /* INCLUDE_PPP_CRYPT */ loginInit(); /* for possible login option */ pppSecretLibInit(); /* initialize secrets library */ pppHookLibInit (); /* initialize pppHooks library */ pppShowInit();#endif /* INCLUDE_PPP */#ifdef INCLUDE_NET_REM_IO remLastResvPort = 1010; /* pick an unused port number so we don't * * have to wait for the one used by the * * by the bootroms to time out */ _func_ftpLs = ftpLs; /* init ptr to ftp dir listing routine */ _func_netLsByName = netLsByName; /* init ptr to netDrv listing routine */ _func_remCurIdGet = (FUNCPTR) remCurIdGet; _func_remCurIdSet = (FUNCPTR) remCurIdSet;#endif /* INCLUDE_NET_REM_IO */#ifdef INCLUDE_MIB2_IF /* add hooks for if.c */ _m2SetIfLastChange = (FUNCPTR) m2SetIfLastChange; _m2IfTableUpdate = (FUNCPTR) m2IfTableUpdate;#endif /* INCLUDE_MIB2_IF */#ifdef INCLUDE_DHCPR#ifndef INCLUDE_DHCPS dhcprResult = dhcprLibInit (DHCPS_MAX_MSGSIZE); if (dhcprResult == ERROR) NET_DIAG(("Unable to initialize DHCP relay agent library!\n"));#endif#endif if ((strncmp (params.bootDev, "bp", 2) == 0) || (strncmp (params.bootDev, "sm", 2) == 0)) { /* booting via backplane */ pBootString = params.bad; } else pBootString = params.ead;#ifdef INCLUDE_DHCPC /* * Remove any values for DHCP lease origin and lease duration from * address string and store in dhcpcBootLease global. Set dhcpBoot * flag to indicate if DHCP lease values were found. */ if (sysFlags & SYSFLG_AUTOCONFIG) if (dhcpcLeaseGet (pBootString, &dhcpBoot) == ERROR) { printf ("Unable to verify assigned DHCP address.\n"); return (ERROR); }#else /* * If network configuration protocols are used, check address * for DHCP lease information. If found (and removed), exit * with an error, since the active DHCP lease cannot be maintained. */ if (sysFlags & SYSFLG_AUTOCONFIG) if (dhcpcBootLineClean (pBootString) == OK) { printf ("Can't use dynamic address %s without DHCP.\n", pBootString); return (ERROR); }#endif /* INCLUDE_DHCPC */ /* attach and configure interfaces */#ifdef INCLUDE_ULIP if (strncmp (params.bootDev, "ul", 2) == 0) { /* * Booting with the simulator's interface completely configures the * device. No DHCP/BOOTP address assignment is available. */ extern int ulipInit ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -