diff options
Diffstat (limited to 'networking/udhcp/packet.c')
-rw-r--r-- | networking/udhcp/packet.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index a3c7ae1..7cbd83a 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c @@ -66,7 +66,7 @@ int get_packet(struct dhcpMessage *packet, int fd) return -2; } DEBUG(LOG_INFO, "Received a packet"); - + if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) { for (i = 0; broken_vendors[i][0]; i++) { if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) && @@ -77,7 +77,7 @@ int get_packet(struct dhcpMessage *packet, int fd) } } } - + return bytes; } @@ -126,10 +126,10 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, DEBUG(LOG_ERR, "socket call failed: %m"); return -1; } - + memset(&dest, 0, sizeof(dest)); memset(&packet, 0, sizeof(packet)); - + dest.sll_family = AF_PACKET; dest.sll_protocol = htons(ETH_P_IP); dest.sll_ifindex = ifindex; @@ -150,7 +150,7 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, packet.ip.tot_len = packet.udp.len; memcpy(&(packet.data), payload, sizeof(struct dhcpMessage)); packet.udp.check = checksum(&packet, sizeof(struct udp_dhcp_packet)); - + packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet)); packet.ip.ihl = sizeof(packet.ip) >> 2; packet.ip.version = IPVERSION; @@ -173,10 +173,10 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po int n = 1; int fd, result; struct sockaddr_in client; - + if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) return -1; - + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) return -1; @@ -191,7 +191,7 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po memset(&client, 0, sizeof(client)); client.sin_family = AF_INET; client.sin_port = htons(dest_port); - client.sin_addr.s_addr = dest_ip; + client.sin_addr.s_addr = dest_ip; if (connect(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) return -1; @@ -199,4 +199,4 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po result = write(fd, payload, sizeof(struct dhcpMessage)); close(fd); return result; -} +} |