]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix arp checking
authorRoy Marples <roy@marples.name>
Thu, 21 Dec 2006 16:51:16 +0000 (16:51 +0000)
committerRoy Marples <roy@marples.name>
Thu, 21 Dec 2006 16:51:16 +0000 (16:51 +0000)
linux-2.6.19 headers NOW don't work with c99 which is just wrong, so
dhcpcd no longer builds against these kernel headers. You get a nice
error though :)

ChangeLog
Makefile
arp.c
client.c
dhcp.c
interface.c

index 395be866b7094d49f40461b78dfdffa77fab2da1..12ddbe436f667c2feef241b4944d89be94a55225 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fix arp checking
+linux-2.6.19 headers NOW don't work with c99 which is just wrong, so
+dhcpcd no longer builds against these kernel headers. You get a nice
+error though :)
+
 dhcpcd-3.0.7
 Allow Linux to use Token Ring again as Linux does not have any more hardware
 specific code. BPF needs a patch for Token Ring support.
index 761fd93e019d4903536f198124591d7495910841..18a3578e5e04d73c30b1dcf58407b9902492d29e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Should work for both GNU make and BSD make
 
-VERSION = 3.0.7
+VERSION = 3.0.8_pre1
 
 INSTALL ?= install
 
diff --git a/arp.c b/arp.c
index c895fa549126aae5c73a6a0997ea3163edafca44..33463052f99b0636380261fe4e578231c6d21103 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -121,16 +121,20 @@ int arp_check (interface_t *iface, struct in_addr address)
        {
          union
          {
-           unsigned char buffer[sizeof (struct arphdr)];
+           unsigned char buffer[buflen];
            struct arphdr hdr;
          } reply;
          union
          {
            unsigned char *c;
-           struct in_addr a;
-         } ra;
-
-         memset (reply.buffer, 0, sizeof (struct arphdr));
+           struct in_addr *a;
+         } rp;
+         union
+         {
+           unsigned char *c;
+           struct ether_addr *a;
+         } rh;
+         memset (reply.buffer, 0, sizeof (reply.buffer));
          if ((bytes = get_packet (iface, reply.buffer, arp.buffer,
                                   &buflen, &bufpos)) < 0)
            break;
@@ -151,10 +155,10 @@ int arp_check (interface_t *iface, struct in_addr address)
          if ((unsigned) bytes < sizeof (reply.hdr) + 2 * (4 + reply.hdr.ar_hln))
            continue;
 
-         ra.c = (unsigned char *) ar_spa (&reply.hdr);
+         rp.c = (unsigned char *) ar_spa (&reply.hdr);
+         rh.c = (unsigned char *) ar_sha (&reply.hdr);
          logger (LOG_ERR, "ARPOP_REPLY received from %s (%s)",
-                 inet_ntoa (ra.a),
-                 ether_ntoa ((struct ether_addr *) ar_sha (&reply.hdr)));
+                 inet_ntoa (*rp.a), ether_ntoa (rh.a));
          close (iface->fd);
          iface->fd = -1;
          return 1;
index 3d1e8763035afaf366cea942c226c9bf323b7691..0116f84de93ce798abf74ae96874b91d2cecf4a7 100644 (file)
--- a/client.c
+++ b/client.c
@@ -464,15 +464,19 @@ int dhcp_run (const options_t *options)
                          SOCKET_MODE (SOCKET_OPEN);
                          SEND_MESSAGE (DHCP_DECLINE);
                          SOCKET_MODE (SOCKET_CLOSED);
+
                          free_dhcp (dhcp);
-                         memset (dhcp, 0, sizeof (dhcp));
+                         memset (dhcp, 0, sizeof (dhcp_t));
                          if (daemonised)
                            configure (options, iface, dhcp);
 
                          xid = 0;
+                         timeout = 0;
                          state = STATE_INIT;
                          /* RFC 2131 says that we should wait for 10 seconds
                             before doing anything else */
+                         logger (LOG_INFO, "sleeping for 10 seconds");
                          sleep (10);
                          continue;
                        }
diff --git a/dhcp.c b/dhcp.c
index 7f5cd0ee2cbeaf11edcca9dd5431b287a3302a58..85427ac70826d4fe9356b6098c4b4d1a7d949aa8 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -253,7 +253,7 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
   make_dhcp_packet (&packet, (unsigned char *) &message, message_length,
                    from, to);
 
-  logger (LOG_DEBUG, "Sending %s with xid %d", dhcp_message[(int) type], xid);
+  logger (LOG_DEBUG, "sending %s with xid %d", dhcp_message[(int) type], xid);
   return send_packet (iface, ETHERTYPE_IP, (unsigned char *) &packet,
                      message_length + sizeof (struct ip) +
                      sizeof (struct udphdr));
@@ -409,7 +409,7 @@ static route_t *decodeCSR(unsigned char *p, int len)
 
 void free_dhcp (dhcp_t *dhcp)
 {
-  if (!dhcp)
+  if (! dhcp)
     return;
 
   if (dhcp->routes)
index 0bc6e56e3b1a60cdb060e29333394d5c26161875..d69a857beadb8e7e49144e52c439292b22af6c18 100644 (file)
 
 #include <arpa/inet.h>
 
-/* Netlink suff */
+/* Check linux version before including headers which break us */
 #ifdef __linux__ 
-#include <asm/types.h> /* Needed for 2.4 kernels */
 #include <features.h>
 #include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION (2,6,19)
-#include <linux/if_addr.h>
+#if LINUX_VERSION_CODE == KERNEL_VERSION (2,6,19)
+#error "linux 2.6.19 headers are so badly broken, use something else"
 #endif
+#endif
+
+/* Netlink suff */
+#ifdef __linux__
+#include <asm/types.h> /* Needed for 2.4 kernels */
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 #include <netinet/ether.h>