aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/clientsocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/clientsocket.c')
-rw-r--r--networking/udhcp/clientsocket.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/networking/udhcp/clientsocket.c b/networking/udhcp/clientsocket.c
index 954db5319..b5534f83e 100644
--- a/networking/udhcp/clientsocket.c
+++ b/networking/udhcp/clientsocket.c
@@ -33,8 +33,8 @@
33#include <linux/filter.h> 33#include <linux/filter.h>
34 34
35#include "common.h" 35#include "common.h"
36 36#include "dhcpd.h"
37#define SERVER_AND_CLIENT_PORTS ((SERVER_PORT << 16) + CLIENT_PORT) 37#include "dhcpc.h"
38 38
39int raw_socket(int ifindex) 39int raw_socket(int ifindex)
40{ 40{
@@ -62,6 +62,7 @@ int raw_socket(int ifindex)
62 * 62 *
63 * TODO: make conditional? 63 * TODO: make conditional?
64 */ 64 */
65#define SERVER_AND_CLIENT_PORTS ((67 << 16) + 68)
65 static const struct sock_filter filter_instr[] = { 66 static const struct sock_filter filter_instr[] = {
66 /* check for udp */ 67 /* check for udp */
67 BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 9), 68 BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 9),
@@ -89,10 +90,13 @@ int raw_socket(int ifindex)
89 fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)); 90 fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
90 DEBUG("got raw socket fd %d", fd); 91 DEBUG("got raw socket fd %d", fd);
91 92
92 /* Ignoring error (kernel may lack support for this) */ 93 if (SERVER_PORT == 67 && CLIENT_PORT == 68) {
93 if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog, 94 /* Use only if standard ports are in use */
95 /* Ignoring error (kernel may lack support for this) */
96 if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
94 sizeof(filter_prog)) >= 0) 97 sizeof(filter_prog)) >= 0)
95 DEBUG("attached filter to raw socket fd %d", fd); 98 DEBUG("attached filter to raw socket fd %d", fd);
99 }
96 100
97 sock.sll_family = AF_PACKET; 101 sock.sll_family = AF_PACKET;
98 sock.sll_protocol = htons(ETH_P_IP); 102 sock.sll_protocol = htons(ETH_P_IP);