summaryrefslogtreecommitdiff
path: root/networking/udhcp/clientpacket.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/clientpacket.c')
-rw-r--r--networking/udhcp/clientpacket.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index af97962a0..42b4895e5 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -25,7 +25,7 @@
25 25
26 26
27/* Create a random xid */ 27/* Create a random xid */
28unsigned random_xid(void) 28uint32_t random_xid(void)
29{ 29{
30 static smallint initialized; 30 static smallint initialized;
31 31
@@ -44,8 +44,10 @@ static void init_packet(struct dhcpMessage *packet, char type)
44 memcpy(packet->chaddr, client_config.arp, 6); 44 memcpy(packet->chaddr, client_config.arp, 6);
45 if (client_config.clientid) 45 if (client_config.clientid)
46 add_option_string(packet->options, client_config.clientid); 46 add_option_string(packet->options, client_config.clientid);
47 if (client_config.hostname) add_option_string(packet->options, client_config.hostname); 47 if (client_config.hostname)
48 if (client_config.fqdn) add_option_string(packet->options, client_config.fqdn); 48 add_option_string(packet->options, client_config.hostname);
49 if (client_config.fqdn)
50 add_option_string(packet->options, client_config.fqdn);
49 add_option_string(packet->options, client_config.vendorclass); 51 add_option_string(packet->options, client_config.vendorclass);
50} 52}
51 53
@@ -69,7 +71,7 @@ static void add_requests(struct dhcpMessage *packet)
69 71
70 72
71/* Broadcast a DHCP discover packet to the network, with an optionally requested IP */ 73/* Broadcast a DHCP discover packet to the network, with an optionally requested IP */
72int send_discover(unsigned long xid, unsigned long requested) 74int send_discover(uint32_t xid, uint32_t requested)
73{ 75{
74 struct dhcpMessage packet; 76 struct dhcpMessage packet;
75 77
@@ -86,7 +88,7 @@ int send_discover(unsigned long xid, unsigned long requested)
86 88
87 89
88/* Broadcasts a DHCP request message */ 90/* Broadcasts a DHCP request message */
89int send_selecting(unsigned long xid, unsigned long server, unsigned long requested) 91int send_selecting(uint32_t xid, uint32_t server, uint32_t requested)
90{ 92{
91 struct dhcpMessage packet; 93 struct dhcpMessage packet;
92 struct in_addr addr; 94 struct in_addr addr;
@@ -106,10 +108,9 @@ int send_selecting(unsigned long xid, unsigned long server, unsigned long reques
106 108
107 109
108/* Unicasts or broadcasts a DHCP renew message */ 110/* Unicasts or broadcasts a DHCP renew message */
109int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr) 111int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
110{ 112{
111 struct dhcpMessage packet; 113 struct dhcpMessage packet;
112 int ret = 0;
113 114
114 init_packet(&packet, DHCPREQUEST); 115 init_packet(&packet, DHCPREQUEST);
115 packet.xid = xid; 116 packet.xid = xid;
@@ -118,15 +119,15 @@ int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr)
118 add_requests(&packet); 119 add_requests(&packet);
119 bb_info_msg("Sending renew..."); 120 bb_info_msg("Sending renew...");
120 if (server) 121 if (server)
121 ret = udhcp_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT); 122 return udhcp_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
122 else ret = udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 123
124 return udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
123 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); 125 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
124 return ret;
125} 126}
126 127
127 128
128/* Unicasts a DHCP release message */ 129/* Unicasts a DHCP release message */
129int send_release(unsigned long server, unsigned long ciaddr) 130int send_release(uint32_t server, uint32_t ciaddr)
130{ 131{
131 struct dhcpMessage packet; 132 struct dhcpMessage packet;
132 133
@@ -214,5 +215,4 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
214 } 215 }
215 DEBUG("oooooh!!! got some!"); 216 DEBUG("oooooh!!! got some!");
216 return bytes - (sizeof(packet.ip) + sizeof(packet.udp)); 217 return bytes - (sizeof(packet.ip) + sizeof(packet.udp));
217
218} 218}