Subject: Re: How to set up NetBSD client of bootp
To: David Brownlee <D.K.Brownlee@city.ac.uk>
From: John C. Hayward <johnh@david.wheaton.edu>
List: current-users
Date: 08/10/1995 22:35:51
In response to my query for bootp client.
On Wed, 9 Aug 1995, David Brownlee wrote:

> 	There was a bootp client for linux around somewhere - someone
> 	here is supposed to be looking at getting it running on our
> 	Solaris 2 boxes by october - if you cant find a copy on a linux
> 	archive bounce me a mail & I'll rattle their cage & find out where
> 	they got it.
> 
> 		abs
In looking around there seems to be a client for linux called bootpc.  I 
found it via archie.

I started to port it to NetBSD and have run into (at least) three problems.

1) Aparently linux has a ioctl which allows you to ask the hardware address
   associated with a socket:
   ===
   /* Get the hardware address */
    memcpy(ifr.ifr_name, device, strlen(device)+1);
    if(ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0) {
      perror("bootpc: ioctl failed");
      FatalError();
    }   
====
   I assume there is a way to get the eithernet address of a socket with 
NetBSD but could not find out how.  Since I figured there would be people
on the list who knew how to do this I hardcoded the eithernet address
and tested it out.  
   If the interface was up and configured to the correct IP address then 
running (and I ran as root) bootpc worked as it should.

   Next I looked at the bootp.rc file provided and it had:
===
DEV=eth0
/sbin/ifconfig ${DEV} up
/sbin/route add default dev ${DEV}
eval `/sbin/bootpc --dev ${DEV}`
/sbin/ifconfig ${DEV} down
===
   The ifconfig ed0 up worked fine.  Then came problem #2:

2) Linux can add a route with a destination being a device rather than 
   address.  I looked and tried various things with the NetBSD route command
   attempting to establish the default route to go out ed0 but it appears
   there is no facility to specify an interface rather than IP address.
   There seem to be some flags which indicate an interface but I kept 
   getting ed0: bad value.  This is with the interface up but no inet
   address.

   Next I tried to give an unused address with ifconfig and the boop server
   could see the query and sent a response.  In fact the correct IP then
   showed up in the routing tables but nothing was sent to bootpc.  This
   is problem #3 which is similar to what Toby Weingart reported:
#3:
====
is not up and working yet.  Also, the TCP/IP stack seems to drop
packets that are not for it.

I don't know what I will need to do with the interface, to be able
to do a sendto(IN_BROADCAST_ADDR) on it, and rcvfrom(IN_ADD_ANY) on it.
If someone has code to get the virgin interface into a state that will
====

In summary questions are:
1) How does one get the hardware eithernet address of an opened socket?
2) How does one get the default route associated with an interface without
   configuring the interface with an IP number?
3) How does one get the bootp reply without having the interface 
   configured with the actual IP you are getting from bootp server?

Several of us would appreciate comments on how to get past these 
problems.

johnh...