diff options
author | Tom Gundersen <teg@jklm.no> | 2014-03-09 22:51:07 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-03-11 12:03:46 +0100 |
commit | 63edaa623bee43c934a0c357e8c6498992429391 (patch) | |
tree | fd954cad50a6d4661e79fa0364c5af1995648970 /src/libsystemd-network/dhcp-packet.c | |
parent | a7b1c3971a30546fe633e320d45033aba8b2ca3c (diff) |
sd-dhcp: generalise ip header generation
This will be needed for sd-dhcp-server.
Diffstat (limited to 'src/libsystemd-network/dhcp-packet.c')
-rw-r--r-- | src/libsystemd-network/dhcp-packet.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libsystemd-network/dhcp-packet.c b/src/libsystemd-network/dhcp-packet.c index 95c4277f8c..418a9773f2 100644 --- a/src/libsystemd-network/dhcp-packet.c +++ b/src/libsystemd-network/dhcp-packet.c @@ -92,17 +92,19 @@ static uint16_t dhcp_checksum(void *buf, int len) { return ~sum; } -void dhcp_packet_append_ip_headers(DHCPPacket *packet, uint16_t len) { +void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr, + uint16_t source_port, be32_t destination_addr, + uint16_t destination_port, uint16_t len) { packet->ip.version = IPVERSION; packet->ip.ihl = DHCP_IP_SIZE / 4; packet->ip.tot_len = htobe16(len); packet->ip.protocol = IPPROTO_UDP; - packet->ip.saddr = INADDR_ANY; - packet->ip.daddr = INADDR_BROADCAST; + packet->ip.saddr = source_addr; + packet->ip.daddr = destination_addr; - packet->udp.source = htobe16(DHCP_PORT_CLIENT); - packet->udp.dest = htobe16(DHCP_PORT_SERVER); + packet->udp.source = htobe16(source_port); + packet->udp.dest = htobe16(destination_port); packet->udp.len = htobe16(len - DHCP_IP_SIZE); |