summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/dhcp-lease-internal.h
AgeCommit message (Collapse)AuthorFilesLines
2019-09-20network: DHCP server Add support to transmit SIP serverSusant Sahani1-0/+3
1. DHCP server trasmit 2. Client parses and saves in leases Implements http://www.rfc-editor.org/rfc/rfc3361.txt ``` Frame 134: 348 bytes on wire (2784 bits), 348 bytes captured (2784 bits) on interface 0 Ethernet II, Src: 42:65:85:d6:4e:32 (42:65:85:d6:4e:32), Dst: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4) Internet Protocol Version 4, Src: 192.168.5.1, Dst: 192.168.5.11 User Datagram Protocol, Src Port: 67, Dst Port: 68 Dynamic Host Configuration Protocol (ACK) Message type: Boot Reply (2) Hardware type: Ethernet (0x01) Hardware address length: 6 Hops: 0 Transaction ID: 0x7cc87cb4 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 0.0.0.0 Your (client) IP address: 192.168.5.11 Next server IP address: 0.0.0.0 Relay agent IP address: 0.0.0.0 Client MAC address: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4) Client hardware address padding: 00000000000000000000 Server host name not given Boot file name not given Magic cookie: DHCP Option: (53) DHCP Message Type (ACK) Length: 1 DHCP: ACK (5) Option: (51) IP Address Lease Time Length: 4 IP Address Lease Time: (3600s) 1 hour Option: (1) Subnet Mask (255.255.255.0) Length: 4 Subnet Mask: 255.255.255.0 Option: (3) Router Length: 4 Router: 192.168.5.1 Option: (6) Domain Name Server Length: 4 Domain Name Server: 192.168.5.1 Option: (42) Network Time Protocol Servers Length: 4 Network Time Protocol Server: 192.168.1.1 Option: (120) SIP Servers <=====here Length: 9 SIP Server Encoding: IPv4 Address (1) SIP Server Address: 192.168.1.1 SIP Server Address: 192.168.5.2 Option: (101) TCode Length: 13 TZ TCode: Europe/Berlin Option: (54) DHCP Server Identifier (192.168.5.1) Length: 4 DHCP Server Identifier: 192.168.5.1 Option: (255) End Option End: 255 ``` ``` cat /run/systemd/netif/state  ✔  ⚡  3148  16:40:51 OPER_STATE=routable CARRIER_STATE=carrier ADDRESS_STATE=routable DNS=192.168.94.2 192.168.5.1 NTP=192.168.5.1 SIP=192.168.1.1 192.168.5.2 ``` aa
2019-02-18dhcp: handle multiple addresses for "Router" (option 3) in DHCP libraryThomas Haller1-1/+3
The Router DHCP option may contain a list of one or more routers ([1]). Extend the API of sd_dhcp_lease to return a list instead of only the first. Note that networkd still only uses the first router (if present). Aside from extending the internal API of the DHCP client, there is almost no change in behavior. The only visible difference in behavior is that the "ROUTER" variable in the lease file is now a list of addresses. Note how RFC 2132 does not define certain IP addresses as invalid for the router option. Still, previously sd_dhcp_lease_get_router() would never return a "0.0.0.0" address. In fact, the previous API could not differenciate whether no router option was present, whether it was invalid, or whether its first router was "0.0.0.0". No longer let the DHCP client library impose additional restrictions that are not part of RFC. Instead, the caller should handle this. The patch does that, and networkd only consideres the first router entry if it is not "0.0.0.0". [1] https://tools.ietf.org/html/rfc2132#section-3.5
2018-06-20tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek1-1/+0
Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
2018-06-14tree-wide: use proper unicode © instead of (C) where we canLennart Poettering1-2/+2
Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
2018-06-14tree-wide: drop 'This file is part of systemd' blurbLennart Poettering1-2/+0
This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
2018-04-06tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek1-13/+0
Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
2018-01-20networkd: ignore Static Routes option when Classless Static Routes is given ↵Susant Sahani1-0/+2
(#7807) When the DHCP server returns both a Classless Static Routes option and a Static Routes option, the DHCP client MUST ignore the Static Routes option. Closes #7792
2017-11-19Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek1-0/+1
This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-05-13network: Implement DHCP Option 119 (Domain Search List) (#5932)Daniel Wang1-0/+2
This adds a modified version of dhcp6_option_parse_domainname() that is able to parse compressed domain names, borrowing the idea from dns_packet_read_name(). It also adds pieces in networkd-link and networkd-manager to properly save/load the added option field. Resolves #2710.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack1-2/+0
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering1-3/+0
GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
2015-11-18tree-wide: sort includes in *.hThomas Hindoe Paaboel Andersen1-4/+3
This is a continuation of the previous include sort patch, which only sorted for .c files.
2015-08-27dhcp: fix n_ref typeLennart Poettering1-1/+1
Fixes fallout from 3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8.
2015-08-27dhcp: clean up dhcp4 lease objectLennart Poettering1-22/+26
a) drop handling of obsolete or unused DHCP options time_offset, mtu_aging_timeout, policy filter, mdr, ttl, ip forwarding settings. Should this become useful one day we can readd support for this. b) For subnet mask and broadcast it is not always clear whether 0 or 255.255.255.255 might be valid, hence maintain a boolean indicating validity next to it. c) serialize/deserialize broadcast address, lifetime, T1 and T2 together with the rest of the fields in dhcp_lease_save() and dhcp_lease_load(). d) consistently return ENODATA from getter functions for data that is missing in the lease. e) add missing getter calls for broadcast, lifetime, T1, T2. f) when decoding DHCP options, generate debug messages on parse failures, but try to proceed if possible. g) Similar, when deserializing a lease in dhcp_lease_load(), make sure we deal nicely with unparsable fields, to provide upgrade compat. h) fix some memory allocations
2015-08-26dhcp: generic data should be void*, not uint8_t*Lennart Poettering1-5/+5
If we handly arbitrary data we should use "void*" pointers, not "uint8_t*", how go intended C to be used.
2015-08-26network: s/user_data/userdata/Lennart Poettering1-1/+1
Everywhere else we call the generic user data pointer just "userdata", rather than "user_data". Let's do this here, too.
2015-08-26dhcp: stop using refcnt.hLennart Poettering1-2/+1
No need to invole atomic ops in single-threaded APIs, let's simplify this.
2015-08-26dhcp: keep lease save/load functions privateLennart Poettering1-0/+3
When we make sd-dhcp public one day we really should not make sd_dhcp_lease_save() and sd_dhcp_lease_load() public, since it's pretty much only useful as internal utility for networkd itself.
2015-08-26dhcp,network: implement RFC 4833 (DHCP Timezone option)Lennart Poettering1-0/+1
This one is simply to add: encode the tzdata timezone in the DHCP options and optionally make use of it.
2015-08-05networkd: add private options to lease structAlex Crawford1-0/+12
This stores private-zone DHCP options inside of their respective DHCP lease. These options aren't used by networkd (what would it do with them?), but saving them will allow other programs to query the values. To improve performance, the options are stored in ascending order by tag.
2015-07-12dhcp: add support for vendor specific DHCP optionBeniamino Galvani1-0/+2
This adds support for option 43 (Vendor Specific Information) to libsystemd-network DHCP code. The option carries an opaque object of n octets, interpreted by vendor-specific code on the clients and servers. [@zonque: adopted to new unhexmem() API]
2014-11-19sd-dhcp-lease: load/save client IDDan Williams1-0/+5
The lease is usually tied to the client ID, so users of the lease may want to know what client ID it was acquired with.
2014-11-18sd-dhcp-lease: expose load/save functionsTom Gundersen1-3/+0
Based on patch by Dan Williams.
2014-11-01sd-dhcp-lease: use shared default prefixlen functionTom Gundersen1-1/+1
Also change the default prefixlen function to only access the first octet of the in_addr.
2014-06-29Add support for DHCP static route optionsEugene Yakubovich1-1/+8
This adds support for DHCP options 33 and 121: Static Route and Classless Static Route. To enable this feature, set UseRoutes=true in .network file. Returned routes are added to the routing table.
2014-05-20dhcp-lease: add support for parsing a few more dhcp optionsTom Gundersen1-0/+12
2014-05-19sd-dhcp-lease: move in_addr (de)serialization to shared network codeTom Gundersen1-0/+1
2014-04-29sd-dhcp-lease: add NTP supportTom Gundersen1-0/+2
Export the NTP servers so timesyncd can use them.
2014-03-21sd-dhcp-client: add fallback subnet masksTom Gundersen1-0/+2
The DHCP RFC does not require the DHCP server to send a subnet mask, so if it is missing, let's try to use the default subnet masks based on address class. In case the class the address belongs to does not have a default subnet mask, we fail as before. Also improve logging when handling invalid dhcp messages, and simply ignore them rather than stop the whole dhcp client.
2014-03-03sd-dhcp-lease: add sd_dhcp_lease_get_next_server()Tom Gundersen1-0/+1
2014-03-03sd-dhcp-lease: add Root Path supportTom Gundersen1-0/+1
This is necessary when mounting /dev/nfs based on a DHCP lease.
2014-02-28sd-network: add new libraryTom Gundersen1-0/+59
This is similar to sd-login, but exposes the state of networkd rather than logind. Include it in libsystemd-dhcp and rename it to libsystemd-network.