summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
AgeCommit message (Collapse)Author
2011-12-10Tweak leases file handling.Kenneth R Westerback
1) Write out new leases file every time a lease is obtained. i.e. don't append 20 leases before cleaning it up. 2) Write new leases file after calling dhclient-script to implement new info. Gets interface configured first, and makes it more likely the leases file reflects most current configuration.
2011-05-11Make dhclient more friendly to sequential option processing byKenneth R Westerback
always starting DHCP packet options with DHO_DHCP_MESSAGE_TYPE. Now DHCP-specific options always come after the option identifying the packet as DHCP rather than BOOTP. Makes at least Nortel NetIP DHCP server happier. Clean up some code and parameter passing. Closes PR#6543, as confirmed by original submitter and patch tester Len Zaifman. Thanks! ok matthew@ (who hates the ISC-like code)
2011-04-17by default we ignore unknown dhcp server options, so don't botherPeter Hessler
warning unless we ask dhclient to reject leases with unknown options OK krw@ (this was lost in my tree for even longer)
2011-04-04Dump some useless calls to dhclient-script. i.e. MEDIUM, PREINIT,Kenneth R Westerback
ARPSEND, ARPCHECK. Drop support for 'media', 'medium' and 'alias' specifications in dhclient.conf. Old leases still parse but these options now have no effect. Be more polite and decline all offers we don't accept. Fix a IMSG length check. Many expressions of support at various bars. ok henning@ deraadt@ beck@
2011-03-27Fix interval handling. Start at initial_interval instead ofKenneth R Westerback
exponentially backed off initial_interval. Don't hallucinate that we can send ARP packets without waiting. Don't claim to be waiting for ARP packets when not doing so. Correctly detect expiry of selecting period. Speeds up negotiations. Tested on various dhcp servers by Martin Pelika, ian@, and David Coppa. And works at Starbucks and a mall for me.
2010-10-15Add and ignore DHCP option 66/0x42 TFTP server name.Jonathan Gray
ok krw@ phessler@
2010-09-24Make it possible to use "dhclient egress" to refetch a lease withoutClaudio Jeker
rememberingwhich interface dhclient was actually active on. Requested by deraadt, OK deraadt@, krw@
2010-06-26Whitespace.Kenneth R Westerback
2010-06-02Have dhclient obey the interface's rdomain, instead of doing routes onPeter Hessler
rdomain 0. OK krw@, claudio@ sharp stick prodding from claudio@
2010-03-25be more strict in check_option().Kevin Steves
ISC dhclient had a buffer overflow: http://www.kb.cert.org/vuls/id/410676 and while our dhclient is not vulnerable to that, it got us looking at how the subnet mask option is handled. this limits specific ip address options to length 4 in conformance with RFC 2132. discussion started by william@ and with input from krw@ ok krw@
2009-11-12Make sure we have enough space for the trailing \0 on prepend/appendJonathan Gray
of dhcp options. found by parfait. ok krw@
2009-07-19use addr_eq() where we can; ok krw@Kevin Steves
2009-06-12state_panic() tries the active then other valid leases by setting theKevin Steves
interface to each address and trying to ping the gateway. This will trigger an RTM_NEWADDR message. routehandler() only checks for the active and alias address in RTM_NEWADDR messages, so we can exit when state_panic() and the message address is on client->leases. routehandler() needs to also check client->leases. testing krw, 'I say commit' krw
2009-06-06Nuke debug() unless DEBUG is defined. Elminates debug output fromKenneth R Westerback
normal operations. Prodded by deraadt@ a while ago.
2009-06-03remove unneeded ARGSUSED; ok krw@ henning@Kevin Steves
2009-05-25log the reason before we die in routehandler(); ok krw@ henning@Kevin Steves
2009-05-20Do not fall back to using nobody if _user is missing, butThordur I. Bjornsson
error out. Add a new user _rwalld for rpc.rwalld, and use that instead of nobody, also unconditionally drop to _rwalld not only if rpc.rwalld was started with euid 0 (as root). ok deraadt@
2009-03-31claudio has spent too much time with the mbuf macros.David Gwynne
switch the rtsocket message filter specification so you can or the macros converting the routing socket message types into the mask used by the filter. ie: - ROUTE_SETFILTER(rtfilter, RTM_NEWADDR); - ROUTE_SETFILTER(rtfilter, RTM_DELADDR); - ROUTE_SETFILTER(rtfilter, RTM_IFINFO); - ROUTE_SETFILTER(rtfilter, RTM_IFANNOUNCE); + rtfilter = ROUTE_FILTER(RTM_NEWADDR) | ROUTE_FILTER(RTM_DELADDR) | + ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_IFANNOUNCE); there's a manpage change coming. ok claudio@
2009-03-10Add 6-byte MAC address to the log entries for DHCP ACK/NAK/OFFER.Kenneth R Westerback
Log the packets before checking the client state. Makes it easy to find MACs for 'surprise' DHCP servers. Positive comments from mbalmer@, jasper@.
2009-02-01Let this compile with gcc2.Miod Vallat
2009-01-28use claudios new rtsocket filters to restrict which messages on the routeDavid Gwynne
socket dhclient will get. ja ja claudio@
2009-01-10Use the kernel set ifam_hdrlen so that ABI changes won't cause olderClaudio Jeker
binaries to stop working. OK krw@, michele@, henning@, dlg@
2008-06-07stop spurious "got link" which nooone noticed, but everyone should have; ok krwTheo de Raadt
2008-05-26If an interface has no link at startup, try to force it up, and thenTheo de Raadt
give it about 4 seconds of (silent) grace period before doing the verbose search for a link... tested by various developers who got burned a bit
2008-05-09- don't give up when the link is not available on startup: dhclientReyk Floeter
goes to background and listens on the routing socket for link to come up before it retries. - renew the lease whenever the link was lost and becomes active again. - listen for link state changes on non-ethernet devices like wireless, the link state becomes active when the wireless has been associated to the AP and becomes active. this helps to automatically renew the lease when the user is roaming. ok beck@, deraadt@
2008-03-12Code was not passing script exit status; fix with macro.Hugh Graham
deraadt@ OK
2007-10-16sync the synopsis and usage of commandsIgor Sobrado
ok jmc@
2007-09-02use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsgTheo de Raadt
2007-08-14make default_lease_time a #define; ok krw@ henning@Kevin Steves
2007-07-18eliminate duplicate code to open lease file and just open atKevin Steves
startup; ok krw@ henning@
2007-06-02safer snprintf construct with more paranoid length calculationPeter Valchev
ok millert
2007-02-25No point in using zero'd fields in the parsed options. Use the optionsKenneth R Westerback
in the lease, whence the parsed info was moved. Fixes "Bogus servername" messages when processing an offer and stops bogus filename info from being stored in the lease. Found while testing a Tucson hotel's dhcp service. ok @stevesk "looks good" henning@.
2007-02-25remove unused/dangling prototypes and comment reference;Kevin Steves
from Mark Lumsden
2007-02-13move includes only needed in dhclient.c; ok henning@Kevin Steves
2007-02-13error check socket() return; ok henning@Kevin Steves
2007-01-29Don't malloc memory to store option data in leases, just appropriateKenneth R Westerback
the malloc'd memory from the parsed option buffer since it would be thrown away after the copy anyway. 'looks sane' millert@
2007-01-27We only poll on the bpf fd and the routing socket fd. No need forKenneth R Westerback
complex list code to keep track. So nuke it. Also eliminate unnecessary variable ('dead') that means 'rfdesc is closed'. Just set rfdesc to -1 when it is closed and use that. As suggested by millert@ and claudio@, don't bother setting revents members to zero since poll() does that. Np functional change, just less code. 'looks good' claudio@ 'I like where this is going' henning@
2007-01-25Cleanup some more code. Eliminate dhcp(), bootp(), parse_options() byKenneth R Westerback
moving the minimal code into do_packet(). Eliminate repeated code for checking the client hardware address and the reject list by putting those checks into do_packet as well. No functional change, just much easier to read. ok stevesk@
2007-01-16More cleanup. Eliminate 'struct packet' by cleverly passing asKenneth R Westerback
parameters just those things actually needed and using existing structs and information. No functional change. ok stevesk@
2007-01-11Since bootp_packet_handler is always set to do_packet before weKenneth R Westerback
process any packets, eliminate that abstraction and just call do_packet directly. No functional change. ok stevesk
2007-01-04Eliminate the 'len' parameter from send_packet() since it alwaysKenneth R Westerback
contains the global value client->packet_length. Use client->packet_length. No functional change. Suggested by stevesk@.
2007-01-04Another round of cleanup. There is only one instance of structKenneth R Westerback
dhcp_packet and it is contained in the global *client. So don't pass around pointers to a struct that contains a pointer to the dhcp_packet instance. Just use the global client->packet. Eliminate unused struct packet members and parameter lists accordingly. No functional change. Suggestions by stevesk@. ok stevesk@
2006-12-28please lintTheo de Raadt
2006-12-28parenthesis not needed here; consistent with usage in other areas.Kevin Steves
no binary change.
2006-12-28small knf (extra space, newline)Kevin Steves
2006-12-28no extra "\n" in note(); ok krw@ henning@Kevin Steves
2006-12-27Since we only have the single global struct interface_info, weKenneth R Westerback
obviously have single global struct client_state and struct client_config nested inside interface_info and client_state respectively. Pull them out to their own global variables and eliminate a bunch (i.e. hundreds) of multi-level dereferences. Make it much nicer to read. No functional change. "makes sense" henning@ Testing stevesk@, ok stevesk@
2006-12-26Our dhclient only handles one interface. Simplify code by using theKenneth R Westerback
single, global, instance of 'struct interface_info' (ifi) rather than passing around pointers to it. "I agree" henning@ Testing moritz@ stevesk@, ok stevesk@
2006-12-26There must be no alias address set, so check ifi->client->aliasMoritz Jodeit
for NULL before dereferencing it. OK henning@ krw@ deraadt@
2006-12-18this is clearer and consistent with other areas; ok henning@Kevin Steves