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.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index a255d6e84..a0be42885 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -109,24 +109,6 @@ static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet)
109} 109}
110 110
111 111
112#if ENABLE_FEATURE_UDHCPC_ARPING
113/* Broadcast a DHCP decline message */
114int FAST_FUNC send_decline(uint32_t xid, uint32_t server, uint32_t requested)
115{
116 struct dhcp_packet packet;
117
118 init_packet(&packet, DHCPDECLINE);
119 packet.xid = xid;
120 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
121 add_simple_option(packet.options, DHCP_SERVER_ID, server);
122
123 bb_info_msg("Sending decline...");
124
125 return raw_bcast_from_client_config_ifindex(&packet);
126}
127#endif
128
129
130/* Broadcast a DHCP discover packet to the network, with an optionally requested IP */ 112/* Broadcast a DHCP discover packet to the network, with an optionally requested IP */
131int FAST_FUNC send_discover(uint32_t xid, uint32_t requested) 113int FAST_FUNC send_discover(uint32_t xid, uint32_t requested)
132{ 114{
@@ -136,11 +118,9 @@ int FAST_FUNC send_discover(uint32_t xid, uint32_t requested)
136 packet.xid = xid; 118 packet.xid = xid;
137 if (requested) 119 if (requested)
138 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested); 120 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
139
140 /* Explicitly saying that we want RFC-compliant packets helps 121 /* Explicitly saying that we want RFC-compliant packets helps
141 * some buggy DHCP servers to NOT send bigger packets */ 122 * some buggy DHCP servers to NOT send bigger packets */
142 add_simple_option(packet.options, DHCP_MAX_SIZE, htons(576)); 123 add_simple_option(packet.options, DHCP_MAX_SIZE, htons(576));
143
144 add_param_req_option(&packet); 124 add_param_req_option(&packet);
145 125
146 bb_info_msg("Sending discover..."); 126 bb_info_msg("Sending discover...");
@@ -159,7 +139,6 @@ int FAST_FUNC send_select(uint32_t xid, uint32_t server, uint32_t requested)
159 139
160 init_packet(&packet, DHCPREQUEST); 140 init_packet(&packet, DHCPREQUEST);
161 packet.xid = xid; 141 packet.xid = xid;
162
163 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested); 142 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
164 add_simple_option(packet.options, DHCP_SERVER_ID, server); 143 add_simple_option(packet.options, DHCP_SERVER_ID, server);
165 add_param_req_option(&packet); 144 add_param_req_option(&packet);
@@ -177,17 +156,46 @@ int FAST_FUNC send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
177 156
178 init_packet(&packet, DHCPREQUEST); 157 init_packet(&packet, DHCPREQUEST);
179 packet.xid = xid; 158 packet.xid = xid;
159 /* RFC 2131:
160 * "3.2 Client-server interaction - reusing a previously
161 * allocated network address"...
162 * The client broadcasts a DHCPREQUEST message on its local subnet.
163 * The message includes the client's network address in the
164 * REQUESTED_IP option. As the client has not received its
165 * network address, it MUST NOT fill in the 'ciaddr' field."
166 *
167 * FIXME: we seem to not follow this, we do set ciaddr.
168 */
180 packet.ciaddr = ciaddr; 169 packet.ciaddr = ciaddr;
181 170 add_simple_option(packet.options, DHCP_REQUESTED_IP, ciaddr);
171 if (server)
172 add_simple_option(packet.options, DHCP_SERVER_ID, server);
182 add_param_req_option(&packet); 173 add_param_req_option(&packet);
174
183 bb_info_msg("Sending renew..."); 175 bb_info_msg("Sending renew...");
184 if (server) 176 if (server)
185 return udhcp_send_kernel_packet(&packet, 177 return udhcp_send_kernel_packet(&packet,
186 ciaddr, CLIENT_PORT, 178 ciaddr, CLIENT_PORT,
187 server, SERVER_PORT); 179 server, SERVER_PORT);
180 return raw_bcast_from_client_config_ifindex(&packet);
181}
182
183
184#if ENABLE_FEATURE_UDHCPC_ARPING
185/* Broadcast a DHCP decline message */
186int FAST_FUNC send_decline(uint32_t xid, uint32_t server, uint32_t requested)
187{
188 struct dhcp_packet packet;
189
190 init_packet(&packet, DHCPDECLINE);
191 packet.xid = xid;
192 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
193 add_simple_option(packet.options, DHCP_SERVER_ID, server);
188 194
195 bb_info_msg("Sending decline...");
189 return raw_bcast_from_client_config_ifindex(&packet); 196 return raw_bcast_from_client_config_ifindex(&packet);
190} 197}
198#endif
191 199
192 200
193/* Unicast a DHCP release message */ 201/* Unicast a DHCP release message */