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

📄 usrnetwork.c

📁 ixp2400 bsp for vxworks
💻 C
📖 第 1 页 / 共 5 页
字号:
#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 */	char            netDev [BOOT_DEV_LEN + 1];	BOOL            seqAddrOn = FALSE;	BOOL            configureBp = TRUE;	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", "sm0");	bootNetmaskExtract (params.bad, &proxymask);	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 = proxymask;	   	    }		else if (sysProcNumGet () == 0)		    {		    /*		     * The shared memory master calculates the next available		     * address, if possible. Slaves will read it directly.		     */		    if ( useEtherAddr )			{	    	    	startAddr = ntohl (inet_addr (params.ead)) + 1;		        netmask = 0xffffffff;			}		    else		/* Configuration error */		       {		       printf ("Error: No address for proxy service.\n");		       printf ("Backplane IP Address must be specified.\n");		       configureBp = FALSE;		       }		    }		}	    else                     /* PROXY WITHOUT SEQ ADDR */		{		if (BP_ADDR_NOT_GIVEN)		    {		    if (sysProcNumGet () == 0)		        configureBp = FALSE;    /* Can't start master. */		    }		else		    {   /* startAddr is left as zero */	    	    netmask = proxymask;		    }	        }	    }	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 = proxymask;		}            else if (sysProcNumGet () == 0)		{		/* Don't start the master if the backplane address is empty. */		configureBp = FALSE;		}	    }	if (configureBp == TRUE)	    {	    if (usrBpInit (bpDev, 0, startAddr) == ERROR)	    	return (ERROR);	    (void) usrNetIfAttach (bpDev, 0, 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, 0, 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_SM_NET_SHOW    smNetShowInit ();#endif /* INCLUDE_SM_NET_SHOW */#endif /* INCLUDE_SM_NET */    if (sysFlags & SYSFLG_PROXY)        {#ifdef INCLUDE_PROXY_CLIENT        printf ("registering proxy client %s...", pBootString);        devName [0] = EOS;        sprintf(devName, "%s%d", params.bootDev, params.unitNum);        if (proxyReg (devName, pBootString) == ERROR)            {            printf ("failed: error %x\n", errno);            return (ERROR);            }        printf ("done.\n");#else /* INCLUDE_PROXY_CLIENT */        printf ("proxy client requested but not included.\n");        return (ERROR);#endif /* INCLUDE_PROXY_CLIENT */        }#ifdef INCLUDE_PROXY_SERVER#ifndef INCLUDE_SM_NET    /* Remove netmask from address if not already done. */    bootNetmaskExtract (params.bad, &proxymask);#endif    if ((sysProcNumGet () == 0) && (params.bad [0] != EOS) &&        (params.ead [0] != EOS))        {        hashLibInit ();                 /* make sure hash functions init'd */        if (proxyArpLibInit (8, 8) == ERROR)	    NET_DIAG(("Unable to initialize proxy server.\n"));        else	    {            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 */    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, &params);        }#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);	if (routeAdd (numString, params.gad) == ERROR)	    NET_DIAG(("Unable to add route to %s; errno = 0x%x.\n", numString,		      errno));        }    /* 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     /* 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 (nfsMaxPath < 1)            {            NET_DIAG(("Error initializing NFS server, invalid NFS_MAXPATH\n"));            return (ERROR);            }        if ((nfsMaxFileName < 1) || (nfsMaxFileName > NAME_MAX))            {            NET_DIAG(("Error initializing NFS server, invalid NFS_MAXFILENAME\n"));            return (ERROR);            }	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");#

⌨️ 快捷键说明

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