Commit Graph

154 Commits

Author SHA1 Message Date
Roy Marples
70207f79e9 setting signals should require an explicit len rather than NULL termination. 2015-05-12 23:47:25 +00:00
Roy Marples
023b012352 eloop_ctx -> eloop 2015-05-12 14:53:38 +00:00
Roy Marples
8d3d5b8221 Remove dhcpcd specifics from eloop to make more portable. 2015-05-09 10:09:34 +00:00
Roy Marples
069e2f284f syslogd(8) may not always be running before dhcpcd so any startup errors are
lost. Also, it's output with LOG_PERROR is ugly and LOG_PERROR isn't portable.

logger is a new function to solve the above which is identical to syslog(3)
but takes a dhcpcd_ctx for context so it functions in the RTEMS OS.
When writing to stdout/stderr or a given logfile, logger will convert %m
into the error string based on errno, just like syslog(3) does.
If your libc supports %m via printf, then define HAVE_PRINTF_M to remove
a fair chunk of code. There is no way of working out if your libc supports
this, especially in cross-compiled environment.
If the logfile is rotated, send dhcpcd a SIGUSR2 and the logfile will be
re-opened.

This does add about an exta 4K on 64-bit platforms so for size constraints
this can be compiled out by defining USE_LOGFILE to 0.
2015-03-17 23:46:38 +00:00
Roy Marples
c04f00c975 Improve pseudo interface handling. 2015-03-14 11:06:19 +00:00
Roy Marples
8c3d363e8b Support kqueue(2). 2015-03-04 15:47:04 +00:00
Roy Marples
4d71774dba Stop using link_addr(3).
Instead just set the sdl_index to specify which interface the route is for.
2015-02-27 14:21:01 +00:00
Roy Marples
a19fe49202 After adding an address load the kernel routing table for the interface.
When routes are rebuilt try not to remove any existing routes if they
don't need changing.
2015-02-26 13:22:41 +00:00
Roy Marples
ff4df8e09a Move the pidfile into the dhcpcd context.
When dumping a lease by filename, store the filename in the pidfile.
Fixes an issue where the filename overflows the interface name size.
2015-02-20 08:28:04 +00:00
Roy Marples
91dbca7a9c Fix Linux define. 2015-02-08 12:57:38 +00:00
Roy Marples
16f1b54cd4 For Linux, keep the alias on the interface so we don't have to guess
all the time.
2015-01-22 20:10:18 +00:00
Roy Marples
f9584c9506 Update copyrights to 2015. 2015-01-02 20:03:28 +00:00
Roy Marples
4d91c2e720 If allowinterfaces is not specified, allow all configured interfaces
to work, such as loopback and ppp.
2014-11-18 12:06:08 +00:00
Roy Marples
bc09d81de2 TAILQ is now inlcuded via config.h either via sys/queue.h or compat/queue.h.
This allows dhcpcd to compile on systems that do not even supply sys/queue.h,
such as the musl C library.

Thanks to Juan RP.
2014-11-10 16:56:32 +00:00
Roy Marples
40683854e3 Fix compile on FreeBSD 2014-10-14 11:29:50 +00:00
Roy Marples
b594ce0ddf For the time being, linkaddr is FreeBSD only. 2014-10-11 00:44:59 +00:00
Roy Marples
91692ea1c7 Improve FreeBSD support by using the actual AF_LINK address. 2014-10-10 20:35:13 +00:00
Roy Marples
559da5b05d Re-introduce our loop to poll interface flags when the interface does
not support link states, but this time ensure we don't call IFF_UP inside
the loop. This now works nicely with PPP interfaces on NetBSD at least.
2014-10-08 12:30:27 +00:00
Roy Marples
9b72ef1ca1 Add an unprivileged control socket so that normal users can
obtain dhcpcd running state.
2014-09-14 19:12:57 +00:00
Roy Marples
71650ebcde Allow SSIDs with non printable characters to be used in ssid selection in
dhcpcd.conf and generate more accurate stable private addresses.
2014-09-10 10:00:08 +00:00
Roy Marples
67ed6c5fdc Use the nl80211 interface on Linux to get the wireless SSID.
If this is not found in the system headers, fall back to assuming WEXT.
This has been done because the WEXT module has been marked as deprecated
for a while now and I'm getting bored of people asking me why their
wireless wasn't working. Bloated dhcpcd by another 600 bytes as a result.
2014-09-10 01:46:58 +00:00
Roy Marples
2f4d126e24 Add variables if_oneup and if_ipwaited so hook scripts know the overall state of dhcpcd better. 2014-09-07 19:03:41 +00:00
Roy Marples
923e118097 Implement a send queue for each control fd.
Only one call to write(2) should be performed for each POLLOUT check
via poll(2) so we should never see EAGAIN when writing to control
sockets ever again.
Each fd queue is limited to 100 entries so we don't OOM with badly
written control subscribers.
2014-09-05 12:28:05 +00:00
Roy Marples
9d5cb9f924 When requesting a IA_PD and another IA type, create a psuedo interface
to handle the IA_PD.
ia_pd_mix config option disables this and mixes IA_PD in the single session as
per draft-ietf-dhc-dhcpv6-stateful-issues-06.
2014-07-07 14:41:18 +00:00
Roy Marples
e17496222a Stop restoring kernel flags to their state before dhcpcd ran.
As multiple dhcpcd daemons could be in use to facilitate separate sessions
per DHCPv6 IA resetting them at exist could break the others.
2014-07-02 13:15:18 +00:00
Roy Marples
3ed12ab824 Implement Stable Private Addresses for SLAAC as per RFC7217.
Add a SHA256 implementation by Collin Percival if one in libc/libmd not found.
2014-06-02 14:48:33 +00:00
Roy Marples
a93e79c68f controlgroup option changes group ownership of the control socket. 2014-05-09 12:09:05 +00:00
Roy Marples
94bec97280 Namespace all public dhcpcd.c functions.
Add ipv4, ipv6, dhcp and dhcp6 options to re-enable if disabled globally.
Try and load a delegated interface if not running on all interfaces.
Fix delegated interfaces without a prefix set.
2014-04-28 12:02:12 +00:00
Roy Marples
34457fe661 Add -Wconversion to debug CFLAGS and fix fallout. 2014-03-27 22:14:52 +00:00
Roy Marples
b5268bac05 BSD has per interface rtadv kernel flag, handle it as per Linux.
When enabling IPv6 ensure that disabled is cleared and auto link-local is set.
2014-03-20 13:48:59 +00:00
Roy Marples
6618e7ea8b Add a USE_SIGNALS define.
If we're not using signals then we also create a control socket in the
non MASTER case. We then use this to communicate instead of signals.
2014-02-21 16:10:55 +00:00
Roy Marples
63d4472589 Fix compile on BSD 2014-02-12 09:25:58 +00:00
Roy Marples
4eb7b4896f Move all global variables into contexts, with a small exception for
signal handling.
This allows dhcpcd to work better in a threaded environment such as rtems.
2014-02-12 00:39:46 +00:00
Roy Marples
d074b2494f Move vendor out of global scope. 2014-02-08 00:29:02 +00:00
Roy Marples
623e5af396 pidfd can be static now. 2014-02-05 13:18:58 +00:00
Roy Marples
ebc9d360fa Allow IAID to be configured in DHCPv4 clientid.
Use this as the default for DHCPv6 IA's as well.
Rename if_iaid to if_ia as it's really an IA containing an IAID.
2013-11-15 13:43:41 +00:00
Roy Marples
7c3225083f Instead of just renaming the interface on Linux, take the FreeBSD
approach and remove the old and create a new one.
This simple change allows the the allow/deny rules to be followed.
2013-09-10 09:56:11 +00:00
Roy Marples
1f88304a4e Fix interface renaming and carrier reporting when using udev 2013-09-09 20:22:12 +00:00
Roy Marples
27f61373d1 It seems that FreeBSD will send RTM_DELADDR + RTM_NEWADDR when
replacing an existing IPv4 address with the same values.
As such, we need to maintain a list of configured IPv4 addresses
for each interface so we know when to add it and when to skip it
to avoid receiving bogus RTM_DELADDR messages from ourself.
2013-09-06 09:38:24 +00:00
Roy Marples
e82129a42c Reduce code size by merging IPv6 ND with RS. 2013-08-20 10:29:43 +00:00
Roy Marples
ecf297d6c7 Detect link address changes on Linux.
Only NetBSD emits RTM_CHGADDR for link address changes.
Sadly no other BSD emits anything for link address changes so we have
to do a full discovery on carrier up.

When a link address does change, simply carry on as we are, no need
to drop any existing lease as the carrier change will do that for us.
2013-06-25 08:31:11 +00:00
Roy Marples
336dd1b83b Move signal handling into dhcpcd.c
Log the PID of the signal caller
Move syslog functions out of the signal handler if we're not
exiting as it's not safe.
Close existing IPv4 sockets when restarting an interface.
Fix control handling keeping current flags and accepting new ones.
2013-06-07 12:44:19 +00:00
Roy Marples
5331b839c9 Store IPv6 link local addresses per interface.
Listen to kernel messages to account them.
If we don't have a local link address, delay IPv6RS as it just
won#t work until we have a local link address.
2013-05-17 23:09:36 +00:00
Roy Marples
3172b10177 Fix compile on FreeBSD 2013-05-15 11:34:17 +00:00
Roy Marples
76a9421805 More PPC __unused compile fixes. 2013-05-03 14:41:19 +00:00
Roy Marples
8cc47ba26d White space police 2013-04-04 20:31:04 +00:00
Roy Marples
4b0cbc8974 Use a TAILQ macro for our interface list. 2013-02-19 13:37:42 +00:00
Roy Marples
95fdd136ae Move if_state into interface->if_data as dhcp_state.
This should reduce memory usage for non IPv4 interfaces.
2013-02-03 22:55:45 +00:00
Roy Marples
5dc65f77b3 Move ipv4 specific infos from interface to if_state. 2013-02-03 14:52:24 +00:00
Roy Marples
875979f614 Move options away from ipv4 state to the interface. 2013-02-03 10:35:59 +00:00