]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Move the BPF buffer from DHCP into IPv4 where it belongs.
authorRoy Marples <roy@marples.name>
Fri, 19 Jun 2015 14:17:18 +0000 (14:17 +0000)
committerRoy Marples <roy@marples.name>
Fri, 19 Jun 2015 14:17:18 +0000 (14:17 +0000)
dhcp.c
dhcp.h
if-bsd.c
ipv4.c
ipv4.h

diff --git a/dhcp.c b/dhcp.c
index 04c02998ec51025281ff2e2493b69781c108fd57..91fc283ead225567a225afc816b914149c8d9785 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -3052,7 +3052,6 @@ dhcp_free(struct interface *ifp)
                free(state->old);
                free(state->new);
                free(state->offer);
-               free(state->buffer);
                free(state->clientid);
                free(state);
                ifp->if_data[IF_DATA_DHCP] = NULL;
diff --git a/dhcp.h b/dhcp.h
index cd5c12aca25d0a6d8a367e91247b6c2f6c5a2a33..8c962788d2f9eaaeb270e50a9ebfe2611213baa3 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
@@ -213,9 +213,6 @@ struct dhcp_state {
        int socket;
 
        int raw_fd;
-       size_t buffer_size, buffer_len, buffer_pos;
-       unsigned char *buffer;
-
        struct in_addr addr;
        struct in_addr net;
        struct in_addr dst;
index e82cd1db0914fd9f32b3e6e198e192d136d02d9e..58164ae4533febb0ac02eaeff7bbe7e8f929184c 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -293,7 +293,7 @@ const char *if_pfname = "Berkley Packet Filter";
 int
 if_openrawsocket(struct interface *ifp, uint16_t protocol)
 {
-       struct dhcp_state *state;
+       struct ipv4_state *state;
        int fd = -1;
        struct ifreq ifr;
        int ibuf_len = 0;
@@ -318,8 +318,7 @@ if_openrawsocket(struct interface *ifp, uint16_t protocol)
        if (fd == -1)
                return -1;
 
-       state = D_STATE(ifp);
-
+       state = IPV4_STATE(ifp);
        memset(&pv, 0, sizeof(pv));
        if (ioctl(fd, BIOCVERSION, &pv) == -1)
                goto eexit;
@@ -403,9 +402,9 @@ if_readrawpacket(struct interface *ifp, uint16_t protocol,
        struct bpf_hdr packet;
        ssize_t bytes;
        const unsigned char *payload;
-       struct dhcp_state *state;
+       struct ipv4_state *state;
 
-       state = D_STATE(ifp);
+       state = IPV4_STATE(ifp);
        fd = ipv4_protocol_fd(ifp, protocol);
 
        *flags = 0;
diff --git a/ipv4.c b/ipv4.c
index d1d825096b05e0b81ace5443ddd5b93837cf4a60..c4a1ebbced057adeb981ee95fddd9c3b6f626cd1 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -1113,6 +1113,9 @@ ipv4_free(struct interface *ifp)
                                free(addr);
                        }
                        ipv4_freerts(&state->routes);
+#ifdef BSD
+                       free(state->buffer);
+#endif
                        free(state);
                }
        }
diff --git a/ipv4.h b/ipv4.h
index 8453fc28f6831457f70bf12e8388e8183389a7f2..4fd9b326cc4611a65f4de31d6a4b4a5448e8431a 100644 (file)
--- a/ipv4.h
+++ b/ipv4.h
@@ -79,6 +79,12 @@ TAILQ_HEAD(ipv4_addrhead, ipv4_addr);
 struct ipv4_state {
        struct ipv4_addrhead addrs;
        struct rt_head routes;
+
+#ifdef BSD
+       /* Buffer for BPF */
+       size_t buffer_size, buffer_len, buffer_pos;
+       unsigned char *buffer;
+#endif
 };
 
 #define IPV4_STATE(ifp)                                                               \