Discussion:
On DHCP client bind
(too old to reply)
Jiang zhou
2003-11-24 07:32:33 UTC
Permalink
Hi,all

I want to get a IP address from DHCP server when the vxworks startup. The
vxworks is saved in flash.
In usrAppInit function, I start the net driver, get the IP address from DHCP
server and config this IP address to the net interface. The get IP address
code come from the docs.

pIf = ifunit ("secEnd0"); /* Access network device. */
/* Initialize lease variables for automatic configuration. */
pLeaseCookie = dhcpcInit (pIf, TRUE); /*or FALSE when I config a another ip
address for debug this DHCP function*/
if (pLeaseCookie == NULL)
return (ERROR);
/* Set any lease options here. */
dhcpcOptionAdd (pLeaseCookie, _DHCP_LEASE_TIME_TAG, 4, 1800);
result = dhcpcBind (pLeaseCookie, TURE);
if (result != OK)
return (ERROR); /*Here I get error result and return*/

But I find the DHCP has release the ip address for this request.
I have used dhcpcEventHookAdd to add a hook and use Asynchronous stlye by
set FALSE in bind call. In the hook function, I get a error message when
I get information from this cookie. The error message is no_bind.

Can someone tell me why? I have read a post in this newsgroup, but there is
no help on this.

More when I build the vxworks image, it ocurs conflict when I add DHCPV4
runtime client component. the conflict componets are BOOTP client, DHCP
client timestamp setup and removal. I have remove all of them when I build
the this test vxworks image.

Thank you
Bill Pringlemeir
2003-11-24 15:52:51 UTC
Permalink
Post by Jiang zhou
I want to get a IP address from DHCP server when the vxworks
startup. The vxworks is saved in flash. In usrAppInit function, I
start the net driver, get the IP address from DHCP server and config
this IP address to the net interface. The get IP address code come
from the docs.
There are several bug with the DHCP client on vxWorks. I am not sure
the exact version that you are using. I would guess vxWorks 5.5?
Anyways, you should check WindSurf for details. Older vxWorks
versions will not work with newer RFC sized packets. There are post
here on the same issue.

I suggest you get a sniffer and examine the network
packets. "http://analyzer.polito.it/" for example. The normal
sequence is a DHCPDISCOVER from vxWorks, a DHCPOFFER from the server,
a DHCPREQUEST from vxWorks and a DHCPACK from the sever.

These sequences are typically done when the "dhcpcBind()" function is
called. You might try adding the cookies,

DHCPC_OPTION_SET(cookie,_DHCP_SUBNET_MASK_TAG);
DHCPC_OPTION_SET(cookie,_DHCP_ROUTER_TAG);
DHCPC_OPTION_SET(cookie,_DHCP_DNS_SERVER_TAG);

When sniffing, look at the packet sizes (308, 556?). Also, some
servers only put the IP address in the DHCP options as a tag. vxWorks
expects the offered server to put IP addresses in the "your address"
and "server address" fields. If it is only in the TAG section, this
might cause a problem. (actually the DHCP code is from the WIDE
project afaik. Try google on "dhcp wide").

It would probably be most helpful if you detailed what the DHCP server
was before asking more questions as well.

Here is a "good trace".

IP: 0.0.0.0 => 255.255.255.255 (576) | UDP: DHCP: Discover
IP: 192.168.123.254 => 255.255.255.255 (328) | UDP: DHCP: Offer
ARP: Hardware type= 1, Protocol Type = IP (0800h) | ARP Request
IP: 0.0.0.0 => 255.255.255.255 (576) | UDP: DHCP: Request
IP: 192.168.123.254 => 255.255.255.255 (328) | UDP: DHCP: Ack
ARP: Hardware type= 1, Protocol Type = IP (0800h)
ARP: Hardware type= 1, Protocol Type = IP (0800h)

The ARPs are important. If a DHCP server is giving out addresses that
are already on the network, the ARPs check for a duplicate and the
stack should refuse to use that address.

fwiw,
Bill Pringlmeeir.
--
A mind that is stretched to a new idea never returns to its original
dimension - Anonymous
Continue reading on narkive:
Loading...