summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-dhcp/dhcp-internal.h4
-rw-r--r--src/libsystemd-dhcp/dhcp-network.c12
-rw-r--r--src/libsystemd-dhcp/sd-dhcp-client.c4
-rw-r--r--src/libsystemd-dhcp/test-dhcp-client.c4
4 files changed, 13 insertions, 11 deletions
diff --git a/src/libsystemd-dhcp/dhcp-internal.h b/src/libsystemd-dhcp/dhcp-internal.h
index 3f1e000365..7639069cf2 100644
--- a/src/libsystemd-dhcp/dhcp-internal.h
+++ b/src/libsystemd-dhcp/dhcp-internal.h
@@ -30,10 +30,10 @@
#include "dhcp-protocol.h"
int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link);
-int dhcp_network_bind_udp_socket(int index, be32_t client_address);
+int dhcp_network_bind_udp_socket(int index, be32_t address, uint16_t port);
int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
const void *packet, size_t len);
-int dhcp_network_send_udp_socket(int s, be32_t server_address,
+int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port,
const void *packet, size_t len);
int dhcp_option_append(uint8_t **buf, size_t *buflen, uint8_t code,
diff --git a/src/libsystemd-dhcp/dhcp-network.c b/src/libsystemd-dhcp/dhcp-network.c
index b2de67e8a7..6c9d4ef999 100644
--- a/src/libsystemd-dhcp/dhcp-network.c
+++ b/src/libsystemd-dhcp/dhcp-network.c
@@ -56,13 +56,13 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
return s;
}
-int dhcp_network_bind_udp_socket(int index, be32_t client_address)
+int dhcp_network_bind_udp_socket(int index, be32_t address, uint16_t port)
{
int s;
union sockaddr_union src = {
.in.sin_family = AF_INET,
- .in.sin_port = htobe16(DHCP_PORT_CLIENT),
- .in.sin_addr.s_addr = client_address,
+ .in.sin_port = htobe16(port),
+ .in.sin_addr.s_addr = address,
};
s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
@@ -90,13 +90,13 @@ int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link,
return 0;
}
-int dhcp_network_send_udp_socket(int s, be32_t server_address,
+int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port,
const void *packet, size_t len)
{
union sockaddr_union dest = {
.in.sin_family = AF_INET,
- .in.sin_port = htobe16(DHCP_PORT_SERVER),
- .in.sin_addr.s_addr = server_address,
+ .in.sin_port = htobe16(port),
+ .in.sin_addr.s_addr = address,
};
if (sendto(s, packet, len, 0, &dest.sa, sizeof(dest.in)) < 0)
diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c
index bff35885f6..83d56a244e 100644
--- a/src/libsystemd-dhcp/sd-dhcp-client.c
+++ b/src/libsystemd-dhcp/sd-dhcp-client.c
@@ -324,6 +324,7 @@ static int client_send_request(sd_dhcp_client *client, uint16_t secs) {
if (client->state == DHCP_STATE_RENEWING) {
err = dhcp_network_send_udp_socket(client->fd,
client->lease->server_address,
+ DHCP_PORT_SERVER,
&request->dhcp,
len - DHCP_IP_UDP_SIZE);
} else {
@@ -535,7 +536,8 @@ static int client_timeout_t1(sd_event_source *s, uint64_t usec,
client->attempt = 1;
r = dhcp_network_bind_udp_socket(client->index,
- client->lease->address);
+ client->lease->address,
+ DHCP_PORT_CLIENT);
if (r < 0) {
client_stop(client, r);
return 0;
diff --git a/src/libsystemd-dhcp/test-dhcp-client.c b/src/libsystemd-dhcp/test-dhcp-client.c
index 56a10b3dfc..f341b3c713 100644
--- a/src/libsystemd-dhcp/test-dhcp-client.c
+++ b/src/libsystemd-dhcp/test-dhcp-client.c
@@ -191,12 +191,12 @@ int dhcp_network_bind_raw_socket(int index, union sockaddr_union *link)
return test_fd[0];
}
-int dhcp_network_bind_udp_socket(int index, be32_t client_address)
+int dhcp_network_bind_udp_socket(int index, be32_t address, uint16_t port)
{
return 0;
}
-int dhcp_network_send_udp_socket(int s, be32_t server_address,
+int dhcp_network_send_udp_socket(int s, be32_t address, uint16_t port,
const void *packet, size_t len)
{
return 0;