--- ./Makefile.orig Tue Sep 2 07:00:24 1997 +++ ./Makefile Sun Sep 6 19:47:47 1998 @@ -1,5 +1,7 @@ # $Id: Makefile,v 0.3 1997/01/31 16:48:47 yoichi v0_5 yoichi $ +CC= gcc + TARGET= dhcpcd BINDIR= /usr/sbin SRCS= main.c if.c client.c options.c socket-if.c arp.c error-handler.c \ @@ -9,7 +11,7 @@ TARDIRS= pcmcia rc.d #CFLAGS= -g -Wall -DNEED_BCAST_RESPONSE -CFLAGS= -g -Wall +CFLAGS= -O2 -g -Wall $(TARGET): $(OBJS) $(CC) -o $(TARGET) $(LFLAGS) $(OBJS) --- ./client.c.orig Tue Sep 2 07:00:24 1997 +++ ./client.c Sun Sep 6 19:47:47 1998 @@ -744,8 +744,12 @@ case DHCP_NAK: return INIT; case DHCP_ACK: - ServerInaddr = *((u_long *)(optp[OserverInaddr]+1)); - LeaseTime = *((u_long *)(optp[OleaseTime]+1)); + ServerInaddr = 0; + if (optp[OserverInaddr]) + ServerInaddr = *((u_long *)(optp[OserverInaddr]+1)); + LeaseTime = 0; + if (optp[OleaseTime]) + LeaseTime = *((u_long *)(optp[OleaseTime]+1)); if ( optp[OrenewalTime] == NULL ) { RenewTime = htonl(ntohl(LeaseTime) / 2); /* default T1 time */ } else { --- ./hostinfo.c.orig Tue Sep 2 07:00:24 1997 +++ ./hostinfo.c Sun Sep 6 19:47:47 1998 @@ -117,7 +117,30 @@ } /* resolv.conf */ - if ( optp[Odns] != NULL && optp[OdomainName] != NULL ) { + { + char buf[MAXLEN]; + const u_char *addr = optp[Odns]; + const u_char *domName = optp[OdomainName]; + u_int *p; int i; + if ( domName ) { + strcpy(buf, "domain name: "); + strncat(buf, domName+1, *domName); + strcat(buf, "\n"); + logRet(buf); + } + if ( addr ) { + strcpy(buf, "name servers: "); + p = (u_int *)(addr + 1); + for ( i = 0; i < *addr/4; ++i ) { + strncat(buf, inet_ntoa(*((struct in_addr *)p)), + MAXLEN - strlen(buf)); + ++p; + } + strcat(buf, "\n"); + logRet(buf); + } + } + if ( optp[Odns] != NULL || optp[OdomainName] != NULL ) { mkResolvConf(optp[Odns], optp[OdomainName]); } /* hostinfo file @@ -298,14 +321,19 @@ } /* TODO: check whether name server is working on those addresses */ - strcpy(buf, "domain "); - strncat(buf, domName+1, *domName); - strcat(buf, "\n"); - p = (u_int *)(addr + 1); - for ( i = 0; i < *addr/4; ++i ) { - sprintf(buf+strlen(buf), "nameserver %s\n", - inet_ntoa(*((struct in_addr *)p))); - ++p; + buf[0] = '\0'; + if (domName) { + strcpy(buf, "domain "); + strncat(buf, domName+1, *domName); + strcat(buf, "\n"); + } + if (addr) { + p = (u_int *)(addr + 1); + for ( i = 0; i < *addr/4; ++i ) { + sprintf(buf+strlen(buf), "nameserver %s\n", + inet_ntoa(*((struct in_addr *)p))); + ++p; + } } if ( write(fd, buf, strlen(buf)) < 0 ) { logSysRet("write (mkResolvConf)"); --- ./if.c.orig Sun Sep 6 19:48:24 1998 +++ ./if.c Sun Sep 6 19:49:56 1998 @@ -107,6 +107,9 @@ p = (struct sockaddr_in *)&rtent.rt_gateway; p->sin_family = AF_INET; p->sin_addr.s_addr = ifinfo->addr; /* gateway address */ + p = (struct sockaddr_in *)&rtent.rt_genmask; + p->sin_family = AF_INET; + p->sin_addr.s_addr = ifinfo->mask; rtent.rt_dev = ifinfo->ifname; /* interface name */ rtent.rt_metric = 1; /* metric (see route.h) */ rtent.rt_flags = RTF_UP; /* net route */