[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Dhcpcd 1.3.16 patch



Hi all,

I've finaly managed to get a working dhcpcd 1.3.16 on 2.1.122 with the
following patch. Be warned it is NOT fully tested (although it works
nicely for me). I've not looked at any thing else than dhcpcd, so make
will fail just after dhcpcd is build.

Changes are fairly trivials, mostly corrections of some creative
casting... ;-).

Any feedback would be apreciated.

	Marc.

diff -ruN old/dhcpcd-1.3.16/Makefile dhcpcd-1.3.16/Makefile
--- old/dhcpcd-1.3.16/Makefile	Sun Nov  8 02:51:49 1998
+++ dhcpcd-1.3.16/Makefile	Mon Nov 23 23:05:07 1998
@@ -21,11 +21,14 @@
 ###########################
 
 OSNAME=$(shell uname)
+ARCH=$(shell uname -m)
 
 ifeq ($(OSNAME),Linux)
 CC = gcc
-CFLAGS = -O2 $(ADDS) -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 \
--malign-functions=2 -Wall $(DEFS)
+CFLAGS = -O2 $(ADDS) -fomit-frame-pointer -Wall $(DEFS)
+ifeq ($(ARCH),i386)
+CFLAGS+= -malign-loops=2 -malign-jumps=2 -malign-functions=2
+endif
 LDFLAGS = -s -O2 -static
 INCLUDES = -I.
 else
diff -ruN old/dhcpcd-1.3.16/client.c dhcpcd-1.3.16/client.c
--- old/dhcpcd-1.3.16/client.c	Tue Nov 10 04:34:43 1998
+++ dhcpcd-1.3.16/client.c	Tue Nov 24 08:05:51 1998
@@ -655,7 +655,7 @@
   unlink(cache_file);
 }
 /*****************************************************************************/
-int dhcpStart()
+FUNC dhcpStart()
 {
   int o = 1;
   struct ifreq	ifr;
@@ -689,10 +689,10 @@
       exit(1);
     }
   memcpy(ClientHwAddr,ifr.ifr_hwaddr.sa_data,ETHER_ADDR_LEN);
-  return (int)&dhcpInit;
+  return (FUNC) &dhcpInit;
 }
 /*****************************************************************************/
-int dhcpReboot()
+FUNC dhcpReboot(void)
 {
   dhcpStart();
   ip_id=time(NULL)&0xffff;
@@ -715,7 +715,7 @@
   return dhcpRequest(&buildDhcpReboot);
 }
 /*****************************************************************************/
-int dhcpInit()
+FUNC dhcpInit()
 {
   releaseDhcpOptions();
 
@@ -761,7 +761,7 @@
   return dhcpRequest(&buildDhcpRequest);
 }
 /*****************************************************************************/
-int dhcpRequest(buildDhcpMsg)
+FUNC dhcpRequest(buildDhcpMsg)
 void (*buildDhcpMsg)(unsigned);
 {
 /* send the message and read and parse replies into DhcpOptions */
@@ -840,20 +840,20 @@
 	}
       prev_ip_addr=DhcpIface.client_iaddr;
     }
-  return (int )&dhcpBound;
+  return (FUNC) &dhcpBound;
 }
 /*****************************************************************************/
-int dhcpBound()
+FUNC dhcpBound()
 {
-  if ( sigsetjmp(env,0xffff) ) return (int)&dhcpRenew;
+  if ( sigsetjmp(env,0xffff) ) return (FUNC) &dhcpRenew;
   alarm(ReqSentTime+ntohl(*(unsigned int *)DhcpOptions.val[dhcpT1value])-time(NULL));
   sleep(ntohl(*(u_int *)DhcpOptions.val[dhcpT1value]));
-  return (int)&dhcpRenew;
+  return (FUNC) &dhcpRenew;
 }
 /*****************************************************************************/
-int dhcpRenew()
+FUNC dhcpRenew()
 {
-  if ( sigsetjmp(env,0xffff) ) return (int)&dhcpRebind;
+  if ( sigsetjmp(env,0xffff) ) return (FUNC) &dhcpRebind;
   alarm(ReqSentTime+ntohl(*(unsigned int *)DhcpOptions.val[dhcpT2value])-time(NULL));
   if ( DebugFlag )
     syslog(LOG_DEBUG,"sending DHCP_REQUEST for %u.%u.%u.%u to %u.%u.%u.%u\n",
@@ -875,7 +875,7 @@
       	else
 	  syslog(LOG_ERR,"dhcpRenew: DHCP_NAK server response received\n");
       default:
-        return (int)&dhcpRebind;
+        return (FUNC) &dhcpRebind;
     }
   ReqSentTime=time(NULL);
   if ( DebugFlag ) syslog(LOG_DEBUG,
@@ -884,12 +884,12 @@
     ((unsigned char *)DhcpOptions.val[dhcpServerIdentifier])[1],
     ((unsigned char *)DhcpOptions.val[dhcpServerIdentifier])[2],
     ((unsigned char *)DhcpOptions.val[dhcpServerIdentifier])[3]);
-  return (int)&dhcpBound;
+  return (FUNC) &dhcpBound;
 }
 /*****************************************************************************/
-int dhcpRebind()
+FUNC dhcpRebind()
 {
-  if ( sigsetjmp(env,0xffff) ) return (int)&dhcpStop;
+  if ( sigsetjmp(env,0xffff) ) return (FUNC) &dhcpStop;
   alarm(ReqSentTime+ntohl(*(unsigned int *)DhcpOptions.val[dhcpIPaddrLeaseTime])-time(NULL));
 
   if ( DebugFlag )
@@ -908,7 +908,7 @@
       	else
 	  syslog(LOG_ERR,"dhcpRebind: DHCP_NAK server response received\n");
       default:
-        return (int)&dhcpStop;
+        return (FUNC) &dhcpStop;
     }
   ReqSentTime=time(NULL);
   if ( DebugFlag ) syslog(LOG_DEBUG,
@@ -917,14 +917,14 @@
     ((unsigned char *)DhcpOptions.val[dhcpServerIdentifier])[1],
     ((unsigned char *)DhcpOptions.val[dhcpServerIdentifier])[2],
     ((unsigned char *)DhcpOptions.val[dhcpServerIdentifier])[3]);
