2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2014-06-19 14:38:55 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/***
|
2018-06-12 17:15:23 +02:00
|
|
|
Copyright © 2014-2015 Intel Corporation. All rights reserved.
|
2014-06-19 14:38:55 +02:00
|
|
|
***/
|
|
|
|
|
|
|
|
#include <net/ethernet.h>
|
2014-06-19 14:39:08 +02:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include "sd-event.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
|
2014-06-19 14:39:08 +02:00
|
|
|
#include "list.h"
|
2014-06-19 14:39:27 +02:00
|
|
|
#include "macro.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "sparse-endian.h"
|
2014-06-19 14:39:08 +02:00
|
|
|
|
2018-01-04 14:11:41 +01:00
|
|
|
/* Common option header */
|
|
|
|
typedef struct DHCP6Option {
|
|
|
|
be16_t code;
|
|
|
|
be16_t len;
|
|
|
|
uint8_t data[];
|
|
|
|
} _packed_ DHCP6Option;
|
|
|
|
|
2018-01-04 14:11:43 +01:00
|
|
|
/* Address option */
|
|
|
|
struct iaaddr {
|
|
|
|
struct in6_addr address;
|
|
|
|
be32_t lifetime_preferred;
|
|
|
|
be32_t lifetime_valid;
|
|
|
|
} _packed_;
|
|
|
|
|
2018-01-04 14:11:46 +01:00
|
|
|
/* Prefix Delegation Prefix option */
|
|
|
|
struct iapdprefix {
|
|
|
|
be32_t lifetime_preferred;
|
|
|
|
be32_t lifetime_valid;
|
|
|
|
uint8_t prefixlen;
|
|
|
|
struct in6_addr address;
|
|
|
|
} _packed_;
|
|
|
|
|
2014-06-19 14:39:08 +02:00
|
|
|
typedef struct DHCP6Address DHCP6Address;
|
|
|
|
|
|
|
|
struct DHCP6Address {
|
|
|
|
LIST_FIELDS(DHCP6Address, addresses);
|
|
|
|
|
2018-01-04 14:11:46 +01:00
|
|
|
union {
|
|
|
|
struct iaaddr iaaddr;
|
|
|
|
struct iapdprefix iapdprefix;
|
|
|
|
};
|
2014-06-19 14:39:08 +02:00
|
|
|
};
|
|
|
|
|
2018-01-04 14:11:40 +01:00
|
|
|
/* Non-temporary Address option */
|
|
|
|
struct ia_na {
|
|
|
|
be32_t id;
|
|
|
|
be32_t lifetime_t1;
|
|
|
|
be32_t lifetime_t2;
|
|
|
|
} _packed_;
|
|
|
|
|
2018-01-04 14:11:46 +01:00
|
|
|
/* Prefix Delegation option */
|
|
|
|
struct ia_pd {
|
|
|
|
be32_t id;
|
|
|
|
be32_t lifetime_t1;
|
|
|
|
be32_t lifetime_t2;
|
|
|
|
} _packed_;
|
|
|
|
|
2018-01-04 14:11:40 +01:00
|
|
|
/* Temporary Address option */
|
|
|
|
struct ia_ta {
|
|
|
|
be32_t id;
|
|
|
|
} _packed_;
|
|
|
|
|
2014-06-19 14:39:08 +02:00
|
|
|
struct DHCP6IA {
|
|
|
|
uint16_t type;
|
2018-01-04 14:11:40 +01:00
|
|
|
union {
|
|
|
|
struct ia_na ia_na;
|
2018-01-04 14:11:46 +01:00
|
|
|
struct ia_pd ia_pd;
|
2018-01-04 14:11:40 +01:00
|
|
|
struct ia_ta ia_ta;
|
|
|
|
};
|
2014-06-19 14:39:08 +02:00
|
|
|
|
|
|
|
LIST_HEAD(DHCP6Address, addresses);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct DHCP6IA DHCP6IA;
|
2014-06-19 14:38:55 +02:00
|
|
|
|
2016-05-15 16:46:17 +02:00
|
|
|
#define log_dhcp6_client_errno(p, error, fmt, ...) log_internal(LOG_DEBUG, error, __FILE__, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
|
|
|
|
#define log_dhcp6_client(p, fmt, ...) log_dhcp6_client_errno(p, 0, fmt, ##__VA_ARGS__)
|
2014-06-19 14:38:55 +02:00
|
|
|
|
2014-06-19 14:39:20 +02:00
|
|
|
int dhcp6_option_append(uint8_t **buf, size_t *buflen, uint16_t code,
|
|
|
|
size_t optlen, const void *optval);
|
2018-10-19 12:11:29 +02:00
|
|
|
int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, const DHCP6IA *ia);
|
|
|
|
int dhcp6_option_append_pd(uint8_t *buf, size_t len, const DHCP6IA *pd);
|
2017-11-16 10:07:07 +01:00
|
|
|
int dhcp6_option_append_fqdn(uint8_t **buf, size_t *buflen, const char *fqdn);
|
2014-06-19 14:39:20 +02:00
|
|
|
int dhcp6_option_parse(uint8_t **buf, size_t *buflen, uint16_t *optcode,
|
|
|
|
size_t *optlen, uint8_t **optvalue);
|
2018-09-30 13:23:58 +02:00
|
|
|
int dhcp6_option_parse_status(DHCP6Option *option, size_t len);
|
2018-01-04 14:11:41 +01:00
|
|
|
int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia);
|
2015-04-02 09:35:30 +02:00
|
|
|
int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
|
|
|
|
struct in6_addr **addrs, size_t count,
|
|
|
|
size_t *allocated);
|
2015-05-04 12:23:46 +02:00
|
|
|
int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen,
|
|
|
|
char ***str_arr);
|
2014-06-19 14:39:23 +02:00
|
|
|
|
|
|
|
int dhcp6_network_bind_udp_socket(int index, struct in6_addr *address);
|
|
|
|
int dhcp6_network_send_udp_socket(int s, struct in6_addr *address,
|
|
|
|
const void *packet, size_t len);
|
2014-06-19 14:39:27 +02:00
|
|
|
|
|
|
|
const char *dhcp6_message_type_to_string(int s) _const_;
|
|
|
|
int dhcp6_message_type_from_string(const char *s) _pure_;
|
2014-06-19 14:39:42 +02:00
|
|
|
const char *dhcp6_message_status_to_string(int s) _const_;
|
|
|
|
int dhcp6_message_status_from_string(const char *s) _pure_;
|