In order to get around this problem, we have assumed
that our network architecture is such that the IP address
of the default router is host id 1 on the local subnet.
(This matches our real network topology)
bootLoadFromNW()
{
struct in_addr inaddrServer;
struct in_addr inaddrDefGateway;
char *pchAddrDefDestination = "0.0.0.0";
char pchAddrDefGateway[32];
/*
* Get parameters via bootpParamsGet()
* params.had = Host IP address (char *)
* netmask = Subnet mask
*/
bootpParamsGet( .... );
/*
* Generate the default router
*/
inAddrServer_addr = inet_addr( params.had );
inaddrDefGateway.s_addr = (inaddrServer.s_addr & netmask) + 1;
inet_ntoa_b( inaddrDefGateway, pchAddrDefGateway );
rc = routeAdd( pchAddrDefDestination, pchAddrDefGateway );
/*
* Get the boot file via TFTP, etc
*/
}
The problem is, that even though I have defined a default
gateway using
routeAdd("0.0.0.0","135.86.28.1")
when the system boots up, no default routing is shown.
The routeAdd function is definitely being called, with
the correct parameters (an no error code is reported).
Can anyone tell me what I'm doing wrong, or how to
set up a default router in VxWorks (preferably in
the bootrom code) ??
Please help
Arthur Watt
E-Mail: art...@lucent.com
Tel: 44 1666 833727
>We have a VxWorks system which boots over the network via the
>BOOTP protocol. The VxWorks API bootpParamsGet() does not return
>the gateway address, hence we can only boot the VxWorks target
>from machines on the same subnet.
[snip]
>Please help
>Arthur Watt
Arthur,
since you got a BOOTP reply, your host is on the same _physical_
network. Then you can turn your target into a router to the host's
_logical_ network. Of course, your host must also have a
router/gateway entry
to your target _logical_ network.
See my variation of:
/*******************************************************************************
*
* bootLoad - load a module into memory
*
* RETURNS: OK or ERROR
*/
LOCAL STATUS bootLoad
(
char * bootString,
FUNCPTR *pEntry
)
{
BOOT_PARAMS params;
char nad [20]; /* host's network internet addr */
int netmask; /* temporary storage */
char netDev [BOOT_DEV_LEN + 1];
char bootDev [BOOT_DEV_LEN];
BOOL backplaneBoot;
char * pBootAddr;
BOOTP_MSG bpm;
char targetNet [INET_ADDR_LEN];
char hostNet [INET_ADDR_LEN];
/* .. skipped come code, among others usrNetIfAttach ("ei"..) /
/* get the boot parameters via bootp */
if (bootpRequest ("ei0", &bpm, pBootAddr, params.bootFile,
params.had ) != OK)
return (ERROR);
/* currently not processing vendor extensions ...*/
errno = 0;
ifMaskSet ( "ei0", 0xff000000);
errno = 0;
if (ifAddrSet ("ei0", pBootAddr) != OK)
{
printf("\nCould not set interface address %s. Errno =%#x ",
pBootAddr, errno);
}
hostAdd("bootHost", params.had);
/* associate hostName with the specified host address */
hostAdd (params.hostName, params.had);
/* 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, nad);
routeAdd (nad, params.gad);
}
else
{
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
/* check whether a routeNetAdd is necessary */
inet_netof_string ( pBootAddr, targetNet);
inet_netof_string ( params.had, hostNet);
if ( strcmp ( targetNet, hostNet) != NULL)
{
printf ("\n adding %s as route to Network %s\n",
pBootAddr, hostNet);
routeNetAdd (hostNet, pBootAddr);
strncpy ( params.gad, pBootAddr, BOOT_ADDR_LEN -1);
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
}
}
/* now load the bootfile .... */
/* ... skipped come code */
bootStructToString (BOOT_LINE_ADRS, ¶ms);
/* now the router entry is in the bootline, too ... */
return (OK);
}
/******************************************************************************
*
* bootpRequest - get network parameters via BOOTP.
*
* 20Nov96, Grz modified
*
* RETURNS: OK if successful otherwise ERROR
*/
LOCAL STATUS bootpRequest
(
char *netDev, /* boot device */
BOOTP_MSG *bpm, /* bootp message */
char *pInetAddr, /* client= my IP addr */
char *pBootFile,
char *pHostAddr
)
{
printf ("Getting boot parameters via network interface %s",
netDev);
if (bootpMsgSend(netDev, &bpServerAddress, 0, bpm,
sysClkRateGet() * 10) == ERROR)
{
printf("Error: No BOOTP Reply\n");
return(ERROR);
}
inet_ntoa_b ( bpm->bp_siaddr, pHostAddr);
inet_ntoa_b ( bpm->bp_yiaddr, pInetAddr);
printf ("\nBootp Server: %s\n", pHostAddr);
printf (" My IP: %s\n", pInetAddr);
if (strlen (bpm->bp_file) >= BOOT_FILE_LEN)
{
printf (" Boot file: %s STRING TOO LONG\n", bpm->bp_file);
return (ERROR);
}
strcpy (pBootFile, bpm->bp_file);
printf (" Boot file: %s\n", pBootFile);
return(OK);
}
=======================================
Hope that helps.
Rolf
--
Rolf Grzibek 10056...@compuserve.com