summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/nfs/bootp_subr.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2010-02-18 00:24:25 +0000
committerChris Johns <chrisj@rtems.org>2010-02-18 00:24:25 +0000
commita9fa9b765df38cc5319ae734b5148fd47ebbfd8d (patch)
tree55ee28ea4a162bfb26c7a2cb6106b057beda70ae /cpukit/libnetworking/nfs/bootp_subr.c
parentThis commit was generated by cvs2svn to compensate for changes in r22658, (diff)
downloadrtems-a9fa9b765df38cc5319ae734b5148fd47ebbfd8d.tar.bz2
2010-02-18 Chris Johns <chrisj@rtems.org>
* libfs/src/rfs/rtems-rfs-bitmaps.c, libfs/src/rfs/rtems-rfs-bitmaps.h, libfs/src/rfs/rtems-rfs-bitmaps-ut.c, libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-block-pos.h, libfs/src/rfs/rtems-rfs-buffer-bdbuf.c, libfs/src/rfs/rtems-rfs-buffer.c, libfs/src/rfs/rtems-rfs-buffer-devio.c, libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h, libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h, libfs/src/rfs/rtems-rfs-dir-hash.c, libfs/src/rfs/rtems-rfs-dir-hash.h, libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h, libfs/src/rfs/rtems-rfs-file-system.c, libfs/src/rfs/rtems-rfs-file-system-fwd.h, libfs/src/rfs/rtems-rfs-file-system.h, libfs/src/rfs/rtems-rfs-format.c, libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c, libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h, libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h, libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h, libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems-dev.c, libfs/src/rfs/rtems-rfs-rtems-dir.c, libfs/src/rfs/rtems-rfs-rtems-file.c, libfs/src/rfs/rtems-rfs-rtems.h, libfs/src/rfs/rtems-rfs-rtems-utils.c, libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h, libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h: New. * Makefile.am, preinstall.am, libfs/Makefile.am, wrapup/Makefile.am: Updated with the RFS support. * libfs/README: Updated after 10 years. * libblock/src/flashdisk.c, libblock/src/nvdisk.c, libblock/src/ramdisk-driver.c: Updated to the new error reporting in libblock. * libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing the size in long mode. * libnetworking/nfs/bootp_subr.c, libnetworking/rtems/rtems_bootp.c, libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP to the forever behaviour of 4.9 with the ability to call BOOTP and control the process if required.
Diffstat (limited to '')
-rw-r--r--cpukit/libnetworking/nfs/bootp_subr.c78
1 files changed, 44 insertions, 34 deletions
diff --git a/cpukit/libnetworking/nfs/bootp_subr.c b/cpukit/libnetworking/nfs/bootp_subr.c
index 7a0e8901f6..34754ac77a 100644
--- a/cpukit/libnetworking/nfs/bootp_subr.c
+++ b/cpukit/libnetworking/nfs/bootp_subr.c
@@ -152,8 +152,6 @@ bootpc_adjust_interface(struct ifreq *ireq,struct socket *so,
struct sockaddr_in *gw,
struct proc *procp);
-void bootpc_init(int update_files);
-
#ifdef BOOTP_DEBUG
void
bootpboot_p_sa(struct sockaddr *sa, struct sockaddr *ma)
@@ -463,7 +461,7 @@ bootpc_call(
goto gotreply; /* break two levels */
} /* while secs */
- } /* forever send/receive */
+ } /* send/receive a number of times then return an error */
{
uint32_t addr = ntohl(sin->sin_addr.s_addr);
printf("BOOTP timeout for server %lu.%lu.%lu.%lu\n",
@@ -943,8 +941,8 @@ processOptions (unsigned char *optbuf, int optbufSize)
#define EALEN 6
-void
-bootpc_init(int update_files)
+bool
+bootpc_init(bool update_files, bool forever)
{
struct bootp_packet call;
struct bootp_packet reply;
@@ -965,7 +963,7 @@ bootpc_init(int update_files)
* If already filled in, don't touch it here
*/
if (nfs_diskless_valid)
- return;
+ return true;
/*
* If we are to update the files create the root
@@ -991,7 +989,7 @@ bootpc_init(int update_files)
break;
if (ifp == NULL) {
printf("bootpc_init: no suitable interface\n");
- return;
+ return false;
}
bzero(&ireq,sizeof(ireq));
sprintf(ireq.ifr_name, "%s%d", ifp->if_name,ifp->if_unit);
@@ -1000,28 +998,31 @@ bootpc_init(int update_files)
if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)) != 0) {
printf("bootpc_init: socreate, error=%d", error);
- return;
+ return false;
}
if (bootpc_fakeup_interface(&ireq,so,procp) != 0) {
- return;
+ soclose(so);
+ return false;
}
/* Get HW address */
for (ifa = ifp->if_addrlist;ifa; ifa = ifa->ifa_next)
if (ifa->ifa_addr->sa_family == AF_LINK &&
- (sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) &&
- sdl->sdl_type == IFT_ETHER)
+ (sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) &&
+ sdl->sdl_type == IFT_ETHER)
break;
if (!sdl) {
printf("bootpc: Unable to find HW address\n");
- return;
+ soclose(so);
+ return false;
}
if (sdl->sdl_alen != EALEN ) {
printf("bootpc: HW address len is %d, expected value is %d\n",
sdl->sdl_alen,EALEN);
- return;
+ soclose(so);
+ return false;
}
printf("bootpc hw address is ");
@@ -1036,32 +1037,39 @@ bootpc_init(int update_files)
bootpboot_p_iflist();
bootpboot_p_rtlist();
#endif
+
+ while (true) {
+ bzero((caddr_t) &call, sizeof(call));
+
+ /* bootpc part */
+ call.op = 1; /* BOOTREQUEST */
+ call.htype= 1; /* 10mb ethernet */
+ call.hlen=sdl->sdl_alen; /* Hardware address length */
+ call.hops=0;
+ xid++;
+ call.xid = txdr_unsigned(xid);
+ bcopy(LLADDR(sdl),&call.chaddr,sdl->sdl_alen);
- bzero((caddr_t) &call, sizeof(call));
-
- /* bootpc part */
- call.op = 1; /* BOOTREQUEST */
- call.htype= 1; /* 10mb ethernet */
- call.hlen=sdl->sdl_alen; /* Hardware address length */
- call.hops=0;
- xid++;
- call.xid = txdr_unsigned(xid);
- bcopy(LLADDR(sdl),&call.chaddr,sdl->sdl_alen);
-
- call.vend[0]=99;
- call.vend[1]=130;
- call.vend[2]=83;
- call.vend[3]=99;
- call.vend[4]=255;
+ call.vend[0]=99;
+ call.vend[1]=130;
+ call.vend[2]=83;
+ call.vend[3]=99;
+ call.vend[4]=255;
- call.secs = 0;
- call.flags = htons(0x8000); /* We need an broadcast answer */
+ call.secs = 0;
+ call.flags = htons(0x8000); /* We need an broadcast answer */
- error = bootpc_call(&call,&reply,procp);
+ error = bootpc_call(&call,&reply,procp);
- if (error) {
+ if (!error)
+ break;
+
printf("BOOTP call failed -- error %d", error);
- return;
+
+ if (!forever) {
+ soclose(so);
+ return false;
+ }
}
/*
@@ -1200,4 +1208,6 @@ bootpc_init(int update_files)
error = bootpc_adjust_interface(&ireq,so,
&myaddr,&dhcp_netmask,&dhcp_gw,procp);
soclose(so);
+
+ return true;
}