summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp6-client.c
AgeCommit message (Collapse)Author
2015-08-26dhcp: coding style fixesLennart Poettering
We place the opening bracket of a function on the same line as the function name. Let's do so in the DHCP sources too.
2015-08-26dhcp: stop using refcnt.hLennart Poettering
No need to invole atomic ops in single-threaded APIs, let's simplify this.
2015-08-26sd-dhcp: don't randomly ref objectsDavid Herrmann
In our API design, getter-functions don't ref objects. Calls like foo_get_bar() will not ref 'bar'. We never do that and there is no real reason to do it in single threaded APIs. If you need a ref-count, you better take it yourself *BEFORE* doing anything else on the parent object (as this might invalidate your pointer). Right now, sd_dhcp?_get_lease() refs the lease it returns. A lot of code-paths in systemd do not expect this and thus leak the lease reference. Fix this by changing the API to not ref returned objects.
2015-08-21sd-dhcp6: Support deprecated SNTP Configuration OptionPatrik Flykt
Although the SNTP option specified in RFC 4075 has been deprecated, some servers are still sending NTP information with this option. Use the SNTP information provided only if the NTP option is not present. Update the test case as SNTP information is also requested.
2015-08-21sd-dhcp6: Add support for DHCPv6 NTP Server OptionPatrik Flykt
Support NTP server and multicast addresses and NTP server domain names as specified in RFC 5908.
2015-08-21sd-dhcp6: Add support for DHCPv6 DNS Domain Search List optionPatrik Flykt
Support DHCPv6 DNS search list option as specified in RFC 3646. This option contains a list of DNS search domains encoded without compression as specified in Section 8. of RFC 3315.
2015-08-21sd-dhcp6: Add support for DHCPv6 DNS Recursive Name Server optionPatrik Flykt
Support DHCPv6 DNS server option as specified in RFC 3646. This option contains a list of IPv6 DNS server addresses.
2015-08-21sd-dhcp6-client: Save a DHCPv6 lease also with Information ReplyPatrik Flykt
As the lease structure contains interesting information, save it also for the Information Reply.
2015-08-21sd-dhcp6-client: Fix unreferencing DHCPv6 lease on client resetPatrik Flykt
When the DHCPv6 client is started by the library user or stopped for any reason, unref the DHCPv6 lease when resetting the DHCPv6 client data structure. This makes the DHCPv6 client always start from a clean state and not keep unnecessary an lease structure around when stopped. If this is not done, a previously existing lease information can be interpreted to be from another server when restarting DHCPv6.
2015-08-03sd-event: make sure sd_event_now() cannot failLennart Poettering
Previously, if the event loop never ran before sd_event_now() would fail. With this change it will instead fall back to invoking now(). This way, the function cannot fail anymore, except for programming error when invoking it with wrong parameters. This takes into account the fact that many callers did not handle the error condition correctly, and if the callers did, then they kept simply invoking now() as fall back on their own. Hence let's shorten the code using this call, and make things more robust, and let's just fall back to now() internally. Whether now() is used or the cache timestamp may still be detected via the return value of sd_event_now(). If > 0 is returned, then the fall back to now() was used, if == 0 is returned, then the cached value was returned. This patch also simplifies many of the invocations of sd_event_now(): the manual fall back to now() can be removed. Also, in cases where the call is invoked withing void functions we can now protect the invocation via assert_se(), acknowledging the fact that the call cannot fail anymore except for programming errors with the parameters. This change is inspired by #841.
2015-04-21dhcp6: remove unnecessary if checkLennart Poettering
2015-04-14sd-dhcp6-client: unref lease when freeing the clientThomas Hindoe Paaboel Andersen
2015-04-11shared: add random-util.[ch]Ronny Chevalier
2015-03-04sd-dhcp6-client: delay setting the DUID and don't fail constructorThomas Haller
sd_dhcp6_client_new() tried to set the DUID based on the machine id. If the host has no /etc/machine-id, the constructor would fail making it impossible to create an sd_dhcp6_client instance. Relax this and create a DUID only later as needed. This way a caller caller can workaround a missing machine-id file and set a DUID of his choosing via sd_dhcp6_client_set_duid().
2015-01-21network: dhcp - split out dhcp_identifier_set_{iaid,duid_en} from dhcp6-clientTom Gundersen
This will also be used in dhcp4-client.
2015-01-21network: dhcp - split out the duid structure into a new header fileTom Gundersen
We will use the same in both dhcp4 and dhcp6.
2015-01-20sd-dhcp6-client: Remove unnecessary debug printoutPatrik Flykt
2015-01-13refcnt: refcnt is unsigned, fix comparisonsTom Gundersen
This does not make a difference, but the code was confusing.
2014-12-10test-dhcp6-client: Add a simple Information Request test casePatrik Flykt
Start the DHCPv6 test case by sending an Information Request, verifying the reply and continuing at once with the normal address acquisition procedure. Reuse the DHCPv6 Solicit Reply so that the client code is verified to ignore any erroneously added IPv6 address information.
2014-12-10sd-dhcp6-client: Implement Information Request messagePatrik Flykt
Implement Information Request message according to RFC 3315, section 18.1.5. with the excepion that the first message is not delayed by a random amount. Instead systemd-networkd is supposed to take care of desynchronizing between other clients. Initialize the DHCPv6 client structure in sd_dhcp6_client_start() as this allows toggling between information request and normal DHCPv6 address aquisition modes.
2014-12-10sd-dhcp6-client: Make end of successfull option parsing explicitPatrik Flykt
When all DHCPv6 options have been parsed, dhcp6_option_parse() returns -ENOMSG. Explicitely set the return value to indicate success so that later code does not need to take this special value into account.
2014-11-04sd-event: rename sd_event_source_set_name() to sd_event_source_get_name()Lennart Poettering
To mirror the recent name change of the concept for sd_bus objects, follow the same logic for sd_event_source objects, too.
2014-11-01sd-dhcp6-client: fix off-by-two error in DUID lengthDan Williams
The duid data passed by the caller does not include the DUID type, but sd_dhcp6_client_set_duid() was treating it like it did.
2014-10-11sd-dhcp-client: support non-Ethernet hardware addressesDan Williams
Like Infiniband. See RFC 4390 section 2.1 for details on DHCP and Infiniband; chaddr is zeroed, hlen is set to 0, and htype is set to ARPHRD_INFINIBAND because IB hardware addresses are 20 bytes in length.
2014-10-02sd-dhcp6: do basic sanity-checking of supplied DUIDTom Gundersen
2014-10-02sd-dhcp6: specify the type explicitly when setting custom DUIDTom Gundersen
This would make it simple to verify that the data is on the right format when the type is known.
2014-10-02sd-dhcp6: support custom DUID's up to the size specified in the RFCTom Gundersen
2014-10-02sd-dhcp6-client: support custom DUIDsDan Williams
The caller may have an existing DUID that it wants to use, and may want to use some other DUID generation scheme than systemd's default DUID-EN. [tomegun: whitespace - we never use tabs]
2014-09-10sd-dhcp6-client: Implement Elapsed Time optionPatrik Flykt
Implement Elapsed Time option as it is defined as MUST in RFC 3315, section 22.9. The elapsed time value is a 1/100th of a second with a max value of 0xffff, i.e. 655.35 seconds. As the main loop might not be running yet when sd_dhcp6_client_start() is called, fetch the monotonic time directly and not from the event loop while in state DHCP6_STATE_STOPPED.
2014-08-30sd-dhcp6-client: properly calculate buffer size when parsing optionsZbigniew Jędrzejewski-Szmek
Also make pointer calculations more explicit so they are easier to understand.
2014-08-28sd-event: name event sources used in librariesTom Gundersen
This should help in debugging failing event sources.
2014-08-20indentation/spurious whitespace fixesLennart Poettering
2014-07-24libsystemd-network: use CLOCK_BOOTTIME instead of CLOCK_MONOTONIC where possibleTom Gundersen
The timeouts in the networking library (DHCP lease timeouts and similar) should not be affected by suspend. In the cases where CLOCK_BOOTTIME is not implemented, it is still safe to fallback to CLOCK_MONOTONIC, as the consumers of the library (i.e., networkd) _should_ renew the leases when coming out of suspend.
2014-07-23dhcp-network: remove unused DHCP6_STATE_RSDan Williams
Probably a left-over from when router solicitations were requested in the DHCP6 code. But since they are now separate, this state is no longer needed.
2014-07-14sd-dhcp6-client: make gcc happyTom Gundersen
It complains about {max,init}_retransmit_time possibly being uninitialized. It is wrong, but let's just initialize it.
2014-07-04networkd: don't clear dhcpv6 lease timers if there's no previous leaseSteven Noonan
If client->lease is NULL, dhcp6_lease_clear_timers will cause a segmentation fault.
2014-07-02sd-dhcp6-client: initialize variableTom Gundersen
2014-07-01sd-dhcp6-client: check return valueThomas Hindoe Paaboel Andersen
Checking the return values seems to have been forgotten in ed6ee21953dac9c78383da00bc4514ece6b75ab5
2014-07-01sd-dhcp6-client: fix free before useTom Gundersen
2014-06-26sd-dhcp6-client: Implement Rapid CommitPatrik Flykt
Add a Rapid Commit option to Solicit messages and expect a Reply to be received instead of an Advertise. When receiving a DHCPv6 message from the server in state Solicit, continue testing whether the message is a Reply. Ease up the message type checking, it's not fatal if the message is of a wrong type. Add helper functions to set/get the rapid commit of a lease. See RFC 3315, sections 17., 17.1.2., 17.1.4. and 18.1.8.
2014-06-26sd-dhcp6-client: Implement Renew and RebindPatrik Flykt
Start sending Renew and Rebind DHCPv6 messages when respective timers T1 and T2 expire. Rebind messages do not include a Server ID option and the Rebind procedure ends when the last IPv6 address valid lifetime expires, whereafter the client restarts the address acquisition procedure by Soliciting for available servers. See RFC 3315, sections 18.1.3. and 18.1.4. for details.
2014-06-26sd-dhcp6-client: Add Option Request Option supportPatrik Flykt
Provide a function to request more options from the DHCPv6 server. Provide a sensible default set at startup and add test basic test cases for the intended usage. Define DNS and NTP related option codes and add comments for the unassigned codes.
2014-06-26sd-dhcp6-client: return NULL from _unref() like the other sd-* librariesPatrik Flykt
In order to keep the refcounting working, a DONT_DESTROY macro similar to the one in sd-bus has been added also to DHCPv6.
2014-06-24sd-dhcp6-client: use %m instead of strerror(errno)Ronny Chevalier
2014-06-20sd-dhcp6-client: fix uninitialized variablesRonny Chevalier
2014-06-19sd-dhcp6-client: Initialize fd to -1 and rename functionZbigniew Jędrzejewski-Szmek
client_initialize name is misleading, since the function is actually useful at the *end*, to reinitialize the object. But reset is shorter, so rename it to client_reset.
2014-06-19sd-dhcp6-client: Receive and parse a reply and set T1 and T2 timersPatrik 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.
2014-06-19sd-dhcp6-client: Add Request message sendingPatrik 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 be received after the first timeout, IPv6 address requesting is started immediately. In response to these events, create a Request message and set up proper resend timers to send the message to the server.
2014-06-19sd-dhcp6-client: Update start function to take a statePatrik Flykt
Update the start function so that the client state can be conveniently changed with the previous message resend timers cleared. On initial startup also create and bind to the UDP socket.
2014-06-19sd-dhcp6-lease: Add functions for accessing lease and addressesPatrik Flykt
Add support functions for accessing the current client lease as well as iterating over the addresses and get their preferred and valid lifetimes.