aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-03-05 14:25:49 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2004-03-05 14:25:49 +0000
commit8b39405d9700091c62409f9a1f84f6ac4d1bd5fb (patch)
tree2d868bbb6059ee64dbf5cd6af9879a33c31562f8
parent90012582cb00c9158a0028bb34a8a49665f489cd (diff)
downloadbusybox-w32-8b39405d9700091c62409f9a1f84f6ac4d1bd5fb.tar.gz
busybox-w32-8b39405d9700091c62409f9a1f84f6ac4d1bd5fb.tar.bz2
busybox-w32-8b39405d9700091c62409f9a1f84f6ac4d1bd5fb.zip
Patch by Andrew Victor,
In arpping.h, fix structure alignment of "struct arpMsg". GCC can insert padding in the structure which causes udhcpd to send an invalid ARP packet on the network. It will then not receive a valid reply, which can cause it to assign an IP address that's already in use on the network. (With kernels before 2.4.20, the "struct ethhdr" in linux/if_ether.h wasn't marked as packed. This is also an issue if your toolchain was built with a pre-2.4.20 kernel). git-svn-id: svn://busybox.net/trunk/busybox@8580 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--networking/udhcp/arpping.c6
-rw-r--r--networking/udhcp/arpping.h9
2 files changed, 10 insertions, 5 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index f2e3768c5..23c7d46b3 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -60,9 +60,9 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
60 60
61 /* send arp request */ 61 /* send arp request */
62 memset(&arp, 0, sizeof(arp)); 62 memset(&arp, 0, sizeof(arp));
63 memcpy(arp.ethhdr.h_dest, MAC_BCAST_ADDR, 6); /* MAC DA */ 63 memcpy(arp.h_dest, MAC_BCAST_ADDR, 6); /* MAC DA */
64 memcpy(arp.ethhdr.h_source, mac, 6); /* MAC SA */ 64 memcpy(arp.h_source, mac, 6); /* MAC SA */
65 arp.ethhdr.h_proto = htons(ETH_P_ARP); /* protocol type (Ethernet) */ 65 arp.h_proto = htons(ETH_P_ARP); /* protocol type (Ethernet) */
66 arp.htype = htons(ARPHRD_ETHER); /* hardware type */ 66 arp.htype = htons(ARPHRD_ETHER); /* hardware type */
67 arp.ptype = htons(ETH_P_IP); /* protocol type (ARP message) */ 67 arp.ptype = htons(ETH_P_IP); /* protocol type (ARP message) */
68 arp.hlen = 6; /* hardware address length */ 68 arp.hlen = 6; /* hardware address length */
diff --git a/networking/udhcp/arpping.h b/networking/udhcp/arpping.h
index 99413aab6..6cbd2979f 100644
--- a/networking/udhcp/arpping.h
+++ b/networking/udhcp/arpping.h
@@ -11,7 +11,12 @@
11#include <netinet/in.h> 11#include <netinet/in.h>
12 12
13struct arpMsg { 13struct arpMsg {
14 struct ethhdr ethhdr; /* Ethernet header */ 14 /* Ethernet header */
15 u_char h_dest[6]; /* destination ether addr */
16 u_char h_source[6]; /* source ether addr */
17 u_short h_proto; /* packet type ID field */
18
19 /* ARP packet */
15 uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */ 20 uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */
16 uint16_t ptype; /* protocol type (must be ETH_P_IP) */ 21 uint16_t ptype; /* protocol type (must be ETH_P_IP) */
17 uint8_t hlen; /* hardware address length (must be 6) */ 22 uint8_t hlen; /* hardware address length (must be 6) */
@@ -22,7 +27,7 @@ struct arpMsg {
22 uint8_t tHaddr[6]; /* target's hardware address */ 27 uint8_t tHaddr[6]; /* target's hardware address */
23 uint8_t tInaddr[4]; /* target's IP address */ 28 uint8_t tInaddr[4]; /* target's IP address */
24 uint8_t pad[18]; /* pad for min. Ethernet payload (60 bytes) */ 29 uint8_t pad[18]; /* pad for min. Ethernet payload (60 bytes) */
25}; 30} __attribute__ ((packed));
26 31
27/* function prototypes */ 32/* function prototypes */
28int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *arp, char *interface); 33int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *arp, char *interface);