summaryrefslogtreecommitdiff
path: root/src/libsystemd-dhcp
AgeCommit message (Collapse)Author
2014-02-20sd-dhcp-client: prevent timer related memory leaksUmut Tezduyar Lindskog
2014-02-20api: in constructor function calls, always put the returned object pointer ↵Lennart Poettering
first (or second) Previously the returned object of constructor functions where sometimes returned as last, sometimes as first and sometimes as second parameter. Let's clean this up a bit. Here are the new rules: 1. The object the new object is derived from is put first, if there is any 2. The object we are creating will be returned in the next arguments 3. This is followed by any additional arguments Rationale: For functions that operate on an object we always put that object first. Constructors should probably not be too different in this regard. Also, if the additional parameters might want to use varargs which suggests to put them last. Note that this new scheme only applies to constructor functions, not to all other functions. We do give a lot of freedom for those. Note that this commit only changes the order of the new functions we added, for old ones we accept the wrong order and leave it like that.
2014-02-19sd-dhcp-client: fix mixup between raw and udp socketsTom Gundersen
2014-02-18libsystemd-dhcp: Add a full DHCP address acquisition test casePatrik 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. Follow exactly the same steps when receiving a DHCP Request in test_addr_acq_recv_request() and send the Ack. Check that the proper addresses have been found by the DHCP library before exiting the main loop and finishing the test.
2014-02-18libsystemd-dhcp: Factor out test code for DHCP message verificationPatrik Flykt
Add a callback function that will handle the test case specific checking.
2014-02-18libsystemd-dhcp: Add capability to print out test stepsPatrik Flykt
2014-02-16sd-dhcp: silently ignore malformed packetsTom Gundersen
This fixes a regression introduced in e5002702.
2014-02-15sd-dhcp: network - don't hardcode portsTom Gundersen
We want to reuse these functions for the server library too.
2014-02-15sd-dhcp: minimum options size is part of the protocolTom Gundersen
2014-02-15sd-dhcp-client: explicitly handle raw and udp messagesTom Gundersen
Split the recevie_message callback into _raw and _udp parts and a generic DHCPMessage handler. Also always verify the xid/MAC, rather than only for udp messages.
2014-02-12sd-dhcp: make sure client->secs > 0Tom Gundersen
Some DHCP servers will not work correctly if secs == 0, so round up to at least 1.
2014-02-11sd-dhcp: split out packet handling from clientTom Gundersen
2014-02-07sd-dhcp-client: split sd_dhcp_lease from sd_dhcp_clientTom Gundersen
This allows us users of the library to keep copies of old leases. This is used by networkd to know what addresses to drop (if any) when the lease expires. In the future this may be used by DNAv4 and sd-dhcp-server.
2014-01-31libsystemd-dhcp: Update secs field only when sending DiscoverPatrik 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.
2014-01-31libsystemd-dhcp: Fix stopping of DHCP clientPatrik Flykt
Go back to Init state independent of the current state the client is in.
2014-01-31libsystemd-dhcp: Compute UDP checksum only if setPatrik Flykt
A checksum field with value zero means no UDP checksum has been computed for the packet.
2014-01-31libsystemd-dhcp: Rename function to be clearer that options are parsedPatrik Flykt
2014-01-31libsystemd-dhcp: DNS name option must be a multiple of 4 bytesPatrik Flykt
2014-01-30sd-dhcp-client/net-util: make netmask_to_prefixlen genericTom Gundersen
This was originally included in the dhcp-client at my request, but it is not really dhcp-specific and useful outside of it, so let's pull it out.
2014-01-21libsystemd-dhcp: revert merge into libsystemdTom Gundersen
Unlike the other merged libs, the rest of libsystemd will never depend on sd-dhcp-client, so there is no reason not to keep it separate.
2014-01-13libsystemd-dhcp: merge into libsystemdTom Gundersen
2014-01-06libsystemd-dns: expose list of DNS serversTom Gundersen
My original patch only returned the first DNS server, but we might want all of them.
2014-01-05libsystemd-dhcp: expose received DNS serverTom Gundersen
2014-01-03libsystemd-dhcp: don't assert on client_stop()Tom Gundersen
We need to be able to stop the dhcp client at any time, and the function appears to be written to handle this.
2013-12-31dhcp: fix creation of req_opts arrayZbigniew Jędrzejewski-Szmek
GREEDY_REALLOC needs to have two size variables: one for the allocated size, and a second one for the used size. Using the allocated size only lead to leaving some elements unitialized and assigning some more than once.
2013-12-22shared: switch our hash table implementation over to SipHashLennart Poettering
SipHash appears to be the new gold standard for hashing smaller strings for hashtables these days, so let's make use of it.
2013-12-22libsystemd-dhcp: add some assertsTom Gundersen
2013-12-22libsystemd-dhcp: Handle T2 Rebinding timeoutPatrik Flykt
Reuse existing functionality when adding T2 Rebinding support.
2013-12-22libsystemd-dhcp: Factor out common code initializing eventsPatrik Flykt
Factor out common code from timeout T1 handling and starting of the DHCP client.
2013-12-22libsystemd-dhcp: Handle T1 Renewing timeoutPatrik 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 Request sending to send only UDP DHCP data when unicasting. Also modify DHCP Ack/Nak receiving such that the client_receive_ack() takes care of using either the full IP, UDP, DHCP packet or only the DHCP payload depending whether the client is in Requesting or Renewing state. Finally always report DHCP_EVENT_IP_ACQUIRE from Requesting state and only DHCP_EVENT_IP_CHANGE if the IP address was modified when the lease was renewed.
2013-12-22libsystemd-dhcp: Add functions for sending unicast UDP messagesPatrik Flykt
Create a helper functions setting up an unicast DHCP UDP socket and sending data. Add function stubs for the test program. [tomegun: initialize structs when allocating, and drop unneccesary 'err']
2013-12-22libsystemd-dhcp: Check test result without casting valuePatrik Flykt
2013-12-22libsystemd-dhcp: Fix checksum computation for buffer with odd sizePatrik 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.
2013-12-22libsystemd-dhcp: Fix receiving of other message when expecting AckPatrik 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.
2013-12-22libsystemd-dhcp: Unref event source before closing socketPatrik Flykt
2013-12-22libsystemd-dhcp: Return proper error on OOMPatrik Flykt
2013-12-22libsystemd-dhcp: Return proper error if bind failsPatrik Flykt
This also fixes a minor indentation damage. [tomegun: use close_noint_nofail() instead and drop 'err' variables]
2013-12-22libsystemd-dhcp: Use be32_t for IP addresses in network order.Patrik Flykt
2013-12-17dhcp: Properly handle unsuccessful cases for DHCP AckPatrik Flykt
Ignore DHCP Ack packets if they are found to be erroneous or have an unexpected xid by setting the result to zero instead of propagating an error. Also remember to report a DHCP Nak and stop the DHCP client.
2013-12-12scan-build: silence some warningsThomas Hindoe Paaboel Andersen
test-fileio/test-strv: Use the streq_ptr to make build-scan not worry about passing in a null to a nonnull function. test-dhcp-option: Prevent a theoretical null pointer dereference
2013-12-12dhcp: Add function to free DHCP client dataPatrik Flykt
2013-12-12dhcp: Add notification callbackPatrik Flykt
Define a notification callback and events for stopping and client lease expiry. Add functions to fetch IP parameters from a lease.
2013-12-12dhcp: Compute expire, T1 and T2 timersPatrik Flykt
Compute the default T1 and T2 timer values if they were not set by the DHCP server. Verify that the values are reasonable.
2013-12-12dhcp: Process DHCP Ack/Nak messagePatrik 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.
2013-12-12dhcp: Add maximum message size optionPatrik Flykt
Add maximum message size option to keep some DHCP server implementations from sending too big messages. See ConnMan commit 0c5c862749c05193cf4c513628328c6db02b5222.
2013-12-12dhcp: Send DHCP Request to acquire an IP addressPatrik 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 calculation, bail out if there are errors while resending the DHCP message for the sixth or more times.
2013-12-12dhcp: Handle received DHCP Offer messagePatrik 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 creation and a sending part. As a result modify the test code.
2013-12-12dhcp: Add timeout and main loop supportPatrik 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.
2013-12-12dhcp: Add function to stop the DHCP clientPatrik Flykt
The client is stopped and brought back to its initial state.
2013-12-12dhcp: Support seconds elapsed since start of DHCP negotiationPatrik 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 their DISCOVER or REQUEST packets."