📄 usrnetwork.c.bak
字号:
dhcpcShowInit ();
#endif
/*
* Renew or obtain a lease as needed and store values in boot line.
* If successful, the pDhcpcBootCookie global is set to allow user
* access to the lease and the timing information is stored in the
* dhcpcBootLease global for later use.
*/
if (dhcpcConfigSet (¶ms, &netmask, &dhcpBoot, attachFlag) == ERROR)
return (ERROR);
#endif /* INCLUDE_DHCPC */
/* Configure the network device using the address/mask information. */
if (attachFlag && (usrNetIfConfig (pNetDev, params.unitNum, pBootString,
params.targetName, netmask) != OK))
return (ERROR);
/* attach backplane interface (as second interface) */
#ifdef INCLUDE_SM_NET
#define BP_ADDR_GIVEN (params.bad [0] != EOS)
#define BP_ADDR_NOT_GIVEN (params.bad [0] == EOS)
if ( !backplaneBoot )
{
char *bpDev;
BOOL proxyOn = FALSE; /* Initialize Defaults */
u_long startAddr = 0; /* Default sequential Addr off */
int bpNetMask = 0;
char netDev [BOOT_DEV_LEN + 1];
BOOL seqAddrOn = FALSE;
BOOL configureBp = FALSE;
BOOL useEtherAddr = FALSE;
/* Turn switches ON as needed */
#ifdef INCLUDE_SM_SEQ_ADDR
seqAddrOn = TRUE;
#endif
#ifdef INCLUDE_PROXY_DEFAULT_ADDR
useEtherAddr = TRUE;
#endif
#ifdef INCLUDE_PROXY_SERVER
proxyOn = TRUE;
#endif
bpDev = "sm";
sprintf(netDev, "%s%d", "sm", params.unitNum);
bootNetmaskExtract (params.bad, &bpNetMask);
if (proxyOn == TRUE)
{
if (seqAddrOn == TRUE) /* PROXY WITH SEQ ADDR */
{
/* Pick address from backplane or ethernet */
if (BP_ADDR_GIVEN)
{
startAddr = ntohl (inet_addr (params.bad));
netmask = bpNetMask;
configureBp = TRUE;
}
else
{
if ( useEtherAddr )
{
startAddr = ntohl (inet_addr (params.ead)) + 1;
configureBp = TRUE;
}
else /* Configuration error */
{
printf(
"Error: PROXY with sequential addr enable, and default addr disable.\n");
printf("Backplane IP Address must be specified.\n");
}
}
}
else /* PROXY WITHOUT SEQ ADDR */
{
if (BP_ADDR_NOT_GIVEN)
{
printf ("Error: PROXY with sequential addr disabled.\n");
printf ("Shared mem IP Address must be specified.\n");
}
else
{ /* startAddr is left as zero */
netmask = bpNetMask;
configureBp = TRUE;
}
}
}
else
{ /* Using Subnet without PROXY Arp */
if (BP_ADDR_GIVEN)
{
if (seqAddrOn == TRUE)
{ /* Assign sequential address to backplane */
startAddr = ntohl (inet_addr (params.bad));
netmask = bpNetMask;
}
/* Else Don't use sequential addr on backplane */
configureBp = TRUE;
}
}
if (configureBp == TRUE)
{
if (usrBpInit (bpDev, params.unitNum, startAddr) == ERROR)
return (ERROR);
(void) usrNetIfAttach (bpDev, params.unitNum, params.bad);
/* Assigned Back Plane Address if needed */
if ((BP_ADDR_NOT_GIVEN) &&
(smNetInetGet (netDev, params.bad, NONE) == OK))
printf ("Backplane address: %s\n", params.bad);
(void) usrNetIfConfig (bpDev, params.unitNum, params.bad,
(char *) NULL, netmask);
}
}
#ifdef INCLUDE_DHCPC
if (backplaneBoot)
{
if ((sysFlags & SYSFLG_AUTOCONFIG) && !(sysFlags & SYSFLG_PROXY))
{
printf ("Warning! DHCP over backplane may need proxy arp.\n");
}
}
#endif /* INCLUDE_DHCPC */
#ifdef INCLUDE_PROXY_SERVER
if ((sysProcNumGet () == 0) && (params.bad [0] != EOS) &&
(params.ead [0] != EOS))
{
inet_netof_string (params.bad, numString);
routeDelete (numString, params.bad);
hashLibInit (); /* make sure hash functions init'd */
proxyArpLibInit (8, 8);
printf ("Creating proxy network: %s\n", params.bad);
if (proxyNetCreate (params.bad, params.ead) == ERROR)
{
printf ("proxyNetCreate failed:%x\n", errno);
return (ERROR);
}
}
#endif /* INCLUDE_PROXY_SERVER */
#ifdef INCLUDE_SHOW_ROUTINES
smNetShowInit ();
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_SM_NET */
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 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);
routeAdd (numString, params.gad);
}
/* associate host name with the specified host address */
hostAdd (params.hostName, params.had);
#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 */
#ifdef INCLUDE_PASSFS
/* 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
netDrv (); /* init remote file driver */
sprintf (devName, "%s:", params.hostName); /* make dev name */
protocol = (params.passwd[0] == EOS) ? 0 : 1; /* pick protocol */
netDevCreate (devName, params.hostName, protocol); /* create device */
/* set the user id, and current directory */
iam (params.usr, params.passwd);
ioDefPathSet (devName);
taskDelay (sysClkRateGet () / 4); /* 1/4 of a second */
#endif /* INCLUDE_NET_REM_IO */
#endif /* INCLUDE_PASSFS */
#ifdef INCLUDE_ZBUF_SOCK
zbufSockLibInit (); /* initialize zbuf socket interface */
#endif /* INCLUDE_ZBUF_SOCK */
#ifdef INCLUDE_TCP_DEBUG
tcpTraceInit (); /* initialize TCP debug facility */
#endif /* INCLUDE_TCP_DEBUG */
/* start the rlogin and telnet daemon */
#ifdef INCLUDE_RLOGIN
rlogInit ();
#endif /* INCLUDE_RLOGIN */
#ifdef INCLUDE_TELNET
telnetInit ();
#endif /* INCLUDE_TELNET */
/* initialize rpc daemon if specified */
#ifdef INCLUDE_RPC
rpcInit ();
#endif /* INCLUDE_RPC */
#if defined(INCLUDE_FTP_SERVER)
#if defined(INCLUDE_FTPD_SECURITY)
loginInit();
ftpdInit((FUNCPTR) loginUserVerify, 0);
#else
ftpdInit ((FUNCPTR) NULL,0);
#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)
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 */
/* rem: by cxj 06/06/2002
printf ("NFS client support not included.\n");
*/
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 boot device.
* Eventually, need to allow for multiple network devices.
*/
devName [0] = EOS;
sprintf(devName, "%s%d", params.bootDev, 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;
dhcpsResult = dhcpsInit (devlist, 1, DHCPS_MAX_MSGSIZE,
dhcpsLeaseTbl, dhcpsLeaseTblSize,
dhcpsRelayTbl, dhcpsRelayTblSize,
dhcpTargetTbl, dhcpTargetTblSize);
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -