contrib: DHCP network monitor and fallback from DHCP to static address
Arnout Vandecappelle
arnout at mind.be
Mon Apr 28 08:33:41 UTC 2008
Hoi,
My colleague Maarten and I have developed an extension to the DHCP
client which allows monitoring the network interface and restarting DHCP
when the network changes.
First, some changes to rtems_dhcp.c and bootpc_subr.c are required.
These are contained in the attached patch, as well as a Changelog entry
for them. Changes include
- all panic() calls in bootpc_subr.c and rtems_dhcp.c are replaced by
printf()'s and return -1;
- bootpc_call() times out;
- rtems_bsdnet_do_dhcp() has an infinite loop over dhcp_init(), to
conserve the old behaviour;
- added rtems_bsdnet_do_dhcp_timeout() (to allow time-out of DHCP) and
rtems_bsdnet_dhcp_down() (to allow stopping the lease renewal task);
- removed a debugging printf in bootpc_init();
- corrected the cast in rtems_bsdnet_ifconfig() for SIOCDIFADDR.
If any of these changes are not acceptable, I can reproduce a patch
without that particular change.
These changes have been tested on an in-house board using an ARM
processor and RTEMS 4.6.99. The patch is against the CVS, but has not
been tested with the CVS version. However, I don't expect problems as
not much has changed in libnetworking (except for K&R -> C90 declarations).
Second, we developed a network monitoring task with the following
functionalities:
* start DHCP, and use static configuration if it fails;
* restart DHCP when the network cable is removed and reconnected;
* bring an interface down when the cable is removed.
It is designed as a replacement for rtems_bsdnet_do_dhcp. The code is
in rtems_dhcp_failsafe.c, the declaration in rtems_dhcp_failsafe.h. The
source file contains documentation.
It is implemented as a user-space task, i.e. it doesn't require access
to the kernel functions and variables. However, in our own RTEMS
version we put it in the cpukit/libnetworking/rtems/ directory and added
the declaration to dhcp.h.
If this code is not included in the RTEMS distribution, I can find a
place on the Wiki to post it.
Regards,
Arnout
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286540
Mind Embedded Development (an Essensium division)
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Changelog
URL: <http://lists.rtems.org/pipermail/users/attachments/20080428/e348f4a7/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-dhcp
URL: <http://lists.rtems.org/pipermail/users/attachments/20080428/e348f4a7/attachment-0001.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtems_dhcp_failsafe.c
Type: text/x-csrc
Size: 11514 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20080428/e348f4a7/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtems_dhcp_failsafe.h
Type: text/x-chdr
Size: 483 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/users/attachments/20080428/e348f4a7/attachment-0001.bin>
More information about the users
mailing list