📄 usrnetwork.c
字号:
}#endif /* INCLUDE_PROXY_SERVER */ if (params.targetName[0] != EOS) sethostname (params.targetName, strlen (params.targetName));#ifdef INCLUDE_DHCPC /* * If the target address is not manually assigned, add timing * information so later reboots will detect the DHCP lease. */ if (dhcpBoot == TRUE) { if (netmask == 0) sprintf (numString, "::%lx:%lx", dhcpcBootLease.lease_duration, dhcpcBootLease.lease_origin); else sprintf (numString, ":%x:%lx:%lx", ntohl (netmask), dhcpcBootLease.lease_duration, dhcpcBootLease.lease_origin); if (backplaneBoot) strcat (params.bad, numString); else strcat (params.ead, numString); bootStructToString (BOOT_LINE_ADRS, ¶ms); }#endif /* INCLUDE_DHCPC */#if 0 /* if a gateway was specified, extract the network part of the host's * address and add a route to this network */ if (params.gad[0] != EOS) { inet_netof_string (params.had, numString); if (routeAdd (numString, params.gad) == ERROR) NET_DIAG(("Unable to add route to %s; errno = 0x%x.\n", numString, errno)); }#else /* if a gateway was specified, add a default route (DZ) */ if (params.gad[0] != EOS) { if (routeAdd ("0", params.gad) == ERROR) NET_DIAG(("Unable to add dafault route to; errno = 0x%x.\n", errno)); }#endif /* associate host name with the specified host address */ if (hostAdd (params.hostName, params.had) == ERROR) NET_DIAG(("Unable to add host %s to host table; errno = 0x%x.\n", params.hostName, errno));#ifdef INCLUDE_ULIP /* Set up host names and routes for talking to other vxworks's */ { extern char *vxsim_ip_addr; extern char *vxsim_ip_name; int vxsim_num_ulips = 16; int ix; char host [50]; char hostip [50]; /* declare other simulated vxWorks' */ for (ix = 0; ix < vxsim_num_ulips; ix++) { sprintf (host, vxsim_ip_name, ix); sprintf (hostip, vxsim_ip_addr, ix); hostAdd (host, hostip); } /* Add default route thru host */ routeAdd ("0.0.0.0", params.had); routeAdd (params.ead, "localhost"); /* loopback for local addresses */ }#endif /* INCLUDE_ULIP */#if ((defined (INCLUDE_PASSFS)) || (defined (INCLUDE_NTPASSFS))) /* The device names for passFs and netDrv are the same, e.g. "host:", * therefore, we have and either/or for the two devices. * Bulk of work done in usrConfig.c:usrRoot() for passFs installation. */ iam (params.usr, params.passwd); devName[0] = EOS; protocol = (params.passwd[0] == EOS) ? 0 : 1; /* pick protocol */#else /* create transparent remote file access device; * device name is host name with ':' appended. * protocol is rcmd if no password, or ftp if password specified */#ifdef INCLUDE_NET_REM_IO if (netDrv () == ERROR) /* init remote file driver */ NET_DIAG(("Error initializing netDrv; errno = 0x%x\n", errno)); else { sprintf (devName, "%s:", params.hostName); /* make dev name */ protocol = (params.passwd[0] == EOS) ? 0 : 1; /* pick protocol */ /* create device */ if (netDevCreate (devName, params.hostName, protocol) == ERROR) NET_DIAG(("Error creating network device %s - errno = 0x%x\n", devName, errno)); else if (ioDefPathSet (devName) == ERROR) /* set the current directory */ NET_DIAG(("Error setting default path to %s - errno = 0x%x\n", devName, errno)); } iam (params.usr, params.passwd); /* set the user id */ taskDelay (sysClkRateGet () / 4); /* 1/4 of a second */#endif /* INCLUDE_NET_REM_IO */#endif /* INCLUDE_PASSFS || INCLUDE_NTPASSFS */#ifdef INCLUDE_ZBUF_SOCK if (zbufSockLibInit () == ERROR) /* initialize zbuf socket interface */ NET_DIAG(("Zbuf initialization failed.\n"));#endif /* INCLUDE_ZBUF_SOCK */#ifdef INCLUDE_TCP_DEBUG tcpTraceInit (); /* initialize TCP debug facility */#endif /* INCLUDE_TCP_DEBUG */ /* start the rlogin daemon */#ifdef INCLUDE_RLOGIN rlogInit ();#endif /* INCLUDE_RLOGIN */ /* start the telnet daemon */#ifdef INCLUDE_TELNET#ifdef INCLUDE_SHELL#ifndef TELNETD_PARSER_CONTROL#define TELNETD_PARSER_CONTROL shellParserControl#endif #endif /* INCLUDE_SHELL */#ifndef TELNETD_PARSER_CONTROL#error You must define INCLUDE_SHELL or TELNETD_PARSER_CONTROL if you define INCLUDE_TELNET.#endif #ifndef TELNETD_PORT#define TELNETD_PORT 23#endif#ifndef TELNETD_MAX_CLIENTS#define TELNETD_MAX_CLIENTS 1#endif#ifndef TELNETD_TASKFLAG#define TELNETD_TASKFLAG FALSE#endif /* Configure telnet server to use a shell as a command interpreter. */ if (telnetdParserSet (TELNETD_PARSER_CONTROL) == ERROR) printf ("Error %x: unable to attach a shell to telnet server.\n", errno); else if (telnetdInit (TELNETD_MAX_CLIENTS, TELNETD_TASKFLAG) == ERROR) printf ("Error %x: unable to initialize telnet server.\n", errno); else if (telnetdStart (TELNETD_PORT) == ERROR) printf ("Error %x: unable to start telnet server.\n", errno);#endif /* INCLUDE_TELNET */ /* initialize rpc daemon if specified */#ifdef INCLUDE_RPC if (rpcInit () == ERROR) NET_DIAG(("RPC initialization failed!\n"));#endif /* INCLUDE_RPC */#if defined(INCLUDE_FTP_SERVER)#if defined(INCLUDE_FTPD_SECURITY) loginInit(); if (ftpdInit((FUNCPTR) loginUserVerify, 0) == ERROR) NET_DIAG(("Unable to start FTP server; errno = 0x%x\n", errno));#else if (ftpdInit ((FUNCPTR) NULL,0) == ERROR) NET_DIAG(("Unable to start FTP server; errno = 0x%x\n", errno));#endif#endif#ifdef INCLUDE_TFTP_SERVER tftpdInit (0, 0, 0, FALSE, 0);#endif /* initialize NFS server and client if specified */#ifdef INCLUDE_NFS_SERVER if (nfsdInit (0, 0, 0, 0, 0, 0) == ERROR) { NET_DIAG(("NFS server initialization failed!\n")); return (ERROR); }#endif /* INCLUDE_NFS_SERVER */#ifdef INCLUDE_NFS /* * The following values are the default values used in NFS. * They can be reset here if necessary. * * nfsMaxMsgLen = 8192 message size (decrease only) * nfsTimeoutSec = 5 timeout seconds * nfsTimeoutUSec = 0 timeout microseconds */#if (CPU==SIMHPPA) nfsMaxMsgLen = 512;#endif nfsAuthUnixSet (params.hostName, NFS_USER_ID, NFS_GROUP_ID, 0, (int *) 0); if (nfsDrv () == ERROR) /* initialize nfs driver */ printf ("Error initializing NFS, errno = %#x\n", errno); else {#ifdef INCLUDE_NFS_MOUNT_ALL printf ("Mounting NFS file systems from host %s", params.hostName); if (params.targetName[0] != EOS) printf (" for target %s:\n", params.targetName); else printf (":\n"); nfsMountAll (params.hostName, params.targetName, FALSE); printf ("...done\n");#endif /* INCLUDE_NFS_MOUNT_ALL */ /* if the boot pathname starts with a device name, e.g. an nfs mount, * then set the current directory to that device */ (void) iosDevFind (sysBootFile, &pBootString); if (pBootString != sysBootFile) { devName[0] = EOS; strncat (devName, sysBootFile, pBootString - sysBootFile); ioDefPathSet (devName); } }#else /* INCLUDE_NFS */ pBootString = NULL; /* dummy use to quiet compiler warning*/#endif /* INCLUDE_NFS */#if defined (INCLUDE_DHCPS) || defined (INCLUDE_DHCPR) /* * For now, set server or relay agent to listen on primary interface. * Eventually, need to allow for multiple network devices. */ devName [0] = EOS; sprintf(devName, "%s%d", pNetDev, params.unitNum); devlist[0] = ifunit (devName);#ifdef INCLUDE_DHCPS#ifdef INCLUDE_DHCPR printf ("DHCP Server present. Relay agent not permitted.\n");#endif if (devlist[0] == NULL) printf("Network interface %s not found. DHCP server not started.\n", devName); else { dhcpsResult = dhcpsLeaseHookAdd (DHCPS_LEASE_HOOK); if (dhcpsResult == ERROR) { printf ("Warning: Required storage hook not installed.\n"); printf ("Lease records will not be saved.\n"); } dhcpsResult = dhcpsAddressHookAdd (DHCPS_ADDRESS_HOOK); if (dhcpsResult == ERROR) { printf ("Warning: No DHCP server address cache!"); printf (" Later entries will not be saved.\n"); } dhcps_dflt_lease = DHCPS_DEFAULT_LEASE; dhcps_max_lease = DHCPS_MAX_LEASE; if (dhcpsDfltCfgParams.pDhcpsIfTbl[0].ifName[0] == EOS) { sprintf (dhcpsDfltCfgParams.pDhcpsIfTbl[0].ifName, "%s", devName); dhcpsDfltCfgParams.numDev = 1; } dhcpsResult = dhcpsInit (&dhcpsDfltCfgParams); if (dhcpsResult == ERROR) printf ("Error initializing DHCP server. Not started.\n"); else { dhcpsResult = taskSpawn ("tDhcpsTask", dhcpsTaskPriority, dhcpsTaskOptions, dhcpsTaskStackSize, (FUNCPTR) dhcpsStart, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (dhcpsResult == ERROR) printf ("Unable to start DHCP server task.\n"); printf ("DHCP server started.\n"); } }#else if (devlist[0] == NULL) printf("Network interface %s not found. DHCP relay agent not started.\n", devName); else if (dhcprResult == OK) { dhcprResult = dhcprInit (devlist, 1, dhcpTargetTbl, dhcpTargetTblSize); if (dhcprResult == ERROR) printf ("Error initializing DHCP relay agent. Not started.\n"); else { dhcprResult = taskSpawn ("tDhcprTask", dhcprTaskPriority, dhcprTaskOptions, dhcprTaskStackSize, (FUNCPTR) dhcprStart, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (dhcprResult == ERROR) printf ("Unable to start DHCP relay agent task.\n"); printf ("DHCP relay agent started.\n"); } }#endif#endif /* INCLUDE_DHCPS or INCLUDE_DHCPR */#ifdef INCLUDE_SNTPC sntpcInit (SNTP_PORT);#endif#ifdef INCLUDE_SNTPS /* * For now, set server to listen on primary interface. * Eventually, need to allow for multiple network devices. */ devName [0] = EOS; sprintf(devName, "%s%d", pNetDev, params.unitNum); if (sntpsInit (devName, SNTPS_MODE, SNTPS_DSTADDR, SNTPS_INTERVAL, SNTP_PORT, SNTPS_TIME_HOOK) == ERROR) NET_DIAG(("Unable to start SNTP server; errno = 0x%x\n", errno));#endif#ifdef INCLUDE_PING if (pingLibInit () == ERROR) /* initialize the ping utility */ NET_DIAG(("Failed to initialize ping\n"));#endif /* INCLUDE_PING */#ifdef INCLUDE_RIP#ifndef RIP_SUPPLIER#define RIP_SUPPLIER 0#endif /* RIP_SUPPLIER */#ifndef RIP_GATEWAY#define RIP_GATEWAY 0#endif /* RIP_GATEWAY */#ifndef RIP_VERSION#define RIP_VERSION 1#endif /* RIP_VERSION */#ifndef RIP_MULTICAST#define RIP_MULTICAST 0#endif /* RIP_MULTICAST */#ifndef RIP_TIMER_RATE#define RIP_TIMER_RATE 1#endif /* RIP_TIMER_RATE */#ifndef RIP_SUPPLY_INTERVAL#define RIP_SUPPLY_INTERVAL 30#endif /* RIP_SUPPLY_INTERVAL */#ifndef RIP_EXPIRE_TIME#define RIP_EXPIRE_TIME 180#endif /* RIP_EXPIRE_TIME */#ifndef RIP_GARBAGE_TIME#define RIP_GARBAGE_TIME 300#endif /* RIP_GARBAGE_TIME */#ifndef RIP_AUTH_TYPE#define RIP_AUTH_TYPE 1#endif /* RIP_AUTH_TYPE */ if (ripLibInit(RIP_SUPPLIER, RIP_GATEWAY, RIP_MULTICAST, RIP_VERSION, RIP_TIMER_RATE, RIP_SUPPLY_INTERVAL, RIP_EXPIRE_TIME, RIP_GARBAGE_TIME, RIP_AUTH_TYPE) == ERROR) NET_DIAG(("RIP initialization failed!\n"));#endif /* INCLUDE_RIP */#ifdef INCLUDE_DNS_RESOLVER if (usrResolvInit () == ERROR) { printf ("Error initializing resolvLib\n"); return(ERROR); }#endif /* INCLUDE_DNS_RESO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -