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.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 88d4d88dc..14e6c6678 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -4,19 +4,7 @@
4 * 4 *
5 * Russ Dill <Russ.Dill@asu.edu> July 2001 5 * Russ Dill <Russ.Dill@asu.edu> July 2001
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 8 */
21 9
22#include <string.h> 10#include <string.h>
@@ -69,7 +57,7 @@ unsigned long random_xid(void)
69/* initialize a packet with the proper defaults */ 57/* initialize a packet with the proper defaults */
70static void init_packet(struct dhcpMessage *packet, char type) 58static void init_packet(struct dhcpMessage *packet, char type)
71{ 59{
72 init_header(packet, type); 60 udhcp_init_header(packet, type);
73 memcpy(packet->chaddr, client_config.arp, 6); 61 memcpy(packet->chaddr, client_config.arp, 6);
74 if (client_config.clientid) 62 if (client_config.clientid)
75 add_option_string(packet->options, client_config.clientid); 63 add_option_string(packet->options, client_config.clientid);
@@ -109,7 +97,7 @@ int send_discover(unsigned long xid, unsigned long requested)
109 97
110 add_requests(&packet); 98 add_requests(&packet);
111 LOG(LOG_DEBUG, "Sending discover..."); 99 LOG(LOG_DEBUG, "Sending discover...");
112 return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 100 return udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
113 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); 101 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
114} 102}
115 103
@@ -129,7 +117,7 @@ int send_selecting(unsigned long xid, unsigned long server, unsigned long reques
129 add_requests(&packet); 117 add_requests(&packet);
130 addr.s_addr = requested; 118 addr.s_addr = requested;
131 LOG(LOG_DEBUG, "Sending select for %s...", inet_ntoa(addr)); 119 LOG(LOG_DEBUG, "Sending select for %s...", inet_ntoa(addr));
132 return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 120 return udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
133 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); 121 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
134} 122}
135 123
@@ -147,8 +135,8 @@ int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr)
147 add_requests(&packet); 135 add_requests(&packet);
148 LOG(LOG_DEBUG, "Sending renew..."); 136 LOG(LOG_DEBUG, "Sending renew...");
149 if (server) 137 if (server)
150 ret = kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT); 138 ret = udhcp_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
151 else ret = raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 139 else ret = udhcp_raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
152 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); 140 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
153 return ret; 141 return ret;
154} 142}
@@ -167,7 +155,7 @@ int send_release(unsigned long server, unsigned long ciaddr)
167 add_simple_option(packet.options, DHCP_SERVER_ID, server); 155 add_simple_option(packet.options, DHCP_SERVER_ID, server);
168 156
169 LOG(LOG_DEBUG, "Sending release..."); 157 LOG(LOG_DEBUG, "Sending release...");
170 return kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT); 158 return udhcp_kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
171} 159}
172 160
173 161
@@ -212,7 +200,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
212 /* check IP checksum */ 200 /* check IP checksum */
213 check = packet.ip.check; 201 check = packet.ip.check;
214 packet.ip.check = 0; 202 packet.ip.check = 0;
215 if (check != checksum(&(packet.ip), sizeof(packet.ip))) { 203 if (check != udhcp_checksum(&(packet.ip), sizeof(packet.ip))) {
216 DEBUG(LOG_INFO, "bad IP header checksum, ignoring"); 204 DEBUG(LOG_INFO, "bad IP header checksum, ignoring");
217 return -1; 205 return -1;
218 } 206 }
@@ -228,7 +216,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
228 packet.ip.saddr = source; 216 packet.ip.saddr = source;
229 packet.ip.daddr = dest; 217 packet.ip.daddr = dest;
230 packet.ip.tot_len = packet.udp.len; /* cheat on the psuedo-header */ 218 packet.ip.tot_len = packet.udp.len; /* cheat on the psuedo-header */
231 if (check && check != checksum(&packet, bytes)) { 219 if (check && check != udhcp_checksum(&packet, bytes)) {
232 DEBUG(LOG_ERR, "packet with bad UDP checksum received, ignoring"); 220 DEBUG(LOG_ERR, "packet with bad UDP checksum received, ignoring");
233 return -2; 221 return -2;
234 } 222 }