summaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
authorDenys Vlasenko2013-01-28 15:25:35 +0100
committerDenys Vlasenko2013-01-28 15:25:35 +0100
commit04ac6e03c3ae8302be2420cf73d70cf466791fa6 (patch)
tree9fd4fbfd3512c576b213b5686a52ff1753d2b2e6 /networking/udhcp
parent03b614739b923994ff0bef74622973ad18fefebd (diff)
downloadbusybox-04ac6e03c3ae8302be2420cf73d70cf466791fa6.zip
busybox-04ac6e03c3ae8302be2420cf73d70cf466791fa6.tar.gz
udhcpc6: fix port numbers used if !FEATURE_UDHCP_PORT
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/d6_dhcpc.c28
-rw-r--r--networking/udhcp/dhcpc.h6
-rw-r--r--networking/udhcp/dhcpd.h6
3 files changed, 22 insertions, 18 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index c44220b..b0f0798 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -311,8 +311,8 @@ static int d6_mcast_from_client_config_ifindex(struct d6_packet *packet, uint8_t
return d6_send_raw_packet(
packet, (end - (uint8_t*) packet),
- /*src*/ NULL, CLIENT_PORT,
- /*dst*/ (struct in6_addr*)FF02__1_2, SERVER_PORT, MAC_BCAST_ADDR,
+ /*src*/ NULL, CLIENT_PORT6,
+ /*dst*/ (struct in6_addr*)FF02__1_2, SERVER_PORT6, MAC_BCAST_ADDR,
client_config.ifindex
);
}
@@ -554,8 +554,8 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st
if (server_ipv6)
return d6_send_kernel_packet(
&packet, (opt_ptr - (uint8_t*) &packet),
- our_cur_ipv6, CLIENT_PORT,
- server_ipv6, SERVER_PORT
+ our_cur_ipv6, CLIENT_PORT6,
+ server_ipv6, SERVER_PORT6
);
return d6_mcast_from_client_config_ifindex(&packet, opt_ptr);
}
@@ -576,8 +576,8 @@ static int send_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cu
bb_info_msg("Sending release...");
return d6_send_kernel_packet(
&packet, (opt_ptr - (uint8_t*) &packet),
- our_cur_ipv6, CLIENT_PORT,
- server_ipv6, SERVER_PORT
+ our_cur_ipv6, CLIENT_PORT6,
+ server_ipv6, SERVER_PORT6
);
}
@@ -614,7 +614,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6
/* make sure its the right packet for us, and that it passes sanity checks */
if (packet.ip6.ip6_nxt != IPPROTO_UDP
|| (packet.ip6.ip6_vfc >> 4) != 6
- || packet.udp.dest != htons(CLIENT_PORT)
+ || packet.udp.dest != htons(CLIENT_PORT6)
/* || bytes > (int) sizeof(packet) - can't happen */
|| packet.udp.len != packet.ip6.ip6_plen
) {
@@ -708,7 +708,7 @@ static int d6_raw_socket(int ifindex)
BPF_STMT(BPF_LDX|BPF_B|BPF_MSH, 0),
/* load udp destination port from halfword[header_len + 2] */
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 2),
- /* jump to L3 if udp dport is CLIENT_PORT, else to L4 */
+ /* jump to L3 if udp dport is CLIENT_PORT6, else to L4 */
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 68, 0, 1),
/* L3: accept packet */
BPF_STMT(BPF_RET|BPF_K, 0xffffffff),
@@ -733,7 +733,7 @@ static int d6_raw_socket(int ifindex)
xbind(fd, (struct sockaddr *) &sock, sizeof(sock));
#if 0
- if (CLIENT_PORT == 68) {
+ if (CLIENT_PORT6 == 546) {
/* Use only if standard port is in use */
/* Ignoring error (kernel may lack support for this) */
if (setsockopt(fd, SOL_SOCKET, SO_ATTACH_FILTER, &filter_prog,
@@ -761,7 +761,7 @@ static void change_listen_mode(int new_mode)
sockfd = -1;
}
if (new_mode == LISTEN_KERNEL)
- sockfd = udhcp_listen_socket(/*INADDR_ANY,*/ CLIENT_PORT, client_config.interface);
+ sockfd = udhcp_listen_socket(/*INADDR_ANY,*/ CLIENT_PORT6, client_config.interface);
else if (new_mode != LISTEN_NONE)
sockfd = d6_raw_socket(client_config.ifindex);
/* else LISTEN_NONE: sockfd stays closed */
@@ -931,8 +931,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
fd_set rfds;
/* Default options */
- IF_FEATURE_UDHCP_PORT(SERVER_PORT = 547;)
- IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 546;)
+ IF_FEATURE_UDHCP_PORT(SERVER_PORT6 = 547;)
+ IF_FEATURE_UDHCP_PORT(CLIENT_PORT6 = 546;)
client_config.interface = "eth0";
client_config.script = CONFIG_UDHCPC_DEFAULT_SCRIPT;
@@ -961,8 +961,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
}
#if ENABLE_FEATURE_UDHCP_PORT
if (opt & OPT_P) {
- CLIENT_PORT = xatou16(str_P);
- SERVER_PORT = CLIENT_PORT - 1;
+ CLIENT_PORT6 = xatou16(str_P);
+ SERVER_PORT6 = CLIENT_PORT6 + 1;
}
#endif
while (list_O) {
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h
index 2859a07..9f423a5 100644
--- a/networking/udhcp/dhcpc.h
+++ b/networking/udhcp/dhcpc.h
@@ -29,9 +29,11 @@ struct client_config_t {
#define client_config (*(struct client_config_t*)(&bb_common_bufsiz1[COMMON_BUFSIZE / 2]))
#if ENABLE_FEATURE_UDHCP_PORT
-#define CLIENT_PORT (client_config.port)
+#define CLIENT_PORT (client_config.port)
+#define CLIENT_PORT6 (client_config.port)
#else
-#define CLIENT_PORT 68
+#define CLIENT_PORT 68
+#define CLIENT_PORT6 546
#endif
POP_SAVED_FUNCTION_VISIBILITY
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h
index 7c801bf..a77724f 100644
--- a/networking/udhcp/dhcpd.h
+++ b/networking/udhcp/dhcpd.h
@@ -61,9 +61,11 @@ struct server_config_t {
/* client_config sits in 2nd half of bb_common_bufsiz1 */
#if ENABLE_FEATURE_UDHCP_PORT
-#define SERVER_PORT (server_config.port)
+#define SERVER_PORT (server_config.port)
+#define SERVER_PORT6 (server_config.port)
#else
-#define SERVER_PORT 67
+#define SERVER_PORT 67
+#define SERVER_PORT6 547
#endif