diff -Naur dhcpcd-1.3.22-pl4/buildmsg.c dhcpcd-1.3.22-pl4.new/buildmsg.c --- dhcpcd-1.3.22-pl4/buildmsg.c Tue Dec 31 00:15:07 2002 +++ dhcpcd-1.3.22-pl4.new/buildmsg.c Sat Apr 19 11:22:20 2003 @@ -42,6 +42,8 @@ extern unsigned nleaseTime; extern int BroadcastResp; extern struct in_addr inform_ipaddr; +extern int ServerPort; +extern int ClientPort; /*****************************************************************************/ void buildDhcpDiscover(xid) @@ -124,7 +126,7 @@ /* build UDP/IP header */ udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST, - htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage)); + htons(ClientPort),htons(ServerPort),sizeof(dhcpMessage)); } /*****************************************************************************/ void buildDhcpRequest(xid) @@ -211,7 +213,7 @@ /* build UDP/IP header */ udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST, - htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage)); + htons(ClientPort),htons(ServerPort),sizeof(dhcpMessage)); } /*****************************************************************************/ void buildDhcpRenew(xid) @@ -286,7 +288,7 @@ udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg, DhcpIface.ciaddr,DhcpIface.siaddr, - htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage)); + htons(ClientPort),htons(ServerPort),sizeof(dhcpMessage)); } /*****************************************************************************/ void buildDhcpRebind(xid) @@ -359,7 +361,7 @@ udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg, DhcpIface.ciaddr,INADDR_BROADCAST, - htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage)); + htons(ClientPort),htons(ServerPort),sizeof(dhcpMessage)); } /*****************************************************************************/ void buildDhcpReboot(xid) @@ -439,7 +441,7 @@ *p = endOption; udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST, - htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage)); + htons(ClientPort),htons(ServerPort),sizeof(dhcpMessage)); } /*****************************************************************************/ void buildDhcpRelease(xid) @@ -474,7 +476,7 @@ *p = endOption; udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,DhcpIface.ciaddr, - DhcpIface.siaddr,htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT), + DhcpIface.siaddr,htons(ClientPort),htons(ServerPort), sizeof(dhcpMessage)); } /*****************************************************************************/ @@ -519,7 +521,7 @@ *p = endOption; udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0, - DhcpIface.siaddr,htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT), + DhcpIface.siaddr,htons(ClientPort),htons(ServerPort), sizeof(dhcpMessage)); } #endif @@ -587,5 +589,5 @@ *p = endOption; udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST, - htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage)); + htons(ClientPort),htons(ServerPort),sizeof(dhcpMessage)); } diff -Naur dhcpcd-1.3.22-pl4/client.c dhcpcd-1.3.22-pl4.new/client.c --- dhcpcd-1.3.22-pl4/client.c Tue Dec 31 20:24:37 2002 +++ dhcpcd-1.3.22-pl4.new/client.c Sat Apr 19 11:22:53 2003 @@ -73,6 +73,8 @@ extern int resolv_renamed,yp_renamed,ntp_renamed; extern int InitialHostName_len,InitialDomainName_len; extern char *InitialHostName,*InitialDomainName; +extern int ServerPort; +extern int ClientPort; #if 0 extern unsigned char ClientMACaddr[ETH_ALEN]; @@ -1161,7 +1163,7 @@ UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP); buildDhcpDecline(random()); udpipgen((udpiphdr *)&UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST, - htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage)); + htons(ClientPort),htons(ServerPort),sizeof(dhcpMessage)); memset(&addr,0,sizeof(struct sockaddr)); memcpy(addr.sa_data,IfName,IfName_len); if ( DebugFlag ) syslog(LOG_DEBUG,"broadcasting DHCP_DECLINE\n"); diff -Naur dhcpcd-1.3.22-pl4/dhcpcd.8 dhcpcd-1.3.22-pl4.new/dhcpcd.8 --- dhcpcd-1.3.22-pl4/dhcpcd.8 Tue Dec 31 20:31:31 2002 +++ dhcpcd-1.3.22-pl4.new/dhcpcd.8 Sat Apr 19 11:31:35 2003 @@ -16,6 +16,7 @@ \%[-i\ ] \%[-I\ ] \%[\-l\ ] +\%[\-p\ ] \%[\-s\ [ipaddr]] \%[\-G\ [gateway]] \%[\-w\ ] @@ -247,6 +248,11 @@ .B DHCP_DISCOVER message. The default is infinite (0xffffffff). .TP +.BI \-p \ +Specifies the UDP Port that the server is listening on for dhcp requests. +The UDP port that the client listens to is 1 higher than the server port. +The defaults are 67 and 68 for the server and client ports respectively. +.TP .BI \-s \ [ipaddr] Sends DHCP_INFORM message to DHCP server using ipaddr. The optional ipaddr parameter must be in diff -Naur dhcpcd-1.3.22-pl4/dhcpcd.c dhcpcd-1.3.22-pl4.new/dhcpcd.c --- dhcpcd-1.3.22-pl4/dhcpcd.c Tue Dec 31 20:26:32 2002 +++ dhcpcd-1.3.22-pl4.new/dhcpcd.c Sat Apr 19 11:24:19 2003 @@ -61,6 +61,8 @@ int SetHostName = 0; int BroadcastResp = 0; time_t TimeOut = DEFAULT_TIMEOUT; +int ServerPort = DHCP_SERVER_PORT; +int ClientPort = DHCP_CLIENT_PORT; int magic_cookie = 0; unsigned short dhcpMsgSize = 0; unsigned nleaseTime = 0; @@ -257,6 +259,18 @@ fprintf(stderr,"**** %s: too long HostName string: strlen=%d\n", argc[0],HostName_len); break; + case 'p': + if ( argc[i][s+1] ) goto usage; + i++; + if ( argc[i] ){ + ServerPort=atoi(argc[i++]); + ClientPort=ServerPort+1; + } + else + goto usage; + s=1; + if ( ServerPort > 0 ) break; + goto usage; case 't': if ( argc[i][s+1] ) goto usage; i++; @@ -327,7 +341,8 @@ fprintf(stderr, "Usage: dhcpcd [-dknrBCDHNRSTY] [-l leasetime] [-h hostname] [-t timeout]\n\ [-i vendorClassID] [-I ClientID] [-c filename] [-s [ipaddr]]\n\ - [-w windowsize] [-L ConfigDir] [-G [gateway]] [interface]\n"); + [-p serverport ] [-w windowsize] [-L ConfigDir]\n\ + [-G [gateway]] [interface]\n"); exit(1); } else