]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-identifier.h
sd-network: DHCPv6 - Add support to send vendor class data
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-identifier.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
764aad62
TG
2#pragma once
3
07630cea 4#include "sd-id128.h"
764aad62 5
c1ff5570 6#include "macro.h"
764aad62 7#include "sparse-endian.h"
335f80a6 8#include "time-util.h"
9ee18af3 9#include "unaligned.h"
764aad62 10
73c8ced7
SS
11#define SYSTEMD_PEN 43793
12
413708d1 13typedef enum DUIDType {
413708d1
VK
14 DUID_TYPE_LLT = 1,
15 DUID_TYPE_EN = 2,
16 DUID_TYPE_LL = 3,
17 DUID_TYPE_UUID = 4,
18 _DUID_TYPE_MAX,
19 _DUID_TYPE_INVALID = -1,
20} DUIDType;
21
764aad62
TG
22/* RFC 3315 section 9.1:
23 * A DUID can be no more than 128 octets long (not including the type code).
24 */
25#define MAX_DUID_LEN 128
26
3b6a4e97 27/* https://tools.ietf.org/html/rfc3315#section-9.1 */
764aad62 28struct duid {
413708d1 29 be16_t type;
764aad62
TG
30 union {
31 struct {
3b6a4e97 32 /* DUID_TYPE_LLT */
9d7b8c66
YW
33 be16_t htype;
34 be32_t time;
764aad62
TG
35 uint8_t haddr[0];
36 } _packed_ llt;
37 struct {
3b6a4e97 38 /* DUID_TYPE_EN */
9d7b8c66 39 be32_t pen;
764aad62
TG
40 uint8_t id[8];
41 } _packed_ en;
42 struct {
3b6a4e97 43 /* DUID_TYPE_LL */
9d7b8c66 44 be16_t htype;
764aad62
TG
45 uint8_t haddr[0];
46 } _packed_ ll;
47 struct {
3b6a4e97 48 /* DUID_TYPE_UUID */
764aad62
TG
49 sd_id128_t uuid;
50 } _packed_ uuid;
51 struct {
52 uint8_t data[MAX_DUID_LEN];
53 } _packed_ raw;
54 };
55} _packed_;
cfb5b380 56
ab4a88bc 57int dhcp_validate_duid_len(uint16_t duid_type, size_t duid_len, bool strict);
335f80a6
YW
58int dhcp_identifier_set_duid_llt(struct duid *duid, usec_t t, const uint8_t *addr, size_t addr_len, uint16_t arp_type, size_t *len);
59int dhcp_identifier_set_duid_ll(struct duid *duid, const uint8_t *addr, size_t addr_len, uint16_t arp_type, size_t *len);
cfb5b380 60int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len);
27eba50e 61int dhcp_identifier_set_duid_uuid(struct duid *duid, size_t *len);
6d13616b 62int dhcp_identifier_set_iaid(int ifindex, const uint8_t *mac, size_t mac_len, bool legacy_unstable_byteorder, void *_id);