]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-identifier.h
Merge pull request #9348 from keszybz/copyright-removal
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-identifier.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4
5 #include "sd-id128.h"
6
7 #include "macro.h"
8 #include "sparse-endian.h"
9 #include "unaligned.h"
10
11 typedef enum DUIDType {
12 DUID_TYPE_LLT = 1,
13 DUID_TYPE_EN = 2,
14 DUID_TYPE_LL = 3,
15 DUID_TYPE_UUID = 4,
16 _DUID_TYPE_MAX,
17 _DUID_TYPE_INVALID = -1,
18 } DUIDType;
19
20 /* RFC 3315 section 9.1:
21 * A DUID can be no more than 128 octets long (not including the type code).
22 */
23 #define MAX_DUID_LEN 128
24
25 /* https://tools.ietf.org/html/rfc3315#section-9.1 */
26 struct duid {
27 be16_t type;
28 union {
29 struct {
30 /* DUID_TYPE_LLT */
31 uint16_t htype;
32 uint32_t time;
33 uint8_t haddr[0];
34 } _packed_ llt;
35 struct {
36 /* DUID_TYPE_EN */
37 uint32_t pen;
38 uint8_t id[8];
39 } _packed_ en;
40 struct {
41 /* DUID_TYPE_LL */
42 int16_t htype;
43 uint8_t haddr[0];
44 } _packed_ ll;
45 struct {
46 /* DUID_TYPE_UUID */
47 sd_id128_t uuid;
48 } _packed_ uuid;
49 struct {
50 uint8_t data[MAX_DUID_LEN];
51 } _packed_ raw;
52 };
53 } _packed_;
54
55 int dhcp_validate_duid_len(uint16_t duid_type, size_t duid_len);
56 int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len);
57 int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id);