-  return (int)&dhcpBound;
+  return (FUNC) &dhcpBound;
 }
 /*****************************************************************************/
-int dhcpRelease()
+FUNC dhcpRelease()
 {
   struct sockaddr addr;
   deleteDhcpCache();
-  if ( DhcpIface.client_iaddr == 0 ) return (int)&dhcpInit;
+  if ( DhcpIface.client_iaddr == 0 ) return (FUNC) &dhcpInit;
 
   buildDhcpRelease(random());
 
@@ -945,10 +945,10 @@
 	      &addr,sizeof(struct sockaddr)) == -1 )
     syslog(LOG_ERR,"dhcpRelease: sendto: %m\n");
   arpRelease(); /* clear ARP cache entries for client IP addr */
-  return (int)&dhcpInit;
+  return (FUNC) &dhcpInit;
 }
 /*****************************************************************************/
-int dhcpStop()
+FUNC dhcpStop()
 {
   int s;
   struct ifreq ifr;
@@ -973,11 +973,11 @@
     syslog(LOG_ERR,"dhcpStop: ioctl SIOCSIFFLAGS: %m\n");
   close(s);
   rename(""RESOLV_CONF".sv",RESOLV_CONF);
-  return (int)&dhcpStart;
+  return (FUNC) &dhcpStart;
 }
 /*****************************************************************************/
 #ifdef ARPCHECK
-int dhcpDecline()
+FUNC dhcpDecline()
 {
   struct sockaddr addr;
   memset(&UdpIpMsg,0,sizeof(udpipMessage));
@@ -994,7 +994,7 @@
 	      sizeof(udpiphdr)+sizeof(dhcpMessage),0,
 	      &addr,sizeof(struct sockaddr)) == -1 )
     syslog(LOG_ERR,"dhcpDecline: sendto: %m\n");
-  return (int)&dhcpInit;
+  return (FUNC) &dhcpInit;
 }
 #endif
 /*****************************************************************************/
diff -ruN old/dhcpcd-1.3.16/client.h dhcpcd-1.3.16/client.h
--- old/dhcpcd-1.3.16/client.h	Sun Nov  8 01:32:43 1998
+++ dhcpcd-1.3.16/client.h	Tue Nov 24 08:05:41 1998
@@ -166,19 +166,21 @@
   void   *val[256];
 } dhcpOptions;
 
+typedef void* FUNC;
+
 int peekfd(int s,int tv_usec);
-int dhcpReboot();
-int dhcpStart();
-int dhcpInit();
-int dhcpRequest(void (*buildDhcpMsg)(unsigned));
-int dhcpBound();
-int dhcpRenew();
-int dhcpRebind();
-int dhcpRelease();
-int dhcpStop();
+FUNC dhcpReboot();
+FUNC dhcpStart();
+FUNC dhcpInit();
+FUNC dhcpRequest(void (*buildDhcpMsg)(unsigned));
+FUNC dhcpBound();
+FUNC dhcpRenew();
+FUNC dhcpRebind();
+FUNC dhcpRelease();
+FUNC dhcpStop();
 void checkIfAlreadyRunning();
 #ifdef ARPCHECK
-int dhcpDecline();
+FUNC dhcpDecline();
 #endif
 
 #endif
diff -ruN old/dhcpcd-1.3.16/dhcpcd.c dhcpcd-1.3.16/dhcpcd.c
--- old/dhcpcd-1.3.16/dhcpcd.c	Sun Nov  8 03:07:43 1998
+++ dhcpcd-1.3.16/dhcpcd.c	Mon Nov 23 23:05:07 1998
@@ -37,7 +37,7 @@
 char		*Cfilename	=	NULL;
 unsigned char	*ClassID	=	NULL;
 unsigned char	*ClientID	=	NULL;
-int		(*currState)()  =	NULL;
+FUNC		(*currState)()  =	NULL;
 int		DebugFlag	=	0;
 int		BeRFC1541	=	0;
 int		LeaseTime	=	DEFAULT_LEASETIME;
@@ -172,7 +172,7 @@
   openlog(PROGRAM_NAME,LOG_PID,LOG_LOCAL0);
   signalSetup();
   alarm(TimeOut);
-  currState=(int (*)())dhcpReboot();
+  currState=(FUNC (*)())dhcpReboot();
   alarm(0);
   if ( currState == NULL ) exit(1);
 #ifndef DEBUG
@@ -180,7 +180,7 @@
 #endif
   chdir("/");
   writePidFile();
-  do currState=(int (*)())currState(); while ( currState );
+  do currState=(FUNC (*)())currState(); while ( currState );
   deletePidFile();
   exit(1);
 }
diff -ruN old/dhcpcd-1.3.16/udpipgen.h dhcpcd-1.3.16/udpipgen.h
--- old/dhcpcd-1.3.16/udpipgen.h	Mon Oct 19 05:17:23 1998
+++ dhcpcd-1.3.16/udpipgen.h	Mon Nov 23 23:05:07 1998
@@ -26,7 +26,7 @@
 
 struct ipovly
 {
-  caddr_t ih_next,ih_prev;
+  int ih_next,ih_prev;
   u_char ih_x1;
   u_char ih_pr;
   u_short ih_len;

-- 
Quench my thirst with gasoline. [m]


Reply to: