aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/clientpacket.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/clientpacket.c')
-rw-r--r--networking/udhcp/clientpacket.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 77331d98d..1ab17321d 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -79,8 +79,18 @@ static void add_param_req_option(struct dhcpMessage *packet)
79} 79}
80 80
81 81
82static int raw_bcast_from_client_config_ifindex(struct dhcpMessage *packet)
83{
84 return udhcp_send_raw_packet(packet,
85 /*src*/ INADDR_ANY, CLIENT_PORT,
86 /*dst*/ INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR,
87 client_config.ifindex);
88}
89
90
82#if ENABLE_FEATURE_UDHCPC_ARPING 91#if ENABLE_FEATURE_UDHCPC_ARPING
83/* Unicast a DHCP decline message */ 92/* Broadcast a DHCP decline message */
93//FIXME: maybe it should be unicast?
84int FAST_FUNC send_decline(uint32_t xid, uint32_t server, uint32_t requested) 94int FAST_FUNC send_decline(uint32_t xid, uint32_t server, uint32_t requested)
85{ 95{
86 struct dhcpMessage packet; 96 struct dhcpMessage packet;
@@ -92,8 +102,7 @@ int FAST_FUNC send_decline(uint32_t xid, uint32_t server, uint32_t requested)
92 102
93 bb_info_msg("Sending decline..."); 103 bb_info_msg("Sending decline...");
94 104
95 return udhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 105 return raw_bcast_from_client_config_ifindex(&packet);
96 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
97} 106}
98#endif 107#endif
99 108
@@ -114,13 +123,13 @@ int FAST_FUNC send_discover(uint32_t xid, uint32_t requested)
114 add_param_req_option(&packet); 123 add_param_req_option(&packet);
115 124
116 bb_info_msg("Sending discover..."); 125 bb_info_msg("Sending discover...");
117 return udhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 126 return raw_bcast_from_client_config_ifindex(&packet);
118 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
119} 127}
120 128
121 129
122/* Broadcasts a DHCP request message */ 130/* Broadcasts a DHCP request message */
123int FAST_FUNC send_selecting(uint32_t xid, uint32_t server, uint32_t requested) 131//FIXME: maybe it should be unicast?
132int FAST_FUNC send_select(uint32_t xid, uint32_t server, uint32_t requested)
124{ 133{
125 struct dhcpMessage packet; 134 struct dhcpMessage packet;
126 struct in_addr addr; 135 struct in_addr addr;
@@ -134,8 +143,7 @@ int FAST_FUNC send_selecting(uint32_t xid, uint32_t server, uint32_t requested)
134 143
135 addr.s_addr = requested; 144 addr.s_addr = requested;
136 bb_info_msg("Sending select for %s...", inet_ntoa(addr)); 145 bb_info_msg("Sending select for %s...", inet_ntoa(addr));
137 return udhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 146 return raw_bcast_from_client_config_ifindex(&packet);
138 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
139} 147}
140 148
141 149
@@ -151,10 +159,11 @@ int FAST_FUNC send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr)
151 add_param_req_option(&packet); 159 add_param_req_option(&packet);
152 bb_info_msg("Sending renew..."); 160 bb_info_msg("Sending renew...");
153 if (server) 161 if (server)
154 return udhcp_send_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT); 162 return udhcp_send_kernel_packet(&packet,
163 ciaddr, CLIENT_PORT,
164 server, SERVER_PORT);
155 165
156 return udhcp_send_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 166 return raw_bcast_from_client_config_ifindex(&packet);
157 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
158} 167}
159 168
160 169