aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/packet.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/packet.c')
-rw-r--r--networking/udhcp/packet.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index d9f715971..0f2a3bc6f 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -14,10 +14,9 @@
14#endif 14#endif
15#include <errno.h> 15#include <errno.h>
16 16
17#include "packet.h"
18#include "debug.h"
19#include "dhcpd.h" 17#include "dhcpd.h"
20#include "options.h" 18#include "options.h"
19#include "common.h"
21 20
22 21
23void init_header(struct dhcpMessage *packet, char type) 22void init_header(struct dhcpMessage *packet, char type)
@@ -123,7 +122,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
123 struct udp_dhcp_packet packet; 122 struct udp_dhcp_packet packet;
124 123
125 if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { 124 if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
126 DEBUG(LOG_ERR, "socket call failed: %s", strerror(errno)); 125 DEBUG(LOG_ERR, "socket call failed: %m");
127 return -1; 126 return -1;
128 } 127 }
129 128
@@ -136,7 +135,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
136 dest.sll_halen = 6; 135 dest.sll_halen = 6;
137 memcpy(dest.sll_addr, dest_arp, 6); 136 memcpy(dest.sll_addr, dest_arp, 6);
138 if (bind(fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_ll)) < 0) { 137 if (bind(fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_ll)) < 0) {
139 DEBUG(LOG_ERR, "bind call failed: %s", strerror(errno)); 138 DEBUG(LOG_ERR, "bind call failed: %m");
140 close(fd); 139 close(fd);
141 return -1; 140 return -1;
142 } 141 }
@@ -159,7 +158,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
159 158
160 result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest)); 159 result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest));
161 if (result <= 0) { 160 if (result <= 0) {
162 DEBUG(LOG_ERR, "write on socket failed: %s", strerror(errno)); 161 DEBUG(LOG_ERR, "write on socket failed: %m");
163 } 162 }
164 close(fd); 163 close(fd);
165 return result; 164 return result;
@@ -200,4 +199,3 @@ int kernel_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_p
200 close(fd); 199 close(fd);
201 return result; 200 return result;
202} 201}
203