gdhcp: DHCP server IP address is stored in host order
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 11 Feb 2013 07:26:35 +0000 (09:26 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 11 Feb 2013 11:42:47 +0000 (13:42 +0200)
This change affects unicasted DHCP renew and release messages.
A DHCP server receiving packets via a raw socket will get all
packets destined to port 67. If the DHCP server checks the
intended server IP address, the request will fail. If the server
does not care about the IP address being used, it will send a
reply. The reply is not recognized by ConnMan since it is coming
from another IP address than what it was sent to. ConnMan will
retry quite a few times, but eventually settle down and use the
address even without a proper response from the server.

gdhcp/common.c

index ed27e43..e8676f8 100644 (file)
@@ -629,7 +629,7 @@ int dhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
        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 = htonl(dest_ip);
        if (connect(fd, (struct sockaddr *) &client, sizeof(client)) < 0) {
                close(fd);
                return -errno;