Hi, Here is a patch to make pfinet use 0.0.0.0 as IP address and make broadcasting possible when pfinet is started with `--dhcp'. Perhaps it would be nice to include this in the Hurd, or just in Debian if it is too much of a hack. I don't want to put too much time in it if it is completely wrong. In that case, just use it when you don't care about such things.
Alfred promised me to make the dhcp client itself work. I have some hacked stuff around to start with, the only thing that really needs to be done is hacking the script to change the ip address, etc, when the DHCP server replied. Thanks, Marco 2005-01-04 Marco Gerards <[EMAIL PROTECTED]> * options.c (options): Add the option `dhcp'. (parse_opt): In case pfinet is started the argument `--dhcp', set the address to `0.0.0.0', the netmask to `255.0.0.0' and add the route for `0.0.0.0' so broadcasting works. * linux-src/net/ipv4/devinet.c (inet_insert_ifa) [_HURD_]: Don't fail when the address is `0.0.0.0'. Index: options.c =================================================================== RCS file: /cvsroot/hurd/hurd/pfinet/options.c,v retrieving revision 1.11 diff -u -p -r1.11 options.c --- options.c 18 Jul 2001 16:56:57 -0000 1.11 +++ options.c 4 Jan 2005 14:18:09 -0000 @@ -1,6 +1,6 @@ /* Pfinet option parsing - Copyright (C) 1996,97,2000,01 Free Software Foundation, Inc. + Copyright (C) 1996,97,2000,01,2005 Free Software Foundation, Inc. Written by Miles Bader <[EMAIL PROTECTED]> @@ -60,6 +60,7 @@ static const struct argp_option options[ {"netmask", 'm', "MASK", 0, "Set the netmask"}, {"peer", 'p', "ADDRESS", 0, "Set the peer address"}, {"gateway", 'g', "ADDRESS", 0, "Set the default gateway"}, + {"dhcp", 'd', 0 , 0, "Prepare pfinet for dhcp"}, {"shutdown", 's', 0, 0, "Shut it down"}, {0} }; @@ -111,6 +112,8 @@ parse_hook_add_interface (struct parse_h return 0; } +static int dhcp_option; + static error_t parse_opt (int opt, char *arg, struct argp_state *state) { @@ -189,6 +192,8 @@ parse_opt (int opt, char *arg, struct ar "%s: Illegal or undefined network address", arg); } break; + case 'd': + dhcp_option = 1; break; case 'm': h->curint->netmask = ADDR (arg, "netmask"); break; case 'p': @@ -213,6 +218,16 @@ parse_opt (int opt, char *arg, struct ar case ARGP_KEY_SUCCESS: in = h->curint; + + /* Configure the interface to default values. */ + if (dhcp_option) + { + h->curint->netmask = ADDR ("255.0.0.0", "netmask"); + h->curint->address = ADDR ("0.0.0.0", "address"); + h->curint->gateway = INADDR_NONE; + h->curint->peer = INADDR_NONE; + } + if (! in->device) /* No specific interface specified; is that ok? */ if (in->address != INADDR_NONE || in->netmask != INADDR_NONE @@ -315,6 +330,53 @@ parse_opt (int opt, char *arg, struct ar } } + /* Setup the routing required for DHCP. */ + if (dhcp_option) + { + struct kern_rta rta; + struct + { + struct nlmsghdr nlh; + struct rtmsg rtm; + } req; + struct fib_table *tb; + struct rtentry route; + struct sockaddr_in *dst; + struct device *dev; + + dst = (struct sockaddr_in *) &route.rt_dst; + dev = dev_get ("eth0"); + if (!dev) + { + __mutex_unlock (&global_lock); + FAIL (ENODEV, 17, 0, "unknown device"); + } + + /* Simulate the SIOCADDRT behavior. */ + bzero (&route, sizeof (struct rtentry)); + bzero (&req.rtm, sizeof req.rtm); + bzero (&rta, sizeof rta); + req.nlh.nlmsg_type = RTM_NEWROUTE; + req.nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE; + req.rtm.rtm_protocol = RTPROT_BOOT; + req.rtm.rtm_scope = RT_SCOPE_LINK; + req.rtm.rtm_type = RTN_UNICAST; + rta.rta_dst = &dst->sin_addr.s_addr; + rta.rta_oif = &dev->ifindex; + + tb = fib_new_table (req.rtm.rtm_table); + if (tb) + err = tb->tb_insert (tb, &req.rtm, &rta, &req.nlh, NULL); + else + err = ENOBUFS; + + if (err) + { + __mutex_unlock (&global_lock); + FAIL (err, 17, 0, "cannot add route"); + } + } + __mutex_unlock (&global_lock); /* Fall through to free hook. */ Index: linux-src/net/ipv4/devinet.c =================================================================== RCS file: /cvsroot/hurd/hurd/pfinet/linux-src/net/ipv4/devinet.c,v retrieving revision 1.8 diff -u -p -r1.8 devinet.c --- linux-src/net/ipv4/devinet.c 18 Jul 2001 17:37:13 -0000 1.8 +++ linux-src/net/ipv4/devinet.c 4 Jan 2005 14:18:11 -0000 @@ -214,10 +214,12 @@ inet_insert_ifa(struct in_device *in_dev { struct in_ifaddr *ifa1, **ifap, **last_primary; +#ifndef _HURD_ if (ifa->ifa_local == 0) { inet_free_ifa(ifa); return 0; } +#endif ifa->ifa_flags &= ~IFA_F_SECONDARY; last_primary = &in_dev->ifa_list; _______________________________________________ Bug-hurd mailing list Bug-hurd@gnu.org http://lists.gnu.org/mailman/listinfo/bug-hurd