summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.c5
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.h7
2 files changed, 10 insertions, 2 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c
index fc2a9d3..fa48636 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.c
@@ -574,8 +574,9 @@ static int dhcpv4_send_raw(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
struct udphdr *udp = (struct udphdr *)(ip + 1);
int len = pack->ptr - pack->data;
struct iovec iov[2];
+ static uint8_t bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- memcpy(eth->ether_dhost, pack->hdr->chaddr, ETH_ALEN);
+ memcpy(eth->ether_dhost, (pack->hdr->flags & DHCP_F_BROADCAST) ? bc_addr : pack->hdr->chaddr, ETH_ALEN);
memcpy(eth->ether_shost, serv->hwaddr, ETH_ALEN);
eth->ether_type = htons(ETH_P_IP);
@@ -589,7 +590,7 @@ static int dhcpv4_send_raw(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
ip->protocol = IPPROTO_UDP;
ip->check = 0;
ip->saddr = saddr;
- ip->daddr = daddr;
+ ip->daddr = (pack->hdr->flags & DHCP_F_BROADCAST) ? INADDR_BROADCAST : daddr;
ip->check = ip_csum((uint16_t *)ip, 20);
udp->source = ntohs(DHCP_SERV_PORT);
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.h b/accel-pppd/ctrl/ipoe/dhcpv4.h
index 39e24ca..57fcf93 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.h
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.h
@@ -3,6 +3,7 @@
#include <stdint.h>
#include <pthread.h>
+#include <endian.h>
#include "list.h"
#include "triton.h"
@@ -16,6 +17,12 @@
#define DHCP_OP_REQUEST 1
#define DHCP_OP_REPLY 2
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define DHCP_F_BROADCAST 0x0080
+#else
+#define DHCP_F_BROADCAST 0x8000
+#endif
+
#define DHCPDISCOVER 1
#define DHCPOFFER 2
#define DHCPREQUEST 3