diff --git a/reactos/base/services/dhcp/adapter.c b/reactos/base/services/dhcp/adapter.c index f6ee86bd018..c81cc97afba 100644 --- a/reactos/base/services/dhcp/adapter.c +++ b/reactos/base/services/dhcp/adapter.c @@ -258,6 +258,12 @@ void AdapterInit() { Adapter->IfMib.dwPhysAddrLen); Adapter->DhclientInfo.hw_address.hlen = Adapter->IfMib.dwPhysAddrLen; + /* I'm not sure where else to set this, but + some DHCP servers won't take a zero. + We checked the hardware type earlier in + the if statement. */ + Adapter->DhclientInfo.hw_address.htype = + HTYPE_ETHER; if( DhcpSocket == INVALID_SOCKET ) { DhcpSocket = diff --git a/reactos/base/services/dhcp/dhclient.c b/reactos/base/services/dhcp/dhclient.c index 2d607d29885..2e41dd42d61 100644 --- a/reactos/base/services/dhcp/dhclient.c +++ b/reactos/base/services/dhcp/dhclient.c @@ -114,6 +114,13 @@ int check_arp( struct interface_info *ip, struct client_lease *lp ) time_t scripttime; +/* XXX Added this since it's not in the NDK ;0/ */ +ULONG +NTAPI +RtlRandom( + IN OUT PULONG Seed + ); + /* XXX Implement me */ int check_arp( struct interface_info *ip, struct client_lease *lp ) { return 1; @@ -221,6 +228,7 @@ void state_reboot(void *ipp) { struct interface_info *ip = ipp; + ULONG foo = (ULONG) GetTickCount(); /* If we don't remember an active lease, go straight to INIT. */ if (!ip->client->active || ip->client->active->is_bootp) { @@ -234,7 +242,7 @@ state_reboot(void *ipp) /* make_request doesn't initialize xid because it normally comes from the DHCPDISCOVER, but we haven't sent a DHCPDISCOVER, so pick an xid now. */ - ip->client->xid = rand(); + ip->client->xid = RtlRandom(&foo); /* Make a DHCPREQUEST packet, and set appropriate per-interface flags. */ @@ -1229,6 +1237,7 @@ make_discover(struct interface_info *ip, struct client_lease *lease) struct tree_cache *options[256]; struct tree_cache option_elements[256]; int i; + ULONG foo = (ULONG) GetTickCount(); memset(option_elements, 0, sizeof(option_elements)); memset(options, 0, sizeof(options)); @@ -1287,7 +1296,7 @@ make_discover(struct interface_info *ip, struct client_lease *lease) ip->client->packet.htype = ip->hw_address.htype; ip->client->packet.hlen = ip->hw_address.hlen; ip->client->packet.hops = 0; - ip->client->packet.xid = rand(); + ip->client->packet.xid = RtlRandom(&foo); ip->client->packet.secs = 0; /* filled in by send_discover. */ ip->client->packet.flags = 0; @@ -1996,11 +2005,11 @@ ipv4addrs(char * buf) struct in_addr jnk; int i = 0; - note("Input: %s\n", buf); + note("Input: %s", buf); do { tmp = strtok(buf, " "); - note("got %s\n", tmp); + note("got %s", tmp); if( tmp && inet_aton(tmp, &jnk) ) i++; buf = NULL; } while( tmp ); diff --git a/reactos/base/services/dhcp/util.c b/reactos/base/services/dhcp/util.c index ee1cdb78b84..4ba256eb05f 100644 --- a/reactos/base/services/dhcp/util.c +++ b/reactos/base/services/dhcp/util.c @@ -4,6 +4,8 @@ #define NDEBUG #include +extern struct interface_info *ifi; + char *piaddr( struct iaddr addr ) { struct sockaddr_in sa; memcpy(&sa.sin_addr,addr.iabuf,sizeof(sa.sin_addr)); @@ -95,7 +97,33 @@ int addr_eq( struct iaddr a, struct iaddr b ) { void *dmalloc( int size, char *name ) { return malloc( size ); } int read_client_conf(void) { - error("util.c read_client_conf not implemented!"); + /* What a strage dance */ + struct client_config *config = ifi->client->config; + char ComputerName [MAX_COMPUTERNAME_LENGTH + 1]; + DWORD ComputerNameSize = sizeof ComputerName / sizeof ComputerName[0]; + + GetComputerName(ComputerName, & ComputerNameSize); + /* This never gets freed since it's only called once */ + LPSTR lpCompName = + HeapAlloc(GetProcessHeap(), 0, strlen(ComputerName) + 1); + if (lpCompName !=NULL) { + GetComputerName(lpCompName, & ComputerNameSize); + /* Send our hostname, some dhcpds use this to update DNS */ + config->send_options[DHO_HOST_NAME].data = strlwr(lpCompName); + config->send_options[DHO_HOST_NAME].len = strlen(ComputerName); + debug("Hostname: %s, length: %d", + config->send_options[DHO_HOST_NAME].data, + config->send_options[DHO_HOST_NAME].len); + } else { + error("Failed to allocate heap for hostname"); + } + /* Both Linux and Windows send this */ + config->send_options[DHO_DHCP_CLIENT_IDENTIFIER].data = + ifi->hw_address.haddr; + config->send_options[DHO_DHCP_CLIENT_IDENTIFIER].len = + ifi->hw_address.hlen; + + warn("util.c read_client_conf poorly implemented!"); return 0; }