Documente Academic
Documente Profesional
Documente Cultură
Abstract
#
'
&"(
%)*+
&"(
, -
,'
'
#
%)*
. /*
('0
!1
2'
'
3
#
'
,1
31'
',-
'/
41
'
12,
1
#
'5
3
',
#'
'
-
(,' 3
.$
'
-
(,' 3
&
'
'
(,' 3
3
1
'
1
#'
'
'
3
3'
'
'/
1
41
-
,'
'
#',
1
Table of Contents
..................................................................................................................................... 1
Table of Contents ................................................................................................................................................... 2
1. DHCP Configuration Files ................................................................................................................................. 4
1.1. In Project Facility ........................................................................................................................................ 4
1.2. In Command Line........................................................................................................................................ 4
2. The DHCP Client ............................................................................................................................................... 4
2.1. Boot DHCP Client....................................................................................................................................... 4
2.2. Run time DHCP Client................................................................................................................................ 5
2.2.1. Command Line Build ........................................................................................................................... 5
2.2.2. Project Facility Build............................................................................................................................ 5
2.3. DHCP State Machine .................................................................................................................................. 6
2.3.1. DHCP Lease Negotiation.................................................................................................................... 6
2.3.2. DHCP Client Lease Selection .............................................................................................................. 6
2.3.3. DHCP Client Lease Renewal ............................................................................................................... 6
2.4. Miscellaneous DHCP Issues........................................................................................................................ 6
2.4.1. Adjusting Retransmission Times.......................................................................................................... 7
2.4.2. How Do I Change the DHCP Lease Interval?...................................................................................... 7
2.4.3. Using Boot Time DHCP (Command Line) ......................................................................................... 7
2.4.4. Why Does the DHCP Runtime Client Immediately Renew the Lease Acquired at Boot Time?......... 8
2.4.5. Why Can’t I Acquire an Address Dynamically When Booting Over a Non-Networked Device? ...... 8
2.4.6. Why is the DHCP Address Changing to a 10.0.x.x Address?.............................................................. 8
2.4.7. Specifying an IP Address at Lease Request Time................................................................................ 8
2.4.8. Incorporating Gateway Retrieval for DHCP for the boot ROM image................................................ 9
2.4.9. Why Does the boot ROM Have Its Own Version of DHCP? ............................................................ 10
2.4.10. What are the ARP Messages That I See Being Sent Out During Negotiation? ............................... 10
2.4.11.The DHCP Boot Client Does Not Process Incoming OFFER Packets When Using BSD Drivers .. 10
2.4.12. DHCP Event Hook ........................................................................................................................... 11
2.4.13. Avoiding the S_dhcpcLib_NOT_BOUND Error ............................................................................. 11
2.4.14. What Happens to Sockets that are Already Open When a DHCP Lease Expires or Renews? ........ 12
2.4.15. Why Does DHCP Begin a Full DHCP Negotiation Instead of Renewing the Lease? ..................... 12
2.4.16. The DHCP Client is not Detecting Renewals when the Lease is in RENEW or REBIND.............. 12
2.4.17. Restrictions on DHCP Packet Lengths (SPR #65264) Resulting in Dropped DHCP Offers........... 12
2.4.18. Why is the DHCP Client Sending INFORM Messages? ................................................................. 12
2.4.19. Timing issue after system tick rollover ............................................................................................ 12
2.4.20. At boot, DHCP client sends out extra ARP request in wait_offer state ........................................... 13
2.4.21. DHCP timeouts are incorrectly calculated after calls to clock_settime ........................................... 13
2.4.22. How long does the DHCP client wait for offers?............................................................................. 13
2.4.23 DHCP attempting to ARP on interfaces that have IFF_NOARP set in if_flags. .............................. 13
2.4.24. Why do RFC 1541 compliant DHCP servers respond only after the 5-th DHCPDISCOVER sent
out by a vxWorks DHCP client? .................................................................................................................. 13
2.4.25. No access to possible duplicate IP address....................................................................................... 13
#
3,
'
3
1
'
21,
3
'
,-
1
/,,
3,+
/target/src/config/1. /*
#define INCLUDE_DHCPC
#define INCLUDE_DHCPC_LEASE_GET
#define INCLUDE_DHCPC_LEASE_TEST
#define INCLUDE_DHCPC_LEASE_SAVE
right before
#include "configAll.h"
<$WIND_BASE>\target\config\<your_BSP>\make bootrom_uncmp.hex
71
'
21,
1
&"(
,
'
%)*
'
3
'
,
3
(5
6',
#include configAll.h
/*
;
/*
,
;
/*
','
;&"(
1
,
6
(&-
,
. /*
;
. /*
,'
;
&"(
;
&"(
1
,
71
/,,
'
31'
/
1
,1
&"(
,
(5
6',
#
'
*/
1
=(
>?@-
'
1
#
/*'1
'
A&"(
,
'
',B
2 ,
#
3
-
/
(5
6',
3
',,
1
)
(&+
/*
;
2'
/*
',C'
;
2 ,
;
&"(
'
',C'
;&"(
,
'
',
6
(&
+
. /*
;
. /*
,'
;&"(
;
'
',C'
;&"(
,
'
',
#
&"(
,
/,,
',/'
,'
33
/
,
,'
-
',
3
'
'
,
3
33
,'
'
'
-
,'
33
'
'
3
/,,
2
,
#
:=8 3';-
86,';@
',,
3',
3
'','2,
3
:
'
86,';
''
#H$
=1@-
',,
/'
1 ,
1
1-
1
$F
3
86,'
6 $-
' 1
'
*
'
1
1
',,
1
'
*-
',,
/,,
1
3',
, ,
6
3'
'21
$
"*-
,
&"(
$
"*
#
1
',
3
6
J
'
E
#
31,'
'
) ',
2'*33-
/
1,
1
In the VxWorks DHCP client, the period of time the client waits for offers after receiving the first offer from a server is the
value for offerTimeout in the function arguments.
&F%$9$#.
–
')1
12
3
'
3
&"(&F%$
'
1 ,
,
1
6##D$
–
'2,
3
'
3
&"(&F%$
#
12,
3
'
1241
'
1 ,
DK#D$
'
.#9#.!
–
'2,
3
3
'
2
,,
'
1,
,
#
3,
/
',,
'
/1,
1
'
'
'
=3
)',
'3
'
/
1 '@-
',,
'
'
'
'
'
'1
',1
6
'
'2,
,'-
,
'
41
'
/
'3
',3
1' -
'
1
,'
/1,
'1
3
/',
'
1
'
J
1
',
, ' ,-
'
1
33
,'
1'
'
3
'
3
'
',1
/
#
'
#
3
,'
'
'-
0
'
'
'2,1 ,
1''
'
3)
',
2 /
41 -
'
/,,
'
341 ,
3
,
3
/',
'
#
0
'
3
',
',
3
41
'
1
'
-
)
3
/
1
1
33
',1
'
1 ,
6
3'
#
1
&"(
,
'
2
-
,1
&"(
,
2
FD
'
$
#define INCLUDE_DHCPC
#include “configall.h”
#include “pc.h”
3
'
'
,-
'
3'1,
2
,
'
/,,
1
&"(
>3
&$6H #9:FF#9 .$
L
“3=-@
','' '++<#'< ' <3<( 1<3'1, <)*
M?E
3M)”
#
)
3,'
&"(
3,'
3
1
,1
&"(
,
2
'-
:FF#(
,
/,,
)1
'
' 1
21,
'
2.4.4. Why Does the DHCP Runtime Client Immediately Renew the Lease Acquired at
Boot Time?
#
2'
1
2'1
23
'
1
'
'
1, -
2,
'*
,'
2
'
2 '
,'
#
C
3
/,'
1
'
'
3
21
''
#
/',
3
'
'
'
,'
)
2.4.5. Why Can’t I Acquire an Address Dynamically When Booting Over a Non-
Networked Device?
#
/
2
1
&"(
'
2
'
/*
'
'
'
331,
#'
'
'
3
&"(
31 ',
=(
>?E?N@
3
/*
2
/*'1
)
3
#'
1-
21
1'
#'
-
'
2
,1
',
1
'
,'
'21
/*
'
3,
2'1
3
3)
=(
N
N@
/
'
/,,
2
'
)
,'
#
,
2
'
'
1
/
'1
'
3
1
'
1
'
%)*
&"(
-
/'
'*
',,
+
2.4.8. Incorporating Gateway Retrieval for DHCP for the boot ROM image
H
3
/
' /'
'
1
/
&"(
33
'
#
-
3
bootConfig.c. 6 -
31
struct ifnet *pIf; /* pointer to network interface data*/
char serverAddr [INET_ADDR_LEN]; /* DHCP server address*/
char bootFile [BOOT_FILE_LEN]; /* name of boot file*/
void * pCookie;
if (pBootDevAddr[0] == EOS)
{
/* Attempt to retrieve address information from a DHCP server.
6
,+
/*
• Fill in the target's IP address, if needed. The status
• variable indicates the source of the IP address as follows:
3,,/
'2
+
/* fill in gateway address */
if(pGateway [0] == EOS && routerAddress.s_addr != 0)
'
,
2
'=@
2 3+
if (params.gad[0] != EOS)
else
printf("Router's address: %s\n", params.gad);
}
2.4.9. Why Does the boot ROM Have Its Own Version of DHCP?
#
2
FD
1
'
/
3
&"(
2'1
/
/'
,-
/'
'
, '
2
FD
C
#
2
FD
3
&"(
,
2 '
'
,'
'
/',
2
3
,'
&1
1
-
''
&"(
(
2
1
'
3
&"(
2
,2'
(
',,
#
'
2
-
3
target/config/all/bootConfig.c.
2.4.10. What are the ARP Messages That I See Being Sent Out During Negotiation?
'
&"(
,'
'
3-
'
,
3
'
(
2
3
'
33
'
3
1
2
'
'
#
(
2
1
/
'
&"(
'
F66$
'
&"(
,
#
,
(
2''
'
/*
#
2
41
',
,1
'
3
'
' 1 1
(
'
3
2
'
#
/,,
'
/
&"(
/'
1
2 '
'
'
3
'
,
2'*
'
,
(
'-
'
'
'
3,
/*
#
' 1 1
(
'
1
,
'3
'
I
3
&"(
#
(
'
*
F66$
'
(
'
41
'
&"(
6
"/-
'
3' 1
,
&"(
,
#
' 1 1
(
'
'
3' 1
3
(
'*
3
1
/
-
1
/,,
'
'*
'
1
2.4.11.The DHCP Boot Client Does Not Process Incoming OFFER Packets When Using
BSD Drivers
(
>?
EE
)
#'
O
(
>NE
/
:*,
('*
6,
=:(6@
#
:(6
2,
3
' 1
'*
'
&"(
,
','
3
21
'
3
,
'
&"(
&F%$
'-
,
/
'
F66$-
'
,
F66$
#
(
/'
3)
#'
#/
'
1+
&"(9 $$9.$
'
&"(9 $$9.% &
#
&"(9 $$9.$
1
/
'
/
,'
131,,
'2,
#
&"(9 $$9.% &
'
'
''
3
,'
'
,
2
1
#
1
'
*
*
3,,/+
if (status != 0)
{
#ifdef DHCPC_DEBUG
logMsg ("Error configuring network. Shutting down.\n", 0, 0, 0, 0, 0, 0);
#endif
pLeaseData->leaseGood = FALSE;
}
else
{
pLeaseData->leaseGood = TRUE;
}
semGive (dhcpcMutexSem);
If you attempt to access DHCP API functions which assume a good lease is in effect, such as
dhcpcVerify(), dhcpcOptionGet(), dhcpcServerGet(), dhcpcTimerGet(), or dhcpcParamsGet() from
within the DHCP Event Hook, an error is returned: S_dhcpcLib_NOT_BOUND
#
*
)1
23
3
19'' =@
1
',
'
)1
'
'
,/
'
'
3
&"(
,
/,,
31'
3'
,,
1
'
&"(
,'
''
',
2 '
D1 )
1 )
'
#
'
1,
/,,
1''
',
)1
,'
/ 1
'
),
,'-
'
2,
3
'
/'
'1
'2
'/
'
/
'*
''-
1
!=@
/
*
,'
',
/
'
,
'
/
'*
'
'
,/
-
/,,
/
3'
,
2.4.14. What Happens to Sockets that are Already Open When a DHCP Lease Expires
or Renews?
F
*
'
'33 -
/
*
31
*
31
1
'
3
(
'
/,,
2
'2,
3
'
/
(
'
'
3
*
/
31
1
.&&9.7-
'
/
(
'
/,,
'33
*
-
)
3
2,
3',1
#
',,
','
/1,
'
',
1
3',1
2.4.15. Why Does DHCP Begin a Full DHCP Negotiation Instead of Renewing the
Lease?
#'
'
-
&"(
/',
3',
3
,*
'
'3
&"(
,
',C
=(>N
@
#
2,
1
2'1
&"(
,
',,
time() 31 -
/
1
,*
,'
3
2 -
' 1',
3
'
3
'
','
,*
' 1',
3
'-
/'
2,
'
33
2 /
',
,*
'
' 1',
3
'
/1,
3'
)
,'
#3-
&"(
,
2'
'
1
,'
'
)-
'
',C
,'
#
2,
1
,
#'
-
#'
'
2
'
#'
3
1
'
#'
-
'
'
3
(
>N
2.4.16. The DHCP Client is not Detecting Renewals when the Lease is in RENEW or
REBIND
#
&"(
,
'
'
21
#
'
*
3
I
'
'3
'
/',
'
2
41
#
2,
'
2
3)
#'
#
'
'','2,
3
3
(
>?EE
#
&"(
/,,
'
&"(I
,
'
P'0
3,
3
&"(.6FD
'
#
',1,'
'*
'1
*
,,
1-
'
2,
3
,'
2
/
'3
*
,,
*
'
E
2
-
/1,
'
',
(
N
3)
1
2.4.20. At boot, DHCP client sends out extra ARP request in wait_offer state
#9F66$
' -
1
'
&"(F66$-
,
1
'
(
41
#
'
3'
6
E
2,
41
1,
2
'
'
3
'
1,'
(
'
=
/
(
41
'/@
,
/,,
'
#9F66$
'
1 ,
1
'
'
,'
'
2
1
&"(&F%$
(
3)
1
-
&"(
,
*
'
'
2
/
'
,',,
/
,'-
'
'
3
.#
'
#'
3)
1
2.4.22. How long does the DHCP client wait for offers?
The collection time is configured by modifying DHCPC_OFFER_TIMEOUT.
Wind River implements DHCP according to RFC 2131. This RFC does not specify any time limit as for how
much should the client wait in the SELECING state for DHCPOFFER messages from servers. As such, in the
SELECTING state, the Wind River client code will stay until the collection time expires and the offer with the
longest lease is the one being selected.
SPR 99445 has been filed for an enhancement which will allow the DHCP client to pick the first offer arrived
and move right away into the REQUESTING state, without waiting for this timer to expire.
2.4.23 DHCP attempting to ARP on interfaces that have IFF_NOARP set in if_flags.
Since the requirement for checking duplicate IP addresses in RFC2131 is a SHOULD, not a MUST, it means it
is possible to run DHCP client on interfaces which do not support ARP. SPR 95666 has been filed for this
issue.
2.4.24. Why do RFC 1541 compliant DHCP servers respond only after the 5-th
DHCPDISCOVER sent out by a vxWorks DHCP client?
Our DHCP client is RFC 2131 compliant. That means it handles variable length option field. For backward
compatibility with servers which still implement RFC 1541 (that means fixed 312 byte length option field), we
provide a workaround: after 4 attempts of DHCPDISCOVER with variable length, we set dhcpOldFlag to
TRUE and we revert to the fixed size option field. SPR 95958 has been filed to make this option configurable.
According to RFC2131, once the client receives a DHCPACK from the server, it has to ARP on the IP address
just received. If it gets a response, it means the given IP address is already in use and the client must send a
DHCPDECLINE thus refusing the given IP address. vxWorks DHCP client does exactly that and is compliant
with RFC 2131. However, right now, there is no way for the user (that is the task calling dhcpcBind) to know
the reason why the lease negotiation failed, let alone know the value of the duplicate IP address. SPR 102116
has been filed as an enhancement to make the value of the duplicate IP available to the user.
3. DHCP Server
3.1. Configuration and Build
*
&"(
, -
&"(
'
2
31
'
'
,
/
5
3',
,1
&"(
(5
6',
+
6
',,
1
)
(&
/*
;
/*
','
;
&"(
6
(&
+
. /*
,'
;
&"(
;
&"(
:,/
'
3
/
'
,'
&"(
71
'
'
'',,
/
'
(
3,
#
'
3, -
usrNetDhcpsCfg.c:
DHCPS_LEASE_DESC dhcpsLeaseTbl [] = {
/*
Name Start IP End IP Parameters
------ -------- -----------------------
*/
/*
* Host requirements defaults needed for RFC compliance - DO NOT REMOVE!! */
#define INCLUDE_DHCPS
31
&"(
,'
1. /*
#
'2,
'
'
E
3
1
/
'
&"(
'2,
'3
1
'
' -
1+
dhcpsLeaseEntryAdd()
3.2. How Do I Specify a List of DNS Servers in the DHCP Lease Entry?
71
'
3
'
3
'
&.
'
,
3
(
'
''
2
/
'
'
'
+
H
3
1, ,
&.
+
H
3
'
,
&.
+
-> dhcpsLeaseEntryAdd (<...lease entry...>, "dnsv=205.214.51.16")
#
''
/
&.
-
J
%)*
&"(
41
3
'
:FF#(
, -
/,,
,
3
3,'
&"(
#
3,'
P',20
D(F#
##H
&"(9 $$9"FFI= -
'
Q-
@R
3
1
'
21,
3
'
,
'
'
(5
6', -
< ' <3<',,<3,,
'
3
3,,/+
>3
&"(9 $$9"FFI
@
$
'#2,ST
'
1
#
'2,
'
&"(
'
1
1
E@
'
'
"*
!1,
'
'
3
1
%)*
&"(
,
'
2 '
'
,'
3
)*
-
'
'2'
,,
1
'
1
1
'
/,,
',,
'
"*
1
#
*
'
'
',
,'
,'
1
'
/,,
',,
/
1
3
,'
*
#
/,,
2
'
1
3
'
2
'
71
'
',
'1',,
',,
11
dump_bind_db() 1
'
/,,
/
1
'
/
,'
3,-
3
'
'
',
,'
)
#
',
3
1
'
2
'
2
'51
!9.#$. -
3
' <<<
'
3'1,
',1
N
dhcpsAddressHookAdd (sampleAddressStorageHook)
The DHCP Server Address Hook will not work with statically configured entries. Use dhcpsEntryAdd() for entries that the hook will
access.
Changing the DHCP Configuration Will Not Appear on the DHCP Client Until a New Lease Is Negotiated.
#
&"(
,
',
,',
(
'
'
12
'*
'1 ' ',,
3
',1
3
8'1 3;
3,'
'
2'
/,,
'*
'
'
,
',1
&"(
3,-
,1
3'1,
' /'
'
#3-
&"(
,
/,,
'
'
3
'
&"(
33
'*
3.5. Additional Configuration for DHCP server if Relay Agents are used
3
&"(
1
1
,'
3
,
1'
33
12 -
1,
2
''2,
3
41
3
,'
' =@
-
3,,/
'
2
3,,
+
<Q
Q
3
&"(
/,,
'
3
,'
' -
Q
3,,/
'2,
1
2
3,,
2
1
Q<
&"(9$ 79&$
,'#2,
ST
M
<Q
(
'
3
'
12
.12
Q<
<Q
UV
JV-
V
VW-
Q<
U
.H -
.H
W
<Q
' -
1
2
,'
Q<
WR
#
(
'
3
'
3'
'
'
'
1
3
'
'
'
3
'
&"(
#
12
12
1,
'
/*
12
3
'
(
'
3
1
21,
3
5
3', -
' '
'
2
31
' <3<<< <1. &3
6
21,
3
'
,
'
2
31
#
1
',
#'
'
3
1
'
'
',
-
1
1
1'
#'
3
'
31
&"(
,'
usrNetDhcprCfg.c
. +
',
,
#'
D'*
'
/
3,+
1& ' =@
31 +
/* dhcprLibInit (); */
dhcprLibInit (DHCPS_MAX_MSGSIZE);
51
&"(
,'
'
'2,
usrNetDhcprCfg.c:
If you leave this table empty, the relay agent will not start.
DHCP_TARGET_DESC dhcpTargetTbl [] = {
/*
IP address of DHCP target servers
--------------------------------
*/
/* {"90.11.42.2"}, */
',C
',,
3'
1
1
,'
'
#
'
/
/'
',C
,'
$'
1 ,
2,/
D$#"F&
3,../target/config/comps/src/net/usrNetEndBoot.c, '
'
31
'
',C
3'
6
)',+
void addInterface(void)
ipAttach(1, “fei”);
Example:
.
.
netAttachFlag = TRUE;
printf ("Attached TCP/IP interface to %s unit %d\n", pDevName, unitNum);
addInterface();
#endif /* INCLUDE_END */
return;
../target/comps/src/net/usrNetDhcprCfg.c:
Modify
'
3+
dhcprInit()
+
devlist[1] = ifunit ("fei1");
3
%)*
'
/,,
2
'
,'
'
'
1 -
'
12
3
'
,'
'
',C
3
1
'
/*
'
,
12 -
,'
'
/,,
'
'
'
,
3'
#
)',
/
/
3'
'
3
+
network components ->networking protocols -> network applications -> DHCP relay agent
D$#"F&
Make all the changes in usrNetDhcprCfg.c:
ipAttach(1, "fei");
usrNetIfConfig("fei", 1, "10.1.1.20", "private", 0xffffff00);
devlist[1] = ifunit ("fei1");
'
12
3
',C
3
/
/* dhcprResult=dhcprInit (devlist, 1, dhcpTargetTbl, dhcpTargetTblSize);*/
dhcprResult = dhcprInit (devlist, 2, dhcpTargetTbl, dhcpTargetTblSize);
'
'
/
3
3,
2'
' <3<<)*< /*3
.'
3,
50network.cdf. '
50network.cdf 3,
3
,'
'
../target/comps/src/net/50network.cdf
&"(9DK9D!Y$
6!9(D
',,
3,
60network.cdf
Component INCLUDE_DHCPR
{
NAME DHCP relay agent
CFG_PARAMS DHCPS_SPORT DHCPS_CPORT \
DHCP_MAX_HOPS DHCPS_MAX_MSGSIZE
REQUIRES INCLUDE_NET_SETUP
HDR_FILES ioLib.h
}
D'*
1
'
3,,/
''
3
Parameter DHCPS_MAX_MSGSIZE
{
NAME DHCP Server/Relay Agent Maximum Message
DEFAULT 590
TYPE uint
}
'
dhcpsRelayTbl[]. #
'2,
usrNetDhcpsCfg.c
DHCPS_RELAY_DESC dhcpsRelayTbl [] =
{
/*
IP address of agent Subnet Number
----------------------- -----------------
*/
{"10.1.1.20", “10.1.1.0"} };
#
(
'
3
'
3'
'
'
'
1
3
'
'
'
3
'
&"(
#
12
12
1,
'
/*
12
3
'
(
'
/*
; /*
,
;
/*
','
;
&"(
,'
'
6
(&
+
. /*
,'
;
&"(
;
&"(
,'
'
ipAttach(1, "fei");
usrNetIfConfig("fei", 1, "10.1.1.20", "private", 0xffffff00);
devlist[1] = ifunit ("fei1");
'
12
3
',C
3
/
/* dhcprResult=dhcprInit (devlist, 1, dhcpTargetTbl, dhcpTargetTblSize); */ dhcprResult =
dhcprInit (devlist, 2, dhcpTargetTbl, dhcpTargetTblSize);
#
',
#'
,
1
'
1
#'
-
,'
E
51
,2'
',C'
1. /*
'
3,,/+
/* dhcprLibInit (); */
dhcprLibInit (DHCPS_MAX_MSGSIZE);
./
1,'
,'
'
'2,-
dhcpTargetTbl[]. #
dhcpTargetTbl[] /,,
'
&"(
(
'
3
'
/,,
,'
'
'
,'
'
#
&"(
,'
#'
#'2,
usrNetwork.c
If you leave this table empty, the relay agent will not start.
DHCP_TARGET_DESC dhcpTargetTbl [] =
{
/*
IP address of DHCP target servers --
------------------------------*/
/* {"90.11.42.2"}, */
{"147.11.38.50"} /* DHCP Server address */ };
'
dhcpsRelayTbl[]. #
'2,
usrNetwork.c
DHCPS_RELAY_DESC dhcpsRelayTbl [] =
{
/*
IP address of agent Subnet Number
----------------------- -----------------
*/
{"10.1.1.20", “10.1.1.0"} };
#
(
'
3
'
3'
'
'
'
1
3
'
'
'
3
'
&"(
#
12
12
1,
'
/*
12
3
'
(
'
31
&"(
/
'
1
/
21 +
DHCPS_LEASE_DESC dhcpsLeaseTbl [] = {
/*
Name Start IP End IP Parameters
---- ------- ------- ----------
* see man pages
* (timers, bootfile,
etc.) */
#
'2
'
'
1
=
&"(
,'
'
(
'
/*@
/
?J
'
' /'
#
1 1
3
(''/
,
'3
,'
/'
2 '+
->dhcpcParamsShow
5. BOOTP in VxWorks
#
: '
( ,
=:FF#(@
/'
'
1
3
&"(
:FF#(
,
41
3'
3
'
:FF#(
#
:FF#(
*
,
3'
/
' '2'
F
' '2'
D
'
3
,
'
'
'
3,'
,
'
#
3,'
P3,0
3,-
'
/,,
3
/
3,
,'
#
:FF#(
,
'
2
*
'
2
'
1
#
'
:FF#(
'
#'
'
#'
-
1
2 D=@1
#
'
:FF#(
'
#'
1
2 D! =@
1
/
2
'
'
'
'
1
(
3
#
2 3
3,
31'
1,
3
2
FD
#
2 3
3,
8Z.&9:$;,L ' L3L',,
5.1. Incorporating Gateway Retrieval for BOOTP for boot ROM and
Runtime Images
*
&"(-
:FF#(
'1 ' ',,
' /'
'
1
/
'
:FF#(
41
1
& ',
1+
'
'
' /'
/,,
2
'
3'1,
1
=@
'@
$
bootConfig.c
' /'
3
2
FD
'
2@
3
1
'
21,
3
'
,-
/target/src/config/usrNetwork.c
@
3
1
'
21,
/
(5
6', -
/target/config/comps/src/net/usrNetRemoteCfg.c
*/
if (sysBootParams.gad[0] != EOS)
{
inet_netof_string (sysBootParams.had, nad);
routeAdd (nad, sysBootParams.gad);
}
For example:
'
'
M
?
+333333
'
M
?
'
' /'
M
?J
#
/1,
'
'
1
'
FH#$
.$#
#: $
147.11.48.0
147.11.41.254 147.11.41.0
147.11.41.198
3
1
'
' /'
'
'
3'1,
1
-
3,,/
'
'
'+
if (sysBootParams.gad[0] != EOS)
{
/* Extract the network address in dot notation */
inet_netof_string (sysBootParams.had, nad); /* for host address */
inet_netof_string (sysBootParams.gad, ngad);
/* for gateway address */
/* gateway and host are on same subnet */
if (strcmp(nad, ngad) == 0)
{
/* Add default route */
if (routeAdd ("0.0.0.0", sysBootParams.gad) == ERROR)
printf("Error adding default route: ");
}
else
{
/* Add network route */
if (routeAdd (nad, sysBootParams.gad) == ERROR)
printf("Error setting route to host ");
}
}
/
'
'
ST
'
2
'
'1 '
''2,
Change bootConfig.c to retrieve gateway parameter and store it so that it will be retrieved by the runtime
image.
'
'
3
bootpGet()
,1
' /'
'' +
LOCAL STATUS bootpGet (char *netDev, char *pBootDevAddr,
2
('
'''
'
' /'
''
/,,
2
3,,/
2 ! =@+
/************************************************************************
*
* bootpGet - get network parameters via BOOTP.
*
* RETURNS: OK if successful otherwise ERROR
*/
6#$
printf ("Getting boot parameters via network interface %s, pNetDev);
return (ERROR);
&&+
if (pGateway [0] == EOS) /* fill in subnet gateway */
{
inet_ntoa_b(gateway, pGateway);
printf (" Subnet gateway: %s ", pGateway);
This is an issue in Tornado 2.2.1. If an interface number other than 0 is used and there is no interface 0
defined (e.g. fei1, but there is no fei0), using bootpMsgGet() will return error with the errno set to
S_bootpLib_BAD_DEVICE. SPR 94241 fixes this problem.
6
3'
'21
:FF#(-
%)*
3
D'1',
3
2 2
< /
: 2 3'
3
,
&"(
1
1
2
2 '
,2'
1
2 1
'
&"(
,
/ &"(
/
1
2 &"(
,'
'
1
2 &"(
1
<
,' 1
'*
'
1
3
,'
'
'
'
31'
:
2
,2'
' ,
'
'
1
:FH.&
'
dhcpcRuntime.c - '
)',
3
/
1
:=@
2 '
'
,'
,
,1
'
)',
3
/
&"(
,'
dhcpLoop.c - 1',,
&F%$
'*
1 ,
'
,
'
*
1'
dhcpsSampleHook.c - )',
3
'
&"(
,'
'
*
1
+
+<<///2 ''<12<333'4 ,
'33
3
3
3,,/
'
3' +
7.1.1. Ethereal
#
'
2'
1-
21
'
!H
+<</// ',<
71
'
1
',
2
H)
'
/
'
7.1.2. tcpdump
#
,
'
/ '
'
6
3
'
1
'
1
1
'
71
'
3
'33
2'
D
'
3
&"(
,
'
3
1
0
*/
3
1
'
1
'','2,
-
*
/
1
' '
7.1.3. snoop
'
1 ,
3
1
,'
'
#
1
'33
3
'
2'
3'
#
2'1
2
'
2
3
'
'','2,
71
1
2
'
,
1
"0
'
)',+
%snoop -o outputFile 147.11.38.89
3,-
1 1 6,-
'
#'
3,
''2,
'
6
'
1 1 +
%snoop -i outputFile > outputFile.txt
6
'
2
1 1 -
,1
'*
3' +
Save the traces in the available binary format, rather than sending large text files.
3
1
'
1
-
'
1
'-
'
3
3,,/
3,'
+
3
3
3,'-
1
/,,
21
1 1
'
'
3
1
/1,
,*
21
'-
21
0
'
1
-
'
41
,
25
'
,1
21
'
3
3
3,'-
1
/,,
,
'
'
3,,/
&"(
'
'
/**************************************************************************** *
* THIS CODE IS NOT SUPPORTED CODE. IT IS PROVIDED ON AN AS-IS BASIS.
* ***************************************************************************** */
/*
modification history
--------------------
/*
DESCRIPTION
This file contains routine to get a DHCP lease after booting with a static IP address
NOMANUAL
*/
#include "vxWorks.h"
#include <ioctl.h>
#include <inetLib.h>
#include "dhcp/dhcpcInit.h"
#include "dhcp/dhcpcCommonLib.h"
#include "dhcpcLib.h"
#include "bootLib.h"
#include "stdio.h"
#include "netinet/if_ether.h"
#include "ifLib.h"
#define MAX_LEASES 10
#define SERVER_PORT 67
#define CLIENT_PORT 68
#define OFFER_TIMEOUT 5
/* #define OFFER_TIMEOUT 5 change to test */
#define DEFAULT_LEASE 3600
#define MINIMUM_LEASE 30
#define MAX_SIZE 576
/* Uncomment the following if you want event hook routine and/or cache hook routine */
/* #define DHCP_EVENT_HOOK_PRESENT */
/* #define DHCP_CACHE_HOOK_PRESENT */
/* prototypes */
#ifdef DHCP_EVENT_HOOK_PRESENT
void myEventHook(int event, void *cookie);
#endif
#ifdef DHCP_CACHE_HOOK_PRESENT
STATUS myCacheHookRtn(int command, unsigned long *pTimeStamp, int *pDataLen, char *pBuffer);
#endif
/* global */
void *pDhcpcRuntimeCookie;
LEASE_DATA *pLeaseData;
/****************************************************************************
*
* ifEtherPrint - print Ethernet address in ":" notation
*
* RETURNS: N/A
*/
char dhcpServerAddr[INET_ADDR_LEN];
char dnsServerAddr[INET_ADDR_LEN];
char targetAddr[INET_ADDR_LEN];
char gatewayAddr[INET_ADDR_LEN];
int netMask = 0;
u_char etherAddress[7];
etherAddress[0] = 0x1;
if ((dhcpcLibInit(SERVER_PORT, CLIENT_PORT, \
MAX_LEASES, MAX_SIZE, OFFER_TIMEOUT, \
DEFAULT_LEASE, MINIMUM_LEASE) == ERROR))
{
printf("\ndhcpLibInit failed!"); return ERROR;
}
*/
/* If dhcpcLibInit was called at boot time, dhcpcInputHook was added to boot device.
* If this code is run for additional interfaces, dhcpcInputHook must be
* added to that device as well. etherInputHookAdd checks for duplicate hook routines. */
/*
" Initialize required variables and get the lease identifier.
" The resulting lease will always apply the address information
o to the specified network interface. */
#ifdef DHCP_CACHE_HOOK_PRESENT
dhcpcCacheHookAdd(myCacheHookRtn);
#endif
#ifdef DHCP_EVENT_HOOK_PRESENT
if(dhcpcEventHookAdd(pDhcpcRuntimeCookie,myEventHook) == ERROR)
{
printf("\n dhcpcEventHookAdd error \n");
return;
}
#endif
/* Set the lease descriptor. Interface will be initialized with lease values. */
pLeaseData->leaseType = DHCP_AUTOMATIC;
/* Set ROUTER_TAG */
routerStruct.num = 1;
routerStruct.addr = &routerAddress;
dhcpParameters.router = &routerStruct;
/* To make this call, set up the etherAddress array above as the MAC address*/
if (dnsAddress.s_addr != 0)
{
inet_ntoa_b (dnsAddress, dnsServerAddr);
printf("DNS Server's address = %s\n", dnsServerAddr);
}
/* Auto flag will cause the interface to go down after the lease is
* relinquished, so wait for that to happen....
*/
if ( isAuto )
{
/* wait for interface to shut down */
do
{
taskDelay( 1 );
ioctl (sockfd, SIOCGIFFLAGS, (int) (caddr_t) &ridreq);
} while( ridreq.ifr_flags & IFF_UP);
}
mRouteShow();
routeDelete( "10.0.0.0", newIpAddress );
ifMaskSet( ridreq.ifr_name, newSubnetMask );
ifAddrSet( ridreq.ifr_name, newIpAddress );
mRouteShow();
/* bcastAddr = inet_ntoa( ( inet_addr(newIpAddress) & newSubnetMask ) | ~newSubnetMask );
ifBroadcastSet( ridreq.ifr_name, bcastAddr ); */
ioctl (sockfd, SIOCGIFFLAGS, (int) (caddr_t) &ridreq);
if ( ! (ridreq.ifr_flags & IFF_UP ) )
{
ridreq.ifr_flags |= IFF_UP;
ioctl (sockfd, SIOCSIFFLAGS, (int) (caddr_t) &ridreq);
}
close (sockfd);
if(!isAuto)
{
flushroutes ();
}
routeAdd( "0.0.0.0", defaultRoute );
}
#ifdef DHCP_EVENT_HOOK_PRESENT
/* dhcp event hook : */
void myEventHook(int event, void *cookie)
{
switch (event)
{
case DHCPC_LEASE_NEW:
printf("got lease new!\n");
break;
case DHCPC_LEASE_INVALID:
printf("got lease invalid!\n");
break;
default:
printf("got unknown!\n");
break;
}
}
#endif
#ifdef DHCP_CACHE_HOOK_PRESENT
STATUS myCacheHookRtn
(
int command, /* requested cache operation */
unsigned long *pTimeStamp, /* lease timestamp data */
int *pDataLen, /* length of data to access */
char *pBuffer /* pointer to data buffer */
)
{
switch (command)
{
case DHCP_CACHE_WRITE: printf("\n DHCP_CACHE_WRITE \n");
printf("\n timestamp = %lu \n", *pTimeStamp);
printf("\n data buffer is %s \n", pBuffer);
/* your code to write the cache record */
break;
case DHCP_CACHE_READ: printf("\n DHCP_CACHE_READ %d \n", command);
printf("\n timestamp = %lu \n", *pTimeStamp);
printf("\n data buffer is %s \n", pBuffer);
/* your code to read record from cache */
break;
/****************************************************************************
*
* THIS CODE IS NOT SUPPORTED CODE. IT IS PROVIDED ON AN AS-IS BASIS.
* *****************************************************************************
*/
/*
modification history
-------------------
01oct04, nk make interface an input parameter
01a,06jul01, ds routine to repeatedly send DHCP packets
*/
/* DESCRIPTION
This file contains three routines:
1. sysDhcpIpConfig(): a routine that initializes DHCP, then calls getIP()
2. getIP(): A routine that sends DHCP discover packets until a server replies.
3. dhcpEventHookRoutine(): A callback routine to notify users when a DHCP event occurs.
*/
#include <vxWorks.h>
#include "dhcp/dhcpc.h"
#include "dhcpcLib.h"
#include "dhcp/dhcpcCommonLib.h"
#include "dhcp/dhcpcInit.h"
/* Define values for the DHCP*/
#define DHCPC_MAX_LEASES 10
#define MAX_SIZE 576
#define DHCPC_SPORT 67
#define DHCPC_CPORT 68
#define DHCPC_OFFER_TIMEOUT 5
#define DHCPC_DEFAULT_LEASE 3600
#define DHCPC_MIN_LEASE 30
/* Global variable */
strcpy(ifName, interface);
if(dhcpcLibInit(DHCPC_SPORT, DHCPC_CPORT, DHCPC_MAX_LEASES, MAX_SIZE,
DHCPC_OFFER_TIMEOUT, DHCPC_DEFAULT_LEASE, DHCPC_MIN_LEASE) ==
ERROR)
{
printf("sysDhcpIpConfig: dhcpcLibInit\n");
return ERROR;
}
pIf = ifunit(ifName);
if (pIf == NULL)
{
pDhcpcBootCookie = dhcpcInit(pIf,TRUE);
if(pDhcpcBootCookie == NULL)
{
printf("sysDhcpIpConfig: unable to setup lease\n");
return ERROR;
}
if(getIP(pIf) != OK)
{
printf("Unable to start DHCP process.\n");
return ERROR;
}
return(OK);
i = ERROR;
printf("Starting DHCP process...\n");
/* Start DHCP process */
while(i != OK)
if((i = dhcpcBind(pDhcpcBootCookie, TRUE))!=OK)
printf("sysDhcpIpConfig: Unable to bind to the dhcpserver.\n");
printf("Bind was successful.\n");
case DHCPC_LEASE_INVALID :
/* this case gets called when the client gives up... */
printf(" DHCPC_LEASE_INVALID \n ");
break;
default:
printf(" leaseEvent = %d \n ", leaseEvent );
break;
}
}
/************************************************************************
#include “copyright_wrs.h”
/*
DESCRIPTION
This code demonstrates one possible method of implementing the permanent
storage needed by the DHCP server. It uses an ATA device and a DOS file
system which spans the full device.
*/
#include “vxWorks.h”
#include “dosFsLib.h”
#include “ioLib.h”
#include <drv/hdisk/ataDrv.h>
extern usrFdiskPartRead;
extern ataDiskInit(void *);
BLK_DEV *pBlkDev0;
void *blk_device, *pCbio, *cbio1;
/*
*scsi related code
SCSI_PHYS_DEV * pPhysDev;
BLK_DEV * pBlkDev;
DOS_VOL_DESC * pVolDesc;
DOS_VOL_CONFIG configStruct; */
int myWriteDesc;
int myReadDesc;
STATUS sampleLeaseStorageHook
(
int op, /* lease operation */
char *recData, /* record of active lease */
int dataLen /* length of record data */
)
{
int result;
int offset; int length; char delim;
char buffer [10];
switch (op)
{
case DHCPS_STORAGE_START:
printf(“Calling cbioLibInit()\n”);
cbioLibInit();
printf(“Calling dosFsLibInit()\n”);
dosFsLibInit(20);
printf(“Calling dosFsFatInit()\n”);
dosFsFatInit();
printf(“Calling dosFsFmtLibInit()\n”);
dosFsFmtLibInit();
printf(“Calling dosVDirLibInit()\n”);
dosVDirLibInit();
printf(“Calling dosChkLibInit()\n”);
dosChkLibInit();
printf(“Calling ataDevCreate()\n”);
blk_device = ataDevCreate(0,0,0,0);
printf(“Calling dcacheDevCreate()\n”);
pCbio = dcacheDevCreate(blk_device, 0, 0, “/ata0/”);
printf(“Calling dpartDevCreate()\n”);
cbio1 = dpartDevCreate( pCbio, 1, usrFdiskPartRead );
printf(“Calling dosFsDevCreate(a)\n”);
dosFsDevCreate(“/sd0a”, dpartPartGet(cbio1,0), 0, 0 );
pBlkDev0 = ataDevCreate(0,0,0,0);
ataDiskInit(pBlkDev0);
dosFsConfigShow();
/*
pVolDesc = dosFsDevInit(“/sd0a”, pBlkDev, &configStruct);
if (pVolDesc == NULL)
return (ERROR);
myFsInit = TRUE;
}
if (myFileInit == FALSE)
if (myWriteDesc == ERROR)
return (ERROR);
myReadDesc = open (“/sd0a/leases.dat”, O_RDONLY, 0);
if (myReadDesc == ERROR)
return (ERROR);
myFileInit = TRUE;
}
break;
case DHCPS_STORAGE_WRITE:
printf (“WRITE message\n”);
/* Store active leases. Return ERROR if START operation failed. */
/*
* Force write to file - each operation must be independent,
* so can’t rely on close() call in the DHCPS_STORAGE_STOP code. */
if (result == ERROR) r
return (ERROR);
if (result != length)
return (ERROR);
break;
case DHCPS_STORAGE_CLEAR:
printf (“CLEAR message\n”);
myFileInit = FALSE;
endOfData = TRUE;
close (myWriteDesc);
close (myReadDesc);
myFileInit = TRUE;
break;
case DHCPS_STORAGE_STOP:
printf (“STOP message\n”);
myFileInit = FALSE;
endOfData = FALSE;
close (myWriteDesc);
close (myReadDesc);
break;
default:
printf (“bogus message\n”);
break;
}
return (OK);