2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2014-02-27 01:24:05 +01:00
|
|
|
#ifndef foosddhcpleasehfoo
|
|
|
|
#define foosddhcpleasehfoo
|
2014-02-04 23:13:52 +01:00
|
|
|
|
|
|
|
/***
|
|
|
|
This file is part of systemd.
|
|
|
|
|
|
|
|
Copyright (C) 2013 Intel Corporation. All rights reserved.
|
|
|
|
Copyright (C) 2014 Tom Gundersen
|
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
systemd is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
|
2015-10-24 23:42:56 +02:00
|
|
|
#include <inttypes.h>
|
2014-02-27 01:24:05 +01:00
|
|
|
#include <net/ethernet.h>
|
2015-10-24 23:42:56 +02:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "_sd-common.h"
|
|
|
|
|
|
|
|
_SD_BEGIN_DECLARATIONS;
|
2014-02-04 23:13:52 +01:00
|
|
|
|
2014-02-27 01:24:05 +01:00
|
|
|
typedef struct sd_dhcp_lease sd_dhcp_lease;
|
2016-01-20 14:44:14 +01:00
|
|
|
typedef struct sd_dhcp_route sd_dhcp_route;
|
2014-02-04 23:13:52 +01:00
|
|
|
|
2014-02-27 01:24:05 +01:00
|
|
|
sd_dhcp_lease *sd_dhcp_lease_ref(sd_dhcp_lease *lease);
|
|
|
|
sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease);
|
2014-07-16 00:26:02 +02:00
|
|
|
|
2014-02-27 01:24:05 +01:00
|
|
|
int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr);
|
2014-06-26 15:18:43 +02:00
|
|
|
int sd_dhcp_lease_get_lifetime(sd_dhcp_lease *lease, uint32_t *lifetime);
|
dhcp: clean up dhcp4 lease object
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-27 01:05:13 +02:00
|
|
|
int sd_dhcp_lease_get_t1(sd_dhcp_lease *lease, uint32_t *t1);
|
|
|
|
int sd_dhcp_lease_get_t2(sd_dhcp_lease *lease, uint32_t *t2);
|
|
|
|
int sd_dhcp_lease_get_broadcast(sd_dhcp_lease *lease, struct in_addr *addr);
|
2014-02-27 01:24:05 +01:00
|
|
|
int sd_dhcp_lease_get_netmask(sd_dhcp_lease *lease, struct in_addr *addr);
|
|
|
|
int sd_dhcp_lease_get_router(sd_dhcp_lease *lease, struct in_addr *addr);
|
2014-03-03 17:13:59 +01:00
|
|
|
int sd_dhcp_lease_get_next_server(sd_dhcp_lease *lease, struct in_addr *addr);
|
2014-03-03 16:46:10 +01:00
|
|
|
int sd_dhcp_lease_get_server_identifier(sd_dhcp_lease *lease, struct in_addr *addr);
|
2014-07-17 01:39:46 +02:00
|
|
|
int sd_dhcp_lease_get_dns(sd_dhcp_lease *lease, const struct in_addr **addr);
|
|
|
|
int sd_dhcp_lease_get_ntp(sd_dhcp_lease *lease, const struct in_addr **addr);
|
2014-02-27 01:24:05 +01:00
|
|
|
int sd_dhcp_lease_get_mtu(sd_dhcp_lease *lease, uint16_t *mtu);
|
|
|
|
int sd_dhcp_lease_get_domainname(sd_dhcp_lease *lease, const char **domainname);
|
2017-05-13 16:19:32 +02:00
|
|
|
int sd_dhcp_lease_get_search_domains(sd_dhcp_lease *lease, char ***domains);
|
2014-02-27 01:24:05 +01:00
|
|
|
int sd_dhcp_lease_get_hostname(sd_dhcp_lease *lease, const char **hostname);
|
2014-03-03 15:43:02 +01:00
|
|
|
int sd_dhcp_lease_get_root_path(sd_dhcp_lease *lease, const char **root_path);
|
2016-01-20 14:44:14 +01:00
|
|
|
int sd_dhcp_lease_get_routes(sd_dhcp_lease *lease, sd_dhcp_route ***routes);
|
dhcp: clean up dhcp4 lease object
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-27 01:05:13 +02:00
|
|
|
int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const void **data, size_t *data_len);
|
|
|
|
int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const void **client_id, size_t *client_id_len);
|
2015-08-26 19:19:32 +02:00
|
|
|
int sd_dhcp_lease_get_timezone(sd_dhcp_lease *lease, const char **timezone);
|
2014-07-16 00:26:02 +02:00
|
|
|
|
2016-01-20 14:44:14 +01:00
|
|
|
int sd_dhcp_route_get_destination(sd_dhcp_route *route, struct in_addr *destination);
|
|
|
|
int sd_dhcp_route_get_destination_prefix_length(sd_dhcp_route *route, uint8_t *length);
|
|
|
|
int sd_dhcp_route_get_gateway(sd_dhcp_route *route, struct in_addr *gateway);
|
|
|
|
|
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
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-27 19:13:45 +01:00
|
|
|
_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_dhcp_lease, sd_dhcp_lease_unref);
|
|
|
|
|
2015-10-24 23:42:56 +02:00
|
|
|
_SD_END_DECLARATIONS;
|
|
|
|
|
2014-02-27 01:24:05 +01:00
|
|
|
#endif
|