Lines Matching defs:lease

24 #include "dhcp6-lease-internal.h"
79 int dhcp6_lease_set_serverid(sd_dhcp6_lease *lease, const uint8_t *id,
81 assert_return(lease, -EINVAL);
84 free(lease->serverid);
86 lease->serverid = memdup(id, len);
87 if (!lease->serverid)
90 lease->serverid_len = len;
95 int dhcp6_lease_get_serverid(sd_dhcp6_lease *lease, uint8_t **id, size_t *len) {
96 assert_return(lease, -EINVAL);
100 *id = lease->serverid;
101 *len = lease->serverid_len;
106 int dhcp6_lease_set_preference(sd_dhcp6_lease *lease, uint8_t preference) {
107 assert_return(lease, -EINVAL);
109 lease->preference = preference;
114 int dhcp6_lease_get_preference(sd_dhcp6_lease *lease, uint8_t *preference) {
117 if (!lease)
120 *preference = lease->preference;
125 int dhcp6_lease_set_rapid_commit(sd_dhcp6_lease *lease) {
126 assert_return(lease, -EINVAL);
128 lease->rapid_commit = true;
133 int dhcp6_lease_get_rapid_commit(sd_dhcp6_lease *lease, bool *rapid_commit) {
134 assert_return(lease, -EINVAL);
137 *rapid_commit = lease->rapid_commit;
142 int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid) {
143 assert_return(lease, -EINVAL);
146 *iaid = lease->ia.id;
151 int sd_dhcp6_lease_get_address(sd_dhcp6_lease *lease, struct in6_addr *addr,
154 assert_return(lease, -EINVAL);
159 if (!lease->addr_iter)
162 memcpy(addr, &lease->addr_iter->iaaddr.address,
165 be32toh(lease->addr_iter->iaaddr.lifetime_preferred);
166 *lifetime_valid = be32toh(lease->addr_iter->iaaddr.lifetime_valid);
168 lease->addr_iter = lease->addr_iter->addresses_next;
173 void sd_dhcp6_lease_reset_address_iter(sd_dhcp6_lease *lease) {
174 if (lease)
175 lease->addr_iter = lease->ia.addresses;
178 int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
181 assert_return(lease, -EINVAL);
187 r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->dns,
188 lease->dns_count,
189 &lease->dns_allocated);
197 lease->dns_count = r;
202 int sd_dhcp6_lease_get_dns(sd_dhcp6_lease *lease, struct in6_addr **addrs) {
203 assert_return(lease, -EINVAL);
206 if (lease->dns_count) {
207 *addrs = lease->dns;
208 return lease->dns_count;
214 int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval,
219 assert_return(lease, -EINVAL);
229 free(lease->domains);
230 lease->domains = domains;
231 lease->domains_count = r;
236 int sd_dhcp6_lease_get_domains(sd_dhcp6_lease *lease, char ***domains) {
237 assert_return(lease, -EINVAL);
240 if (lease->domains_count) {
241 *domains = lease->domains;
242 return lease->domains_count;
248 int dhcp6_lease_set_ntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
254 assert_return(lease, -EINVAL);
257 lease->ntp = mfree(lease->ntp);
258 lease->ntp_count = 0;
259 lease->ntp_allocated = 0;
273 &lease->ntp,
274 lease->ntp_count,
275 &lease->ntp_allocated);
279 lease->ntp_count = s;
289 lease->ntp_fqdn = strv_free(lease->ntp_fqdn);
290 lease->ntp_fqdn = servers;
291 lease->ntp_fqdn_count = r;
303 int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen) {
306 assert_return(lease, -EINVAL);
312 if (lease->ntp || lease->ntp_fqdn) {
320 r = dhcp6_option_parse_ip6addrs(optval, optlen, &lease->ntp,
321 lease->ntp_count,
322 &lease->ntp_allocated);
330 lease->ntp_count = r;
335 int sd_dhcp6_lease_get_ntp_addrs(sd_dhcp6_lease *lease,
337 assert_return(lease, -EINVAL);
340 if (lease->ntp_count) {
341 *addrs = lease->ntp;
342 return lease->ntp_count;
348 int sd_dhcp6_lease_get_ntp_fqdn(sd_dhcp6_lease *lease, char ***ntp_fqdn) {
349 assert_return(lease, -EINVAL);
352 if (lease->ntp_fqdn_count) {
353 *ntp_fqdn = lease->ntp_fqdn;
354 return lease->ntp_fqdn_count;
360 sd_dhcp6_lease *sd_dhcp6_lease_ref(sd_dhcp6_lease *lease) {
362 if (!lease)
365 assert(lease->n_ref >= 1);
366 lease->n_ref++;
368 return lease;
371 sd_dhcp6_lease *sd_dhcp6_lease_unref(sd_dhcp6_lease *lease) {
373 if (!lease)
376 assert(lease->n_ref >= 1);
377 lease->n_ref--;
379 if (lease->n_ref > 0)
382 free(lease->serverid);
383 dhcp6_lease_free_ia(&lease->ia);
385 free(lease->dns);
387 lease->domains = strv_free(lease->domains);
389 free(lease->ntp);
391 lease->ntp_fqdn = strv_free(lease->ntp_fqdn);
392 free(lease);
398 sd_dhcp6_lease *lease;
400 lease = new0(sd_dhcp6_lease, 1);
401 if (!lease)
404 lease->n_ref = 1;
406 LIST_HEAD_INIT(lease->ia.addresses);
408 *ret = lease;