summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-05-14 16:35:23 +0000
committerRoy Marples <roy@marples.name>2016-05-14 16:35:23 +0000
commit29b0fc9128c041ae5ed4eddc720232028bfa1eb9 (patch)
treec25cbc54dcceb3d884ef4a4c734d868d98c80319
parent55314f9874ea04ab2b0603fccb4b2f329b06724e (diff)
downloaddhcpcd-29b0fc9128c041ae5ed4eddc720232028bfa1eb9.tar.xz
dhcp_bpf_filter -> bootp_bpf_filter (and DHCP -> BOOTP for ports).
-rw-r--r--bpf-filter.h8
-rw-r--r--dhcp.c8
-rw-r--r--dhcp.h30
-rw-r--r--if-bsd.c6
-rw-r--r--if-linux.c6
5 files changed, 29 insertions, 29 deletions
diff --git a/bpf-filter.h b/bpf-filter.h
index c8b027a4..37c3e303 100644
--- a/bpf-filter.h
+++ b/bpf-filter.h
@@ -49,7 +49,7 @@ static const struct bpf_insn arp_bpf_filter [] = {
/* Otherwise, drop it. */
BPF_STMT(BPF_RET + BPF_K, 0),
};
-#define arp_bpf_filter_len sizeof(arp_bpf_filter) / sizeof(arp_bpf_filter[0])
+#define arp_bpf_filter_len __arraycount(arp_bpf_filter)
/* dhcp_bpf_filter taken from bpf.c in dhcp-3.1.0
@@ -76,7 +76,7 @@ static const struct bpf_insn arp_bpf_filter [] = {
* http://www.isc.org/
*/
-static const struct bpf_insn dhcp_bpf_filter [] = {
+static const struct bpf_insn bootp_bpf_filter [] = {
#ifndef BPF_SKIPTYPE
/* Make sure this is an IP packet... */
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
@@ -92,10 +92,10 @@ static const struct bpf_insn dhcp_bpf_filter [] = {
BPF_STMT(BPF_LDX + BPF_B + BPF_MSH, 14 + BPF_ETHCOOK),
/* Make sure it's to the right port... */
BPF_STMT(BPF_LD + BPF_H + BPF_IND, 16 + BPF_ETHCOOK),
- BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, DHCP_CLIENT_PORT, 0, 1),
+ BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, BOOTPC, 0, 1),
/* If we passed all the tests, ask for the whole packet. */
BPF_STMT(BPF_RET + BPF_K, BPF_WHOLEPACKET),
/* Otherwise, drop it. */
BPF_STMT(BPF_RET + BPF_K, 0),
};
-#define dhcp_bpf_filter_len sizeof(dhcp_bpf_filter) / sizeof(dhcp_bpf_filter[0])
+#define bootp_bpf_filter_len __arraycount(bootp_bpf_filter)
diff --git a/dhcp.c b/dhcp.c
index fc0a0b2f..2579495d 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -1539,7 +1539,7 @@ dhcp_openudp(struct interface *ifp)
#endif
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
- sin.sin_port = htons(DHCP_CLIENT_PORT);
+ sin.sin_port = htons(BOOTPC);
if (ifp) {
state = D_STATE(ifp);
sin.sin_addr.s_addr = state->addr.s_addr;
@@ -1607,8 +1607,8 @@ dhcp_makeudppacket(size_t *sz, const uint8_t *data, size_t length,
else
ip->ip_dst.s_addr = dest.s_addr;
- udp->uh_sport = htons(DHCP_CLIENT_PORT);
- udp->uh_dport = htons(DHCP_SERVER_PORT);
+ udp->uh_sport = htons(BOOTPC);
+ udp->uh_dport = htons(BOOTPS);
udp->uh_ulen = htons((uint16_t)(sizeof(*udp) + length));
ip->ip_len = udp->uh_ulen;
udp->uh_sum = checksum(udpp, sizeof(*ip) + sizeof(*udp) + length);
@@ -1717,7 +1717,7 @@ send_message(struct interface *ifp, uint8_t type,
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = to.s_addr;
- sin.sin_port = htons(DHCP_SERVER_PORT);
+ sin.sin_port = htons(BOOTPS);
r = sendto(s, (uint8_t *)bootp, len, 0,
(struct sockaddr *)&sin, sizeof(sin));
if (r == -1)
diff --git a/dhcp.h b/dhcp.h
index e007cb03..5d4ccf47 100644
--- a/dhcp.h
+++ b/dhcp.h
@@ -39,26 +39,26 @@
#include "dhcp-common.h"
/* UDP port numbers for DHCP */
-#define DHCP_SERVER_PORT 67
-#define DHCP_CLIENT_PORT 68
+#define BOOTPS 67
+#define BOOTPC 68
-#define MAGIC_COOKIE 0x63825363
-#define BROADCAST_FLAG 0x8000
+#define MAGIC_COOKIE 0x63825363
+#define BROADCAST_FLAG 0x8000
/* DHCP message OP code */
-#define DHCP_BOOTREQUEST 1
-#define DHCP_BOOTREPLY 2
+#define DHCP_BOOTREQUEST 1
+#define DHCP_BOOTREPLY 2
/* DHCP message type */
-#define DHCP_DISCOVER 1
-#define DHCP_OFFER 2
-#define DHCP_REQUEST 3
-#define DHCP_DECLINE 4
-#define DHCP_ACK 5
-#define DHCP_NAK 6
-#define DHCP_RELEASE 7
-#define DHCP_INFORM 8
-#define DHCP_FORCERENEW 9
+#define DHCP_DISCOVER 1
+#define DHCP_OFFER 2
+#define DHCP_REQUEST 3
+#define DHCP_DECLINE 4
+#define DHCP_ACK 5
+#define DHCP_NAK 6
+#define DHCP_RELEASE 7
+#define DHCP_INFORM 8
+#define DHCP_FORCERENEW 9
/* Constants taken from RFC 2131. */
#define T1 0.5
diff --git a/if-bsd.c b/if-bsd.c
index 0f35ce2a..3cab244d 100644
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -447,14 +447,14 @@ if_openraw(struct interface *ifp, uint16_t protocol)
goto eexit;
#endif
- /* Install the DHCP filter */
+ /* Install the filter. */
memset(&pf, 0, sizeof(pf));
if (protocol == ETHERTYPE_ARP) {
pf.bf_insns = UNCONST(arp_bpf_filter);
pf.bf_len = arp_bpf_filter_len;
} else {
- pf.bf_insns = UNCONST(dhcp_bpf_filter);
- pf.bf_len = dhcp_bpf_filter_len;
+ pf.bf_insns = UNCONST(bootp_bpf_filter);
+ pf.bf_len = bootp_bpf_filter_len;
}
if (ioctl(fd, BIOCSETF, &pf) == -1)
goto eexit;
diff --git a/if-linux.c b/if-linux.c
index 404b2c96..921c8e02 100644
--- a/if-linux.c
+++ b/if-linux.c
@@ -1244,14 +1244,14 @@ if_openraw(struct interface *ifp, uint16_t protocol)
return -1;
#undef SF
- /* Install the DHCP filter */
+ /* Install the filter. */
memset(&pf, 0, sizeof(pf));
if (protocol == ETHERTYPE_ARP) {
pf.filter = UNCONST(arp_bpf_filter);
pf.len = arp_bpf_filter_len;
} else {
- pf.filter = UNCONST(dhcp_bpf_filter);
- pf.len = dhcp_bpf_filter_len;
+ pf.filter = UNCONST(bootp_bpf_filter);
+ pf.len = bootp_bpf_filter_len;
}
if (setsockopt(s, SOL_SOCKET, SO_ATTACH_FILTER, &pf, sizeof(pf)) != 0)
goto eexit;