2
* dhcpcd - DHCP client daemon -
3
* Copyright (C) 1996 - 1997 Yoichi Hariguchi <yoichi@fore.com>
4
* Copyright (C) January, 1998 Sergei Viznyuk <sv@phystech.com>
5
* Copyright (C) 2005 Roy Marples <uberlord@gentoo.org>
6
* Copyright (C) 2005 Simon Kelley <simon@thekelleys.org.uk>
8
* dhcpcd is an RFC2131 and RFC1541 compliant DHCP client daemon.
10
* This is free software; you can redistribute it and/or modify it
11
* under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful, but
16
* WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
* See the GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
#include <netinet/in.h>
27
#include <net/if_arp.h>
31
extern dhcpMessage *DhcpMsgSend;
32
extern dhcpOptions DhcpOptions;
33
extern dhcpInterface DhcpIface;
34
extern char *HostName;
35
extern int HostName_len;
38
extern unsigned LeaseTime;
39
extern int TokenRingIf;
40
extern unsigned char ClientHwAddr[6];
41
extern udpipMessage UdpIpMsgSend;
42
extern int magic_cookie;
43
extern unsigned short dhcpMsgSize;
44
extern unsigned nleaseTime;
45
extern int BroadcastResp;
46
extern struct in_addr inform_ipaddr;
48
extern int SetFQDNHostName;
50
/*****************************************************************************/
51
void buildDhcpDiscover(xid)
54
register unsigned char *p = DhcpMsgSend->options + 4;
56
/* build Ethernet header */
57
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
58
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,MAC_BCAST_ADDR,ETH_ALEN);
59
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
60
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
62
DhcpMsgSend->op = DHCP_BOOTREQUEST;
63
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
64
DhcpMsgSend->hlen = ETH_ALEN;
65
DhcpMsgSend->xid = xid;
66
DhcpMsgSend->secs = htons(10);
68
DhcpMsgSend->flags = htons(BROADCAST_FLAG);
70
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
72
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
74
memcpy(DhcpMsgSend->options,&magic_cookie,4);
75
*p++ = dhcpMessageType;
78
*p++ = dhcpMaxMsgSize;
80
memcpy(p,&dhcpMsgSize,2);
82
if ( DhcpIface.ciaddr )
85
DhcpMsgSend->ciaddr = DhcpIface.ciaddr;
88
*p++ = dhcpRequestedIPaddr;
90
memcpy(p,&DhcpIface.ciaddr,4);
94
*p++ = dhcpIPaddrLeaseTime;
96
memcpy(p,&nleaseTime,4);
98
*p++ = dhcpParamRequest;
101
*p++ = routersOnSubnet;
107
*p++ = broadcastAddr;
108
*p++ = performMaskDiscovery;
109
*p++ = performRouterDiscovery;
111
*p++ = nisDomainName;
114
*p++ = dnsSearchPath;
115
/* FQDN option (81) replaces HostName option (12) if requested */
116
if (( HostName ) && ( SetFQDNHostName == FQDNdisable ))
120
memcpy(p,HostName,HostName_len);
123
*p++ = dhcpClassIdentifier;
124
*p++ = DhcpIface.class_len;
125
memcpy(p,DhcpIface.class_id,DhcpIface.class_len);
126
p += DhcpIface.class_len;
127
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
128
p += DhcpIface.client_len;
129
if (( HostName ) && ( SetFQDNHostName != FQDNdisable ))
131
/* Draft IETF DHC-FQDN option (81) */
132
*p++ = dhcpFQDNHostName;
133
*p++ = HostName_len + 3;
135
* S: 1 => Client requests Server to update A RR in DNS as well as PTR
136
* O: 1 => Server indicates to client that DNS has been updated regardless
137
* E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com"
138
* N: 1 => Client requests Server to not update DNS
140
*p++ = SetFQDNHostName & 0x9;
141
*p++ = 0; /* rcode1, response from DNS server to DHCP for PTR RR */
142
*p++ = 0; /* rcode2, response from DNS server to DHCP for A RR if S=1 */
143
memcpy(p,HostName,HostName_len);
148
/* build UDP/IP header */
149
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST,
150
htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage));
152
/*****************************************************************************/
153
void buildDhcpRequest(xid)
156
register unsigned char *p = DhcpMsgSend->options + 4;
158
/* build Ethernet header */
159
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
160
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,MAC_BCAST_ADDR,ETH_ALEN);
161
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
162
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
164
DhcpMsgSend->op = DHCP_BOOTREQUEST;
165
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
166
DhcpMsgSend->hlen = ETH_ALEN;
167
DhcpMsgSend->xid = xid;
168
DhcpMsgSend->secs = htons(10);
170
DhcpMsgSend->flags = htons(BROADCAST_FLAG);
172
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
174
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
176
memcpy(DhcpMsgSend->options,&magic_cookie,4);
177
*p++ = dhcpMessageType;
180
*p++ = dhcpMaxMsgSize;
182
memcpy(p,&dhcpMsgSize,2);
184
*p++ = dhcpServerIdentifier;
186
memcpy(p,DhcpOptions.val[dhcpServerIdentifier],4);
189
DhcpMsgSend->ciaddr = DhcpIface.ciaddr;
192
*p++ = dhcpRequestedIPaddr;
194
memcpy(p,&DhcpIface.ciaddr,4);
197
if ( DhcpOptions.val[dhcpIPaddrLeaseTime] )
199
*p++ = dhcpIPaddrLeaseTime;
201
memcpy(p,DhcpOptions.val[dhcpIPaddrLeaseTime],4);
204
*p++ = dhcpParamRequest;
207
*p++ = routersOnSubnet;
213
*p++ = broadcastAddr;
214
*p++ = performMaskDiscovery;
215
*p++ = performRouterDiscovery;
217
*p++ = nisDomainName;
220
*p++ = dnsSearchPath;
221
/* FQDN option (81) replaces HostName option (12) if requested */
222
if (( HostName ) && ( SetFQDNHostName == FQDNdisable ))
226
memcpy(p,HostName,HostName_len);
229
*p++ = dhcpClassIdentifier;
230
*p++ = DhcpIface.class_len;
231
memcpy(p,DhcpIface.class_id,DhcpIface.class_len);
232
p += DhcpIface.class_len;
233
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
234
p += DhcpIface.client_len;
235
if (( HostName ) && ( SetFQDNHostName != FQDNdisable ))
237
/* Draft IETF DHC-FQDN option (81) */
238
*p++ = dhcpFQDNHostName;
239
*p++ = HostName_len + 3;
241
* S: 1 => Client requests Server to update A RR in DNS as well as PTR
242
* O: 1 => Server indicates to client that DNS has been updated regardless
243
* E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com"
244
* N: 1 => Client requests Server to not update DNS
246
*p++ = SetFQDNHostName & 0x9;
247
*p++ = 0; /* rcode1, response from DNS server to DHCP for PTR RR */
248
*p++ = 0; /* rcode2, response from DNS server to DHCP for A RR if S=1 */
249
memcpy(p,HostName,HostName_len);
254
/* build UDP/IP header */
255
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST,
256
htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage));
258
/*****************************************************************************/
259
void buildDhcpRenew(xid)
262
register unsigned char *p = DhcpMsgSend->options + 4;
263
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
264
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,DhcpIface.shaddr,ETH_ALEN);
265
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
266
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
268
DhcpMsgSend->op = DHCP_BOOTREQUEST;
269
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
270
DhcpMsgSend->hlen = ETH_ALEN;
271
DhcpMsgSend->xid = xid;
272
DhcpMsgSend->secs = htons(10);
274
DhcpMsgSend->flags = htons(BROADCAST_FLAG);
275
DhcpMsgSend->ciaddr = DhcpIface.ciaddr;
277
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
279
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
281
memcpy(DhcpMsgSend->options,&magic_cookie,4);
282
*p++ = dhcpMessageType;
285
*p++ = dhcpMaxMsgSize;
287
memcpy(p,&dhcpMsgSize,2);
290
if ( DhcpOptions.val[dhcpIPaddrLeaseTime] )
292
*p++ = dhcpIPaddrLeaseTime;
294
memcpy(p,DhcpOptions.val[dhcpIPaddrLeaseTime],4);
298
*p++ = dhcpParamRequest;
301
*p++ = routersOnSubnet;
307
*p++ = broadcastAddr;
308
*p++ = performMaskDiscovery;
309
*p++ = performRouterDiscovery;
311
*p++ = nisDomainName;
314
*p++ = dnsSearchPath;
315
/* FQDN option (81) replaces HostName option (12) if requested */
316
if (( HostName ) && ( SetFQDNHostName == FQDNdisable ))
320
memcpy(p,HostName,HostName_len);
323
*p++ = dhcpClassIdentifier;
324
*p++ = DhcpIface.class_len;
325
memcpy(p,DhcpIface.class_id,DhcpIface.class_len);
326
p += DhcpIface.class_len;
327
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
328
p += DhcpIface.client_len;
329
if (( HostName ) && ( SetFQDNHostName != FQDNdisable ))
331
/* Draft IETF DHC-FQDN option (81) */
332
*p++ = dhcpFQDNHostName;
333
*p++ = HostName_len + 3;
335
* S: 1 => Client requests Server to update A RR in DNS as well as PTR
336
* O: 1 => Server indicates to client that DNS has been updated regardless
337
* E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com"
338
* N: 1 => Client requests Server to not update DNS
340
*p++ = SetFQDNHostName & 0x9;
341
*p++ = 0; /* rcode1, response from DNS server to DHCP for PTR RR */
342
*p++ = 0; /* rcode2, response from DNS server to DHCP for A RR if S=1 */
343
memcpy(p,HostName,HostName_len);
348
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,
349
DhcpIface.ciaddr,DhcpIface.siaddr,
350
htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage));
352
/*****************************************************************************/
353
void buildDhcpRebind(xid)
356
register unsigned char *p = DhcpMsgSend->options + 4;
357
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
358
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,MAC_BCAST_ADDR,ETH_ALEN);
359
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
360
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
362
DhcpMsgSend->op = DHCP_BOOTREQUEST;
363
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
364
DhcpMsgSend->hlen = ETH_ALEN;
365
DhcpMsgSend->xid = xid;
366
DhcpMsgSend->secs = htons(10);
368
DhcpMsgSend->flags = htons(BROADCAST_FLAG);
369
DhcpMsgSend->ciaddr = DhcpIface.ciaddr;
371
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
373
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
375
memcpy(DhcpMsgSend->options,&magic_cookie,4);
376
*p++ = dhcpMessageType;
379
*p++ = dhcpMaxMsgSize;
381
memcpy(p,&dhcpMsgSize,2);
383
if ( DhcpOptions.val[dhcpIPaddrLeaseTime] )
385
*p++ = dhcpIPaddrLeaseTime;
387
memcpy(p,DhcpOptions.val[dhcpIPaddrLeaseTime],4);
390
*p++ = dhcpParamRequest;
393
*p++ = routersOnSubnet;
399
*p++ = broadcastAddr;
400
*p++ = performMaskDiscovery;
401
*p++ = performRouterDiscovery;
403
*p++ = nisDomainName;
406
*p++ = dnsSearchPath;
407
/* FQDN option (81) replaces HostName option (12) if requested */
408
if (( HostName ) && ( SetFQDNHostName == FQDNdisable ))
412
memcpy(p,HostName,HostName_len);
415
*p++ = dhcpClassIdentifier;
416
*p++ = DhcpIface.class_len;
417
memcpy(p,DhcpIface.class_id,DhcpIface.class_len);
418
p += DhcpIface.class_len;
419
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
420
p += DhcpIface.client_len;
421
if (( HostName ) && ( SetFQDNHostName != FQDNdisable ))
423
/* Draft IETF DHC-FQDN option (81) */
424
*p++ = dhcpFQDNHostName;
425
*p++ = HostName_len + 3;
427
* S: 1 => Client requests Server to update A RR in DNS as well as PTR
428
* O: 1 => Server indicates to client that DNS has been updated regardless
429
* E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com"
430
* N: 1 => Client requests Server to not update DNS
432
*p++ = SetFQDNHostName & 0x9;
433
*p++ = 0; /* rcode1, response from DNS server to DHCP for PTR RR */
434
*p++ = 0; /* rcode2, response from DNS server to DHCP for A RR if S=1 */
435
memcpy(p,HostName,HostName_len);
440
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,
441
DhcpIface.ciaddr,INADDR_BROADCAST,
442
htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage));
444
/*****************************************************************************/
445
void buildDhcpReboot(xid)
448
register unsigned char *p = DhcpMsgSend->options + 4;
450
/* build Ethernet header */
451
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
452
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,MAC_BCAST_ADDR,ETH_ALEN);
453
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
454
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
456
DhcpMsgSend->op = DHCP_BOOTREQUEST;
457
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
458
DhcpMsgSend->hlen = ETH_ALEN;
459
DhcpMsgSend->xid = xid;
460
DhcpMsgSend->secs = htons(10);
462
DhcpMsgSend->flags = htons(BROADCAST_FLAG);
464
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
466
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
468
memcpy(DhcpMsgSend->options,&magic_cookie,4);
470
*p++ = dhcpMessageType;
473
*p++ = dhcpMaxMsgSize;
475
memcpy(p,&dhcpMsgSize,2);
478
DhcpMsgSend->ciaddr = DhcpIface.ciaddr;
481
*p++ = dhcpRequestedIPaddr;
483
memcpy(p,&DhcpIface.ciaddr,4);
486
*p++ = dhcpIPaddrLeaseTime;
488
memcpy(p,&nleaseTime,4);
490
*p++ = dhcpParamRequest;
493
*p++ = routersOnSubnet;
499
*p++ = broadcastAddr;
500
*p++ = performMaskDiscovery;
501
*p++ = performRouterDiscovery;
503
*p++ = nisDomainName;
506
*p++ = dnsSearchPath;
507
/* FQDN option (81) replaces HostName option (12) if requested */
508
if (( HostName ) && ( SetFQDNHostName == FQDNdisable ))
512
memcpy(p,HostName,HostName_len);
515
*p++ = dhcpClassIdentifier;
516
*p++ = DhcpIface.class_len;
517
memcpy(p,DhcpIface.class_id,DhcpIface.class_len);
518
p += DhcpIface.class_len;
519
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
520
p += DhcpIface.client_len;
521
if (( HostName ) && ( SetFQDNHostName != FQDNdisable ))
523
/* Draft IETF DHC-FQDN option (81) */
524
*p++ = dhcpFQDNHostName;
525
*p++ = HostName_len + 3;
527
* S: 1 => Client requests Server to update A RR in DNS as well as PTR
528
* O: 1 => Server indicates to client that DNS has been updated regardless
529
* E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com"
530
* N: 1 => Client requests Server to not update DNS
532
*p++ = SetFQDNHostName & 0x9;
533
*p++ = 0; /* rcode1, response from DNS server to DHCP for PTR RR */
534
*p++ = 0; /* rcode2, response from DNS server to DHCP for A RR if S=1 */
535
memcpy(p,HostName,HostName_len);
540
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST,
541
htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage));
543
/*****************************************************************************/
544
void buildDhcpRelease(xid)
547
register unsigned char *p = DhcpMsgSend->options + 4;
548
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
549
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,DhcpIface.shaddr,ETH_ALEN);
550
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
551
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
553
DhcpMsgSend->op = DHCP_BOOTREQUEST;
554
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
555
DhcpMsgSend->hlen = ETH_ALEN;
556
DhcpMsgSend->xid = xid;
557
DhcpMsgSend->ciaddr = DhcpIface.ciaddr;
559
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
561
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
563
memcpy(DhcpMsgSend->options,&magic_cookie,4);
564
*p++ = dhcpMessageType;
567
*p++ = dhcpServerIdentifier;
569
memcpy(p,DhcpOptions.val[dhcpServerIdentifier],4);
571
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
572
p += DhcpIface.client_len;
575
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,DhcpIface.ciaddr,
576
DhcpIface.siaddr,htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),
577
sizeof(dhcpMessage));
579
/*****************************************************************************/
581
void buildDhcpDecline(xid)
584
register unsigned char *p = DhcpMsgSend->options + 4;
585
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
586
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,DhcpIface.shaddr,ETH_ALEN);
587
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
588
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
590
DhcpMsgSend->op = DHCP_BOOTREQUEST;
591
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
592
DhcpMsgSend->hlen = ETH_ALEN;
593
DhcpMsgSend->xid = xid;
595
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
597
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
599
memcpy(DhcpMsgSend->options,&magic_cookie,4);
600
*p++ = dhcpMessageType;
603
*p++ = dhcpServerIdentifier;
605
memcpy(p,DhcpOptions.val[dhcpServerIdentifier],4);
608
DhcpMsgSend->ciaddr = DhcpIface.ciaddr;
611
*p++ = dhcpRequestedIPaddr;
613
memcpy(p,&DhcpIface.ciaddr,4);
616
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
617
p += DhcpIface.client_len;
620
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,
621
DhcpIface.siaddr,htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),
622
sizeof(dhcpMessage));
625
/*****************************************************************************/
626
void buildDhcpInform(xid)
629
register unsigned char *p = DhcpMsgSend->options + 4;
631
memset(&UdpIpMsgSend,0,sizeof(udpipMessage));
632
memcpy(UdpIpMsgSend.ethhdr.ether_dhost,MAC_BCAST_ADDR,ETH_ALEN);
633
memcpy(UdpIpMsgSend.ethhdr.ether_shost,ClientHwAddr,ETH_ALEN);
634
UdpIpMsgSend.ethhdr.ether_type = htons(ETHERTYPE_IP);
636
DhcpMsgSend->op = DHCP_BOOTREQUEST;
637
DhcpMsgSend->htype = (TokenRingIf) ? ARPHRD_IEEE802_TR : ARPHRD_ETHER;
638
DhcpMsgSend->hlen = ETH_ALEN;
639
DhcpMsgSend->xid = xid;
640
DhcpMsgSend->secs = htons(10);
642
DhcpMsgSend->flags = htons(BROADCAST_FLAG);
644
memcpy(DhcpMsgSend->chaddr,DhcpIface.chaddr,ETH_ALEN);
646
memcpy(DhcpMsgSend->chaddr,ClientHwAddr,ETH_ALEN);
648
DhcpMsgSend->ciaddr = inform_ipaddr.s_addr;
649
memcpy(DhcpMsgSend->options,&magic_cookie,4);
650
*p++ = dhcpMessageType;
653
*p++ = dhcpMaxMsgSize;
655
memcpy(p,&dhcpMsgSize,2);
657
*p++ = dhcpParamRequest;
660
*p++ = routersOnSubnet;
666
*p++ = broadcastAddr;
667
*p++ = performMaskDiscovery;
668
*p++ = performRouterDiscovery;
670
*p++ = nisDomainName;
673
*p++ = dnsSearchPath;
674
/* FQDN option (81) replaces HostName option (12) if requested */
675
if (( HostName ) && ( SetFQDNHostName == FQDNdisable ))
679
memcpy(p,HostName,HostName_len);
682
*p++ = dhcpClassIdentifier;
683
*p++ = DhcpIface.class_len;
684
memcpy(p,DhcpIface.class_id,DhcpIface.class_len);
685
p += DhcpIface.class_len;
686
memcpy(p,DhcpIface.client_id,DhcpIface.client_len);
687
p += DhcpIface.client_len;
688
if (( HostName ) && ( SetFQDNHostName != FQDNdisable ))
690
/* Draft IETF DHC-FQDN option (81) */
691
*p++ = dhcpFQDNHostName;
692
*p++ = HostName_len + 3;
694
* S: 1 => Client requests Server to update A RR in DNS as well as PTR
695
* O: 1 => Server indicates to client that DNS has been updated regardless
696
* E: 1 => Name data is DNS format, i.e. <4>host<6>domain<4>com<0> not "host.domain.com"
697
* N: 1 => Client requests Server to not update DNS
699
*p++ = SetFQDNHostName & 0x9;
700
*p++ = 0; /* rcode1, response from DNS server to DHCP for PTR RR */
701
*p++ = 0; /* rcode2, response from DNS server to DHCP for A RR if S=1 */
702
memcpy(p,HostName,HostName_len);
707
udpipgen((udpiphdr *)UdpIpMsgSend.udpipmsg,0,INADDR_BROADCAST,
708
htons(DHCP_CLIENT_PORT),htons(DHCP_SERVER_PORT),sizeof(dhcpMessage));