Hi, Here is version 2 of the libsystemd-dhcp patch set fixed according to comments. Functionality is the same as in the earlier version. I'm still usin src/dhcp as the location for this code, but what might be the proper directory for the code eventually? I also left it conditionally enabled by default, should it be compiled unconditionally in the future?
I chose to drop the example DHCP client, it seems systemd-network is right around the corner so yet another piece of code doing something very similar is probably not very worthwhile. Thus the set shrunk with two patches. In addition to this, I added struct sockaddr_ll to sockaddr_union in patch 11/26. It wasn't possible to use _cleanup_free_ while handling the DHCP lease structure as freeing the structure afterwards is only to be done on error conditions. DHCP_EVENT_NAK was renamed to the hopefully more useful DHCP_EVENT_NO_LEASE and the public API is now in src/systemd/sd-dhcp-client.h. I also created a function for fetching the prefix length instead of netmask. After that I noticed someting interesting when setting a monotonic timer event to go off at time 0. It seems to repeatedly call the timer event without stopping, either due to the next timer computation going wrong in my code or then the reshuffling of the event queue in sd-event. As I couldn't figure out the root cause, I left the timer setting to now(CLOCK_MONOTONIC) instead of the proposed value 0. Please review, Patrik Patrik Flykt (26): dhcp: Add DHCP protocol structures and initial defines dhcp: Add DHCP client initialization dhcp: Add test for DHCP client initialization and parameter setting build: Add initial build support dhcp: Add option appending and parsing dhcp: Add buffer length and invalid cookie tests for DHCP options build: Add DHCP option test dhcp: Add tests for DHCP options, file and sname fields dhcp: Add option append tests dhcp: Add test function for computing checksum shared: Add struct sockaddr_ll to sockaddr_union dhcp: Add function for sending a raw packet dhcp: Add DHCP discover sending build: Add libsystemd-dhcp dhcp: Add test for discover DHCP packet creation dhcp: Support seconds elapsed since start of DHCP negotiation dhcp: Add function to stop the DHCP client build: Add dependency on libsystemd-bus needed for main loop dhcp: Add timeout and main loop support dhcp: Handle received DHCP Offer message dhcp: Send DHCP Request to acquire an IP address dhcp: Add maximum message size option dhcp: Process DHCP Ack/Nak message dhcp: Compute expire, T1 and T2 timers dhcp: Add notification callback dhcp: Add function to free DHCP client data Makefile.am | 50 +++ configure.ac | 9 + src/dhcp/Makefile | 1 + src/dhcp/client.c | 981 ++++++++++++++++++++++++++++++++++++++++++ src/dhcp/internal.h | 41 ++ src/dhcp/network.c | 64 +++ src/dhcp/option.c | 181 ++++++++ src/dhcp/protocol.h | 119 +++++ src/dhcp/test-dhcp-client.c | 224 ++++++++++ src/dhcp/test-dhcp-option.c | 376 ++++++++++++++++ src/shared/socket-util.h | 2 + src/systemd/sd-dhcp-client.h | 57 +++ 12 files changed, 2105 insertions(+) create mode 120000 src/dhcp/Makefile create mode 100644 src/dhcp/client.c create mode 100644 src/dhcp/internal.h create mode 100644 src/dhcp/network.c create mode 100644 src/dhcp/option.c create mode 100644 src/dhcp/protocol.h create mode 100644 src/dhcp/test-dhcp-client.c create mode 100644 src/dhcp/test-dhcp-option.c create mode 100644 src/systemd/sd-dhcp-client.h -- 1.7.10.4 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel