[systemd-devel] [PATCH 01/24] sd-dhcp6-client: Add initial DHCPv6 client files

2014-06-13 Thread Patrik Flykt
Add initial structure definition and functions for setting index, MAC address, callback and event loop. Define protocol values and states. --- src/libsystemd-network/dhcp6-protocol.h | 104 src/libsystemd-network/sd-dhcp6-client.c | 203 +++ src/system

[systemd-devel] [PATCH 22/24] sd-dhcp6-client: Receive and parse a reply and set T1 and T2 timers

2014-06-13 Thread Patrik Flykt
Receive and parse a Reply from the server. Set up T1 and T2 timers and notify the library user of an acquired DHCPv6 lease. --- src/libsystemd-network/dhcp6-protocol.h | 1 + src/libsystemd-network/sd-dhcp6-client.c | 145 +++ src/systemd/sd-dhcp6-client.h

[systemd-devel] [PATCH 12/24] sd-dhcp6-client: Add DHCPv6 Solicit message creation and sending

2014-06-13 Thread Patrik Flykt
Implement the initial functionality used for creating a DHCPv6 Solicit message containing the needed options and send it to the DHCPv6 broadcast address. Increase the sent message count and ensure that the Solicit Initial Retransmission Time is strictly greater than the Solicitation IRT as describe

[systemd-devel] [PATCH 07/24] sd-dhcp6-client: Add DHCPv6 IAID functionality

2014-06-13 Thread Patrik Flykt
Create structures describing Identity Association IDentifiers and IPv6 lease addresses. [tomegun: initialize the IAID when client is started. Base this off of the predictable udev names, if available, as these satisfy the requirement of the IAID, and base it off the mac addres otherwise, as that i

[systemd-devel] [PATCH 17/24] sd-dhcp6-lease: Add functions for accessing lease and addresses

2014-06-13 Thread Patrik Flykt
Add support functions for accessing the current client lease as well as iterating over the addresses and get their preferred and valid lifetimes. --- src/libsystemd-network/dhcp6-lease-internal.h | 2 ++ src/libsystemd-network/sd-dhcp6-client.c | 12 + src/libsystemd-network/sd-dhcp6

[systemd-devel] [PATCH 20/24] sd-dhcp6-client: Add Request message sending

2014-06-13 Thread Patrik Flykt
As described in RFC 3315, Section 17.1.2, a client has to wait until the first timeout has elapsed before it is allowed to request IPv6 addresses from the DHCPv6 server. This is indicated by a non-NULL lease and a non-zero resend count. Should the Advertisement contain a preference value of 255 or

[systemd-devel] [PATCH 13/24] sd-dhcp6-client: Add RA and DHCPv6 Solicit test case

2014-06-13 Thread Patrik Flykt
Copy Router Advertisement functions and data from the previous test case and verify the created Solicit message. The test will take some non-trivial time to run due to the DHCPv6 initial delay. --- Makefile.am| 1 + src/libsystemd-network/test-dhcp6-client.c | 181

[systemd-devel] [PATCH 21/24] sd-dhcp6-client: Add Advertise sending for test cases

2014-06-13 Thread Patrik Flykt
Enhance the test case by replying with an Advertise message to the client. Copy the transaction id, IAID and DUID from the Solicit message. Verify the Request message created by the DHCPv6 client implementation and move the main loop exit to the end of the Request message verification. Provide loc

[systemd-devel] [PATCH 16/24] sd-dhcp6-client: Receive and parse Advertise messages

2014-06-13 Thread Patrik Flykt
When receiving DHCPv6 messages, discard the ones that are not meant for DHCPv6 clients and verify the transaction id. Once that is done, process the Advertise message and select the Advertise with the highest preference. Create a separate function for lease information parsing so that it can be re

[systemd-devel] [PATCH 06/24] network-internal: split out net_get_name()

2014-06-13 Thread Patrik Flykt
From: Tom Gundersen --- src/libsystemd-network/network-internal.c | 26 +++--- src/libsystemd-network/network-internal.h | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-interna

[systemd-devel] [PATCH 24/24] networkd: Add initial DHCPv6 support

2014-06-13 Thread Patrik Flykt
Enable DHCPv6 support by creating a DHCPv6 boolean in the Network section. Add necessary dhcp6 structures and initial function calls. --- src/network/networkd-link.c | 75 src/network/networkd-network-gperf.gperf | 1 + src/network/networkd.h

[systemd-devel] [PATCH 09/24] sd-dhcp6-client: Add DHCPv6 client Solicitation timeout handling

2014-06-13 Thread Patrik Flykt
Add the core of DHCPv6 client message retransmission and upper bound timer and message count handling according to RFC 3315 Secions 7.1.2 and 14. Omit the DHCPv6 initial delay; for now it is assumed that systemd-networkd will provide decent startup randomization that will desynchronize the clients.

[systemd-devel] [PATCH 10/24] sd-dhcp6-client: Add basic DHCPv6 option handling

2014-06-13 Thread Patrik Flykt
Add option appending and parsing. DHCPv6 options are not aligned, thus the option handling code must be able to handle options starting at any byte boundary. Add a test case for the basic option handling. --- Makefile.am| 4 +- src/libsystemd-network/dhcp6-intern

[systemd-devel] [PATCH 18/24] sd-dhcp6-client: Add test case for Advertise message parsing

2014-06-13 Thread Patrik Flykt
Add a basic test case excersising once more option parsing function in addition to lease handling. Check that the address iteration functions return the correct IPv6 address and lifetimes and that only one address is returned. Also verify that the server ID and preference values are read correctly.

[systemd-devel] [PATCH 15/24] sd-dhcp6-client: Add IA Address option parsing

2014-06-13 Thread Patrik Flykt
Add functionality to parse DHCPv6 Identity Association for Non-temporary (IA_NA) and Temporary Addresses (IA_TA) options. Both of them contain one or more IA Address (IAADDR) options and optinally a status code option. Only the IA_NA option contains lease lifetimes. See RFC 3315, sections 22.4., 22

[systemd-devel] [PATCH 11/24] sd-dhcp6-client: Add functions to bind to DHCPv6 UDP socket

2014-06-13 Thread Patrik Flykt
Add a function that creates a UDP socket bound to the given interface and optionally to an IPv6 address. Add another function that will send the DHCPv6 UDP packet to its destination. Using IPV6_PKTINFO in setsockopt to bind the IPv6 socket to an interface is documented in section 4. of RFC 3542, "

[systemd-devel] [PATCH 04/24] sd-dhcp6-client: Initialize Router Solicitation on startup

2014-06-13 Thread Patrik Flykt
Try DHCPv6 if router solicitation times out as a link without routers may use DHCPv6 according to RFC 4862 section 5.5.2. --- src/libsystemd-network/sd-dhcp6-client.c | 70 +++- src/systemd/sd-dhcp6-client.h| 1 + 2 files changed, 69 insertions(+), 2 deleti

[systemd-devel] [PATCH 14/24] sd-dhcp6-lease: Add DHCPv6 lease handling

2014-06-13 Thread Patrik Flykt
Create a structure describing a DHCPv6 lease. Add internal functions for creating a new lease and accessing the server ID, preference and IAID. Provide functions for clearing addresses and associated timers. External users are initially given only the capabilities of referencing and unreferencing

[systemd-devel] [PATCH 03/24] sd-dhcp6-client: Add initial Router Advertisement test case

2014-06-13 Thread Patrik Flykt
Feed a Router Advertisement to the code and expect proper events each time. The sending part is ignored, as all of it is static code in the real dhcp_network_icmp6_send_rs() function. --- Makefile.am| 13 ++- src/libsystemd-network/test-dhcp6-rs.c | 155 +++

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-06-02 Thread Patrik Flykt
On Fri, 2014-05-30 at 17:21 +0100, Tom Gundersen wrote: > I'm wondering if the criterion should be to request broadcast if and > only if we have not configured an IP address (I.e. only in > discovering, requesting and init-reboot), as that seems to be the > problem, or did I get that wrong? Yes, I

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-06-02 Thread Patrik Flykt
On Fri, 2014-05-30 at 17:42 +0100, Tom Gundersen wrote: > > Actually, I have had recent reports from users that there seems to > exist > > a category of networking devices > > Do you have any more info on this by any chance? Any way we may > classify these devices in a robust way? Unfortunately i

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-05-30 Thread Patrik Flykt
On Thu, 2014-05-29 at 18:18 +0100, Tom Gundersen wrote: > + if (link->udev_device) { > + const char *l2; > + > + l2 = udev_device_get_sysattr_value(link->udev_device, "layer2"); > + if (l2) { > + unsigned layer2; > + > + r = safe_atou(l2, &layer2); > +

Re: [systemd-devel] [PATCH] sd-dhcp-client: Sets broadcast flag to 1

2014-05-30 Thread Patrik Flykt
On Thu, 2014-05-29 at 00:03 +0100, Tom Gundersen wrote: > On Wed, May 28, 2014 at 7:43 PM, Camilo Aguilar > wrote: > > In systems running on hypervisors this flag needs to be set ON, so offers > > can reach > > the virtual machines. > > > > For more information please refer to this thread in Core

Re: [systemd-devel] [PATCH 17/17] networkd: add dhcp server support

2014-05-28 Thread Patrik Flykt
On Tue, 2014-05-27 at 13:39 +0200, David Herrmann wrote: > I strongly disagree. One major example is Wifi-P2P which requires a > DHCP-Server for ad-hoc P2P connections. A network-daemon manages the > local address-space, so it should also be responsible of assigning > those ranges to an ad-hoc DHCP

[systemd-devel] [PATCH] libsystemd-network: Support setting DHCP client initial delay

2014-04-03 Thread Patrik Flykt
Section 4.4.1 in RFC 2131 says that a DHCP client SHOULD wait a random time between one and ten seconds to desynchronize DHCP clients on startup. This is supported such that the application can optionally set an initial delay of approximately two and eight seconds or leave the initial value unset r

Re: [systemd-devel] systemd-networkd bridge with DHCP not working

2014-03-21 Thread Patrik Flykt
On Thu, 2014-03-20 at 20:29 +0100, Tom Gundersen wrote: > My proposal is: > > Whenever the MAC address changes under us networkd calls > sd_{dhcp_client,ipv4ll}_set_mac(), and it is the libs' responsibility > to then do the right thing. > > Currently the libs don't support this and will fail with

Re: [systemd-devel] [PATCH] libsystemd-network: Prepend hardware type byte to client identifier

2014-03-20 Thread Patrik Flykt
On Wed, 2014-03-19 at 13:53 +0200, Patrik Flykt wrote: > Even though client identifiers SHOULD be treated as opaque objects by > DHCP servers, follow the recommendation of a hardware type field with > value 0x01 (ethernet) followed by the hardware address as described in > RFC 2132.

Re: [systemd-devel] [PATCH] libsystemd-network: Don't unnecessarily send too long packets

2014-03-20 Thread Patrik Flykt
On Wed, 2014-03-19 at 14:38 +0200, Patrik Flykt wrote: > Since the length used by options is known, send packets with no > extra padding. Applied this patch too. Cheers, Patrik ___ systemd-devel mailing list systemd

[systemd-devel] [PATCH] libsystemd-network: Don't unnecessarily send too long packets

2014-03-19 Thread Patrik Flykt
Since the length used by options is known, send packets with no extra padding. --- Hi, Discovered that the full buffer was sent out even though the length of all options would indicate a shorter one. Shave off extra padding from the packets by properly setting the buffer length. Cheers,

[systemd-devel] [PATCH] libsystemd-network: Prepend hardware type byte to client identifier

2014-03-19 Thread Patrik Flykt
Even though client identifiers SHOULD be treated as opaque objects by DHCP servers, follow the recommendation of a hardware type field with value 0x01 (ethernet) followed by the hardware address as described in RFC 2132. --- Hi, This change "fixes" the DHCP client identifier to use the in

Re: [systemd-devel] [PATCH 4/4] libsystemd-network: Add Init-Reboot support

2014-03-19 Thread Patrik Flykt
On Mon, 2014-03-17 at 15:08 +0100, Zbigniew Jędrzejewski-Szmek wrote: > > If there are no more comments, I can probably go ahead and apply > > these four patches? > > Yes, they look fine. Rebased to latest taking Tom's changes from yesterday into account and applied these. Cheers, Patri

Re: [systemd-devel] [PATCH 2/4] libsystemd-network: Add hangcheck timer for DHCP client test

2014-03-17 Thread Patrik Flykt
Hi, On Sat, 2014-03-15 at 03:56 +0100, Zbigniew Jędrzejewski-Szmek wrote: > On Fri, Mar 14, 2014 at 08:05:10PM +0100, Tom Gundersen wrote: > > On Thu, Mar 13, 2014 at 12:01 PM, Patrik Flykt > > wrote: > > > --- > > > src/libsystem

Re: [systemd-devel] [PATCH 4/4] libsystemd-network: Add Init-Reboot support

2014-03-17 Thread Patrik Flykt
On Sat, 2014-03-15 at 04:02 +0100, Zbigniew Jędrzejewski-Szmek wrote: > This means that I can complain about spelling :) There's no such word > as "broadcasted". Past tense and adjective are "broadcast". Yes :-) Spelling fixed. > > -if (client->state == DHCP_STATE_REQUESTI

[systemd-devel] [PATCH 0/4] Add DHCPv4 client restart and Init-Reboot support

2014-03-13 Thread Patrik Flykt
before should the previous IP address be acceptable to the server. Cheers, Patrik Patrik Flykt (4): libsystemd-network: Export checksum function to test case libsystemd-network: Add hangcheck timer for DHCP client test libsystemd-network: Restart DHCP acquisition if the lease exp

[systemd-devel] [PATCH 2/4] libsystemd-network: Add hangcheck timer for DHCP client test

2014-03-13 Thread Patrik Flykt
--- src/libsystemd-network/test-dhcp-client.c | 16 1 file changed, 16 insertions(+) diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c index cfc75ae..9509eec 100644 --- a/src/libsystemd-network/test-dhcp-client.c +++ b/src/libsyst

[systemd-devel] [PATCH 1/4] libsystemd-network: Export checksum function to test case

2014-03-13 Thread Patrik Flykt
Remove identical checksum function implementation from the test case code. --- src/libsystemd-network/dhcp-internal.h| 2 ++ src/libsystemd-network/dhcp-packet.c | 10 +- src/libsystemd-network/test-dhcp-client.c | 30 +++--- 3 files changed, 10 insertions

[systemd-devel] [PATCH 4/4] libsystemd-network: Add Init-Reboot support

2014-03-13 Thread Patrik Flykt
Init-Reboot is tried if a client IP address has been given when the DHCP client is started. In Init-Reboot, start by sending a broadcasted DHCP Request including the supplied client IP address but without the server identifier. After sending the request, enter Reboot state. If a DHCP Ack is receiv

[systemd-devel] [PATCH 3/4] libsystemd-network: Restart DHCP acquisition if the lease expires

2014-03-13 Thread Patrik Flykt
This causes the DHCP client struct initialization and DHCP client starting to be factored out into functions of their own. --- src/libsystemd-network/sd-dhcp-client.c | 74 +++-- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/src/libsystemd-network/sd-d

[systemd-devel] [PATCH] NEWS: Fix header file name

2014-02-18 Thread Patrik Flykt
--- Minor correction to the news section. Cheers, Patrik NEWS | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 4c7fb72..b40d369 100644 --- a/NEWS +++ b/NEWS @@ -85,8 +85,8 @@ CHANGES WITH 209: around the route netlink interface of

Re: [systemd-devel] [HEADS-UP] It's release time!

2014-02-18 Thread Patrik Flykt
Hi, On Tue, 2014-02-18 at 03:26 +0100, Lennart Poettering wrote: > Kay, Zbigniew, Tom, David, Patrik, anything left to fix before I roll a > release? I'd like to roll the release tomorrow (tuesday) or > wednesday. Please have a closer look and test! I'm fine with the DHCP state of affair

[systemd-devel] [PATCH 3/3] libsystemd-dhcp: Add a full DHCP address acquisition test case

2014-02-18 Thread Patrik Flykt
Upon startup the DHCP library will immediately send a DHCP Discover. Handle the additional DHCP Discover checking and DHCP Offer sending in test_addr_acq_recv_discover(). Write a zero UDP checksum, the received XID and the faked MAC address into place to create a DHCP message the library can accept

[systemd-devel] [PATCH 1/3] libsystemd-dhcp: Add capability to print out test steps

2014-02-18 Thread Patrik Flykt
--- src/libsystemd-dhcp/test-dhcp-client.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/src/libsystemd-dhcp/test-dhcp-client.c b/src/libsystemd-dhcp/test-dhcp-client.c index f341b3c..32c79eb 100644 --- a/src/libsystemd-dhcp/test-dhcp-client.c +++ b/src/libsystemd-dhcp/test-dhcp

[systemd-devel] [PATCH 2/3] libsystemd-dhcp: Factor out test code for DHCP message verification

2014-02-18 Thread Patrik Flykt
Add a callback function that will handle the test case specific checking. --- src/libsystemd-dhcp/test-dhcp-client.c | 38 +++--- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/libsystemd-dhcp/test-dhcp-client.c b/src/libsystemd-dhcp/test-dhcp-clien

[systemd-devel] [PATCH 0/3] Add basic DHCP client test case

2014-02-18 Thread Patrik Flykt
n the world but should get the work done. I still have to send these to the mailing list, no word from fd.o yet. Cheers, Patrik Patrik Flykt (3): libsystemd-dhcp: Add capabilitye to print out test steps libsystemd-dhcp: Factor out test code for DHCP message verification libsyst

[systemd-devel] [PATCH 1/6] libsystemd-dhcp: DNS name option must be a multiple of 4 bytes

2014-01-31 Thread Patrik Flykt
--- src/libsystemd-dhcp/sd-dhcp-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index 3b7b9f4..1fdc01a 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-clien

[systemd-devel] [PATCH 4/6] libsystemd-dhcp: Compute UDP checksum only if set

2014-01-31 Thread Patrik Flykt
A checksum field with value zero means no UDP checksum has been computed for the packet. --- src/libsystemd-dhcp/sd-dhcp-client.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index

[systemd-devel] [PATCH 6/6] libsystemd-dhcp: Update secs field only when sending Discover

2014-01-31 Thread Patrik Flykt
Compute the 'secs' field as seconds since start of lease acquisition procedure. Start off with a value of zero and increase it only for each resent DHCP discover message. See the discussion before and after http://www.ietf.org/mail-archive/web/dhcwg/current/msg05836.html and Section 3.1 of RFC 2131

[systemd-devel] [PATCH 3/6] libsystemd-dhcp: Add Init-Reboot support

2014-01-31 Thread Patrik Flykt
Init-Reboot is tried if a client IP address has been given when the DHCP client is started. In Init-Reboot, start by sending a broadcasted DHCP Request including the supplied client IP address but without the server identifier. After sending the request, enter Reboot state. If a DHCP Ack is receiv

[systemd-devel] [PATCH 0/6] Init-Reboot and some minor fixes

2014-01-31 Thread Patrik Flykt
x27; field is to be updated only with each sent DHCP Discover and not constantly for each message. The commit message contains a link to the discussion on the IETF DHC WG mailing list some years ago. Cheers, Patrik Patrik Flykt (6): libsystemd-dhcp: DNS name option must be a multiple

[systemd-devel] [PATCH 5/6] libsystemd-dhcp: Fix stopping of DHCP client

2014-01-31 Thread Patrik Flykt
Go back to Init state independent of the current state the client is in. --- src/libsystemd-dhcp/sd-dhcp-client.c | 20 ++-- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index 7e79dc1..fd

[systemd-devel] [PATCH 2/6] libsystemd-dhcp: Rename function to be clearer that options are parsed

2014-01-31 Thread Patrik Flykt
--- src/libsystemd-dhcp/sd-dhcp-client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index 1fdc01a..ffb304d 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp

Re: [systemd-devel] [RFT] DHCPv4 support in networkd

2014-01-03 Thread Patrik Flykt
On Thu, 2014-01-02 at 16:52 +0100, Tom Gundersen wrote: > On Thu, Jan 2, 2014 at 4:48 PM, Reindl Harald wrote: > > > > > > Am 02.01.2014 16:41, schrieb Tom Gundersen: > >> On Thu, Jan 2, 2014 at 4:37 PM, Reindl Harald > >> wrote: > >>> the problems are that if someone comes back with his Apple n

Re: [systemd-devel] [PATCH 00/11] Finalize initial DHCP support

2014-01-03 Thread Patrik Flykt
On Fri, 2013-12-20 at 09:47 -0800, Marcel Holtmann wrote: > Hi Tom, > > >>> The first seven patches fix a few issues with the current code. > >>> > >>> Patch 09 adds DHCP lease renewing support when timer T1 triggers. > Using > >>> the UDP socket sending implementation in patch 08, the DHCP lease

[systemd-devel] [PATCH 00/11] Finalize initial DHCP support

2013-12-20 Thread Patrik Flykt
, etc options from the DHCP message(s) is still missing, sorry for that. Also Init-Reboot state support is missing; adding that functionality can speed up the address acquisition if the host comes back to a known network where it still has an unexpired lease. Please review, Patrik Patrik

[systemd-devel] [PATCH 07/11] libsystemd-dhcp: Check test result without casting value

2013-12-20 Thread Patrik Flykt
--- src/libsystemd-dhcp/test-dhcp-client.c |8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/libsystemd-dhcp/test-dhcp-client.c b/src/libsystemd-dhcp/test-dhcp-client.c index 7400cc6..1ff78c1 100644 --- a/src/libsystemd-dhcp/test-dhcp-client.c +++ b/src/libsystemd-

[systemd-devel] [PATCH 09/11] libsystemd-dhcp: Handle T1 Renewing timeout

2013-12-20 Thread Patrik Flykt
Expiration of T1 timeout takes the client to the Rebinding state, where it attempts to renew its lease. Start by opening a DCHP unicast socket as there now is a proper IP address set. Compute the resend timer as half of the remaining time down to a minimum of 60 seconds (RFC2131). Modify DHCP Requ

[systemd-devel] [PATCH 11/11] libsystemd-dhcp: Handle T2 Rebinding timeout

2013-12-20 Thread Patrik Flykt
Reuse existing functionality when adding T2 Rebinding support. --- src/libsystemd-dhcp/dhcp-client.c | 41 - 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c index 23669c7..a8

[systemd-devel] [PATCH 06/11] libsystemd-dhcp: Fix checksum computation for buffer with odd size

2013-12-20 Thread Patrik Flykt
Fix off-by-one error and notice that summing may need more than one round for the result to be in the lower 16 bits. --- src/libsystemd-dhcp/dhcp-client.c |7 +-- src/libsystemd-dhcp/test-dhcp-client.c |7 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src

[systemd-devel] [PATCH 10/11] libsystemd-dhcp: Factor out common code initializing events

2013-12-20 Thread Patrik Flykt
Factor out common code from timeout T1 handling and starting of the DHCP client. --- src/libsystemd-dhcp/dhcp-client.c | 76 + 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.

[systemd-devel] [PATCH 03/11] libsystemd-dhcp: Return proper error on OOM

2013-12-20 Thread Patrik Flykt
--- src/libsystemd-dhcp/dhcp-client.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c index fe41067..043d574 100644 --- a/src/libsystemd-dhcp/dhcp-client.c +++ b/src/libsystemd-dhcp/dhcp-client.c @@ -726,

[systemd-devel] [PATCH 04/11] libsystemd-dhcp: Unref event source before closing socket

2013-12-20 Thread Patrik Flykt
--- src/libsystemd-dhcp/dhcp-client.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c index 043d574..18a6e3c 100644 --- a/src/libsystemd-dhcp/dhcp-client.c +++ b/src/libsystemd-dhcp/dhcp-client.c @@ -

[systemd-devel] [PATCH 08/11] libsystemd-dhcp: Add functions for sending unicast UDP messages

2013-12-20 Thread Patrik Flykt
Create a helper functions setting up an unicast DHCP UDP socket and sending data. Add function stubs for the test program. --- src/libsystemd-dhcp/dhcp-internal.h|3 +++ src/libsystemd-dhcp/dhcp-network.c | 38 src/libsystemd-dhcp/test-dhcp-client.c |

[systemd-devel] [PATCH 05/11] libsystemd-dhcp: Fix receiving of other message when expecting Ack

2013-12-20 Thread Patrik Flykt
When a DHCP Nak is received, return a DHCP_EVENT_NO_LEASE event. If some other DHCP message is received or an error happens when parsing options, return -ENOMSG in order to ignore the packet. There may be more than one server serving the same subnet, each server will send its Offer to the client. -

[systemd-devel] [PATCH 01/11] libsystemd-dhcp: Use be32_t for IP addresses in network order.

2013-12-20 Thread Patrik Flykt
--- src/libsystemd-dhcp/dhcp-client.c | 10 +- src/libsystemd-dhcp/dhcp-protocol.h |8 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c index c0c348c..fe41067 100644 --- a/src/libsystemd-d

[systemd-devel] [PATCH 02/11] libsystemd-dhcp: Return proper error if bind fails

2013-12-20 Thread Patrik Flykt
This also fixes a minor indentation damage. --- src/libsystemd-dhcp/dhcp-network.c |7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libsystemd-dhcp/dhcp-network.c b/src/libsystemd-dhcp/dhcp-network.c index 83a3084..3ff2d0b 100644 --- a/src/libsystemd-dhcp/dhcp-net

Re: [systemd-devel] [PATCH] dhcp: Move src/dhcp to src/libsystemd-dhcp

2013-12-13 Thread Patrik Flykt
On Thu, 2013-12-12 at 17:50 +0100, Zbigniew Jędrzejewski-Szmek wrote: > In the end I made more changes: not only is src/dhcp renamed to > src/libsystemd-dhcp, but also src/libsystemd-dhcp/*.[ch] to > src/libsystemd-dhcp/dhcp-*.[ch]. This is because we like to have > unique names for files, which ma

Re: [systemd-devel] [PATCH v3 01/26] dhcp: Add DHCP protocol structures and initial defines

2013-12-12 Thread Patrik Flykt
On Tue, 2013-12-10 at 18:48 +0100, Lennart Poettering wrote: > I agree with Zbigniew: this should probably be in > src/libsystemd-dhcp/, so that this is similar to libsystemd-bus/, > libsystemd-id128/ and so on... Sent a patch for that, and in the process of creating an account on freedesktop.org.

Re: [systemd-devel] [PATCH v3 01/26] dhcp: Add DHCP protocol structures and initial defines

2013-12-10 Thread Patrik Flykt
On Tue, 2013-12-10 at 02:46 +0100, Lennart Poettering wrote: > > +uint32_t ciaddr; > > +uint32_t yiaddr; > > +uint32_t siaddr; > > +uint32_t giaddr; > > Hmmm, why uin32_t? Shouldn't this be32_t? THis is network byte order, > right? which is just synoymous to big end

[systemd-devel] [PATCH v3 06/26] dhcp: Add buffer length and invalid cookie tests for DHCP options

2013-12-09 Thread Patrik Flykt
Create an initial simple test program for these two cases. --- src/dhcp/test-dhcp-option.c | 51 +++ 1 file changed, 51 insertions(+) create mode 100644 src/dhcp/test-dhcp-option.c diff --git a/src/dhcp/test-dhcp-option.c b/src/dhcp/test-dhcp-option.c ne

[systemd-devel] [PATCH v3 14/26] build: Add libsystemd-dhcp

2013-12-09 Thread Patrik Flykt
--- Makefile.am | 20 1 file changed, 20 insertions(+) diff --git a/Makefile.am b/Makefile.am index 5794380..cface06 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3837,6 +3837,26 @@ lib_LTLIBRARIES += \ endif # -

[systemd-devel] [PATCH v3 22/26] dhcp: Add maximum message size option

2013-12-09 Thread Patrik Flykt
Add maximum message size option to keep some DHCP server implementations from sending too big messages. See ConnMan commit 0c5c862749c05193cf4c513628328c6db02b5222. --- src/dhcp/client.c | 12 src/dhcp/protocol.h |1 + 2 files changed, 13 insertions(+) diff --git a/src/dhcp/c

[systemd-devel] [PATCH v3 12/26] dhcp: Add function for sending a raw packet

2013-12-09 Thread Patrik Flykt
Open a packet socket, create a link level header, send packet and close socket. Adding it to a separate file makes testing of the DHCP sending much easier, as the test program can supply any socket to the DHCP client code. --- v3: use size_t and set buffer to const src/dhcp/internal.h |2 ++

[systemd-devel] [PATCH v3 20/26] dhcp: Handle received DHCP Offer message

2013-12-09 Thread Patrik Flykt
Create a function for handling the full IP, UDP and DHCP packet and tie it to the main loop. Verify IP and UDP headers and checksum. Creat a new lease structure with using the values supplied in the DHCP message. Free the lease structure when client is stopped. Split out socket handling into a cre

[systemd-devel] [PATCH v3 19/26] dhcp: Add timeout and main loop support

2013-12-09 Thread Patrik Flykt
Require a main loop to be set when creating a DHCP client. Set up a timer to resend DHCP Discover messages and add a 0-2 second delay to the timeout value. Move to state Selecting after successful sending of a Discover message. --- v3: take ref on event loop, unref in free function in patch 26/26

[systemd-devel] [PATCH v3 26/26] dhcp: Add function to free DHCP client data

2013-12-09 Thread Patrik Flykt
--- src/dhcp/client.c| 13 + src/systemd/sd-dhcp-client.h |1 + 2 files changed, 14 insertions(+) diff --git a/src/dhcp/client.c b/src/dhcp/client.c index d93cceb..2a479e4 100644 --- a/src/dhcp/client.c +++ b/src/dhcp/client.c @@ -961,6 +961,19 @@ int sd_dhcp_client_

[systemd-devel] [PATCH v3 03/26] dhcp: Add test for DHCP client initialization and parameter setting

2013-12-09 Thread Patrik Flykt
--- src/dhcp/test-dhcp-client.c | 81 +++ 1 file changed, 81 insertions(+) create mode 100644 src/dhcp/test-dhcp-client.c diff --git a/src/dhcp/test-dhcp-client.c b/src/dhcp/test-dhcp-client.c new file mode 100644 index 000..cb2f652 --- /dev/null +++

[systemd-devel] [PATCH v3 18/26] build: Add dependency on libsystemd-bus needed for main loop

2013-12-09 Thread Patrik Flykt
--- Makefile.am |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1b9edf2..cfa9b4b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3855,7 +3855,8 @@ libsystemd_dhcp_la_LDFLAGS = \ $(AM_LDFLAGS) libsystemd_dhcp_la_LIBADD = \ -

[systemd-devel] [PATCH v3 16/26] dhcp: Support seconds elapsed since start of DHCP negotiation

2013-12-09 Thread Patrik Flykt
It was noticed by Grant Erickson in ConnMan commit 95e15c09350acf58d4707056ae2614570883ef66 that: "Certain DHCP servers, such as that implemented in Mac OS X (< 10.7) for its "Internet Sharing" feature, refuse to issue a DHCP lease to clients that have not set a non-zero value in th

[systemd-devel] [PATCH v3 11/26] shared: Add struct sockaddr_ll to sockaddr_union

2013-12-09 Thread Patrik Flykt
--- src/shared/socket-util.h |2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared/socket-util.h b/src/shared/socket-util.h index d42a2fe..84ebc30 100644 --- a/src/shared/socket-util.h +++ b/src/shared/socket-util.h @@ -27,6 +27,7 @@ #include #include #include +#include #in

[systemd-devel] [PATCH v3 25/26] dhcp: Add notification callback

2013-12-09 Thread Patrik Flykt
Define a notification callback and events for stopping and client lease expiry. Add functions to fetch IP parameters from a lease. --- src/dhcp/client.c| 112 +- src/systemd/sd-dhcp-client.h | 13 + 2 files changed, 124 insertions(+), 1 de

[systemd-devel] [PATCH v3 01/26] dhcp: Add DHCP protocol structures and initial defines

2013-12-09 Thread Patrik Flykt
Create a new directory to host DHCP components. --- src/dhcp/protocol.h | 104 +++ 1 file changed, 104 insertions(+) create mode 100644 src/dhcp/protocol.h diff --git a/src/dhcp/protocol.h b/src/dhcp/protocol.h new file mode 100644 index 000..

[systemd-devel] [PATCH v3 02/26] dhcp: Add DHCP client initialization

2013-12-09 Thread Patrik Flykt
Provide functionality for initializing a DHCP client struct, setting interface index, last used address and additional options to request. On initialization the most useful options are added by default. --- v3: fix OOM check, #ifdef in public header, fix struct prefix src/dhcp/client.c

[systemd-devel] [PATCH v3 09/26] dhcp: Add option append tests

2013-12-09 Thread Patrik Flykt
Add checks for invalid lengths and parameters when using the option appending function. Add also checks for adding options, see to it that the resulting array is identical to the array of options added. --- src/dhcp/test-dhcp-option.c | 72 +++ 1 file chan

[systemd-devel] [PATCH v3 07/26] build: Add DHCP option test

2013-12-09 Thread Patrik Flykt
--- Makefile.am | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Makefile.am b/Makefile.am index 4e13370..5794380 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3837,6 +3837,15 @@ lib_LTLIBRARIES += \ endif # ---

[systemd-devel] [PATCH v3 13/26] dhcp: Add DHCP discover sending

2013-12-09 Thread Patrik Flykt
On starting the client, use the supplied interface mac address and create a transaction id. Puzzle together an IP/UDP/DHCP Discover message, compute checksums and send it out as a raw packet. Create an additional function that constructs default options common to all DHCP messages. Set the DHCP C

[systemd-devel] [PATCH v3 24/26] dhcp: Compute expire, T1 and T2 timers

2013-12-09 Thread Patrik Flykt
Compute the default T1 and T2 timer values if they were not set by the DHCP server. Verify that the values are reasonable. --- src/dhcp/client.c | 116 ++- src/dhcp/protocol.h |2 + 2 files changed, 117 insertions(+), 1 deletion(-) diff --git

[systemd-devel] [PATCH v3 08/26] dhcp: Add tests for DHCP options, file and sname fields

2013-12-09 Thread Patrik Flykt
Add a structure describing the DHCP file, sname and trailing options fields. Create a messge holding these fields and call the internal option parsing function. In the test callback function verify that only regular options are passed and figure out which part of the DHCP message is the one that i

[systemd-devel] [PATCH v3 23/26] dhcp: Process DHCP Ack/Nak message

2013-12-09 Thread Patrik Flykt
Process a DHCP Ack/Nak in much the same way as an DHCP Offer. Factor out header verification and process options sent. Add notification functionality with discrete values for the outcome of the DHCP Ack/ Nak processing. --- v3: use size_t for length, -ENOMEM for OOM src/dhcp/client.c|

[systemd-devel] [PATCH v3 21/26] dhcp: Send DHCP Request to acquire an IP address

2013-12-09 Thread Patrik Flykt
Create and send a DHCP Request message reusing already existing parts of the code. This causes factoring out IP and UDP header creation and moving next timeout calculation to be done every time in the timer callback function independent of DHCP state. Also add an exponential part to the timer calcu

[systemd-devel] [PATCH v3 17/26] dhcp: Add function to stop the DHCP client

2013-12-09 Thread Patrik Flykt
The client is stopped and brought back to its initial state. --- src/dhcp/client.c| 32 src/systemd/sd-dhcp-client.h |1 + 2 files changed, 33 insertions(+) diff --git a/src/dhcp/client.c b/src/dhcp/client.c index 665f986..60a1b4c 100644 --- a/sr

[systemd-devel] [PATCH v3 15/26] dhcp: Add test for discover DHCP packet creation

2013-12-09 Thread Patrik Flykt
Set a fake MAC address and emulate raw packet sending. When the buffer containing the Discover message is received, check selected IP and UDP headers and compute IP header and UDP message checksums. Also send the DHCP message for option parsing and expect a successful outcome. --- Makefile.am

[systemd-devel] [PATCH v3 04/26] build: Add initial build support

2013-12-09 Thread Patrik Flykt
The client test program is the only one to be built so far. --- Makefile.am | 13 + src/dhcp/Makefile |1 + 2 files changed, 14 insertions(+) create mode 12 src/dhcp/Makefile diff --git a/Makefile.am b/Makefile.am index 7bedd76..4e13370 100644 --- a/Makefile.am +++ b/

[systemd-devel] [PATCH v3 05/26] dhcp: Add option appending and parsing

2013-12-09 Thread Patrik Flykt
Add functions to append and parse DHCP options. Not all options are passed to the callback function, the ones not exposed are pad, end, message type and overload. If indicated by the overload option, file and sname fields will be examined for more options. The option functions are internal to DHCP

[systemd-devel] [PATCH v3 10/26] dhcp: Add test function for computing checksum

2013-12-09 Thread Patrik Flykt
--- src/dhcp/test-dhcp-client.c | 40 1 file changed, 40 insertions(+) diff --git a/src/dhcp/test-dhcp-client.c b/src/dhcp/test-dhcp-client.c index cb2f652..b226d3f 100644 --- a/src/dhcp/test-dhcp-client.c +++ b/src/dhcp/test-dhcp-client.c @@ -22,6 +22,7

[systemd-devel] [PATCH v3 00/26] Initial DHCP v4 library implementation

2013-12-09 Thread Patrik Flykt
x27;s still the same old src/dhcp. Cheers, 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 optio

Re: [systemd-devel] [PATCH v2 00/26] Initial DHCP v4 library implementation

2013-12-09 Thread Patrik Flykt
On Mon, 2013-11-25 at 23:52 +0100, Lennart Poettering wrote: > Of course, timer callbacks should only be called once, ence > ONESHOT mode is the default -- unless you change that explicitly. > > If this doesn't solve the issue, I wouldn't be surprised if there was > still a bug lurking with the sd

[systemd-devel] [PATCH] networkd: Initialize variable to NULL

2013-11-27 Thread Patrik Flykt
If any number of arguments are given, _cleanup_manager_free_ is used with unitialized memory causing a crash. --- src/network/networkd.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/networkd.c b/src/network/networkd.c index 1d43361..360afba 100644 --- a/src/ne

Re: [systemd-devel] [PATCH v2 20/26] dhcp: Handle received DHCP Offer message

2013-11-27 Thread Patrik Flykt
Hi, On Tue, 2013-11-26 at 00:23 +0100, Lennart Poettering wrote: > On Mon, 25.11.13 09:13, Patrik Flykt (patrik.fl...@linux.intel.com) wrote: > > > +static int client_receive_raw_message(sd_event_source *s, int fd, > > + uint

Re: [systemd-devel] [PATCH v2 12/26] dhcp: Add function for sending a raw packet

2013-11-27 Thread Patrik Flykt
On Tue, 2013-11-26 at 00:10 +0100, Lennart Poettering wrote: > On Mon, 25.11.13 09:13, Patrik Flykt (patrik.fl...@linux.intel.com) wrote: > > > +int dhcp_network_send_raw_packet(int index, void *packet, int len); > > Should be "const void* packet", no? >

Re: [systemd-devel] [PATCH v2 23/26] dhcp: Process DHCP Ack/Nak message

2013-11-27 Thread Patrik Flykt
On Tue, 2013-11-26 at 00:26 +0100, Lennart Poettering wrote: > On Mon, 25.11.13 09:13, Patrik Flykt (patrik.fl...@linux.intel.com) wrote: > > > -static int client_receive_offer(DHCPClient *client, > > -DHCPPacket *offer, int le

<    1   2   3   >