]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
764aad62 TG |
2 | #pragma once |
3 | ||
07630cea | 4 | #include "sd-id128.h" |
764aad62 | 5 | |
3b75435d | 6 | #include "ether-addr-util.h" |
c1ff5570 | 7 | #include "macro.h" |
764aad62 | 8 | #include "sparse-endian.h" |
335f80a6 | 9 | #include "time-util.h" |
9ee18af3 | 10 | #include "unaligned.h" |
764aad62 | 11 | |
73c8ced7 SS |
12 | #define SYSTEMD_PEN 43793 |
13 | ||
413708d1 | 14 | typedef enum DUIDType { |
413708d1 VK |
15 | DUID_TYPE_LLT = 1, |
16 | DUID_TYPE_EN = 2, | |
17 | DUID_TYPE_LL = 3, | |
18 | DUID_TYPE_UUID = 4, | |
19 | _DUID_TYPE_MAX, | |
0979e4ad | 20 | _DUID_TYPE_INVALID = -EINVAL, |
413708d1 VK |
21 | } DUIDType; |
22 | ||
764aad62 TG |
23 | /* RFC 3315 section 9.1: |
24 | * A DUID can be no more than 128 octets long (not including the type code). | |
25 | */ | |
26 | #define MAX_DUID_LEN 128 | |
27 | ||
3b6a4e97 | 28 | /* https://tools.ietf.org/html/rfc3315#section-9.1 */ |
764aad62 | 29 | struct duid { |
413708d1 | 30 | be16_t type; |
764aad62 TG |
31 | union { |
32 | struct { | |
3b6a4e97 | 33 | /* DUID_TYPE_LLT */ |
9d7b8c66 YW |
34 | be16_t htype; |
35 | be32_t time; | |
764aad62 TG |
36 | uint8_t haddr[0]; |
37 | } _packed_ llt; | |
38 | struct { | |
3b6a4e97 | 39 | /* DUID_TYPE_EN */ |
9d7b8c66 | 40 | be32_t pen; |
764aad62 TG |
41 | uint8_t id[8]; |
42 | } _packed_ en; | |
43 | struct { | |
3b6a4e97 | 44 | /* DUID_TYPE_LL */ |
9d7b8c66 | 45 | be16_t htype; |
764aad62 TG |
46 | uint8_t haddr[0]; |
47 | } _packed_ ll; | |
48 | struct { | |
3b6a4e97 | 49 | /* DUID_TYPE_UUID */ |
764aad62 TG |
50 | sd_id128_t uuid; |
51 | } _packed_ uuid; | |
52 | struct { | |
53 | uint8_t data[MAX_DUID_LEN]; | |
54 | } _packed_ raw; | |
55 | }; | |
56 | } _packed_; | |
cfb5b380 | 57 | |
5e1618fa | 58 | int dhcp_validate_duid_len(DUIDType duid_type, size_t duid_len, bool strict); |
ac680f76 | 59 | int dhcp_identifier_set_duid_en(bool test_mode, struct duid *ret_duid, size_t *ret_len); |
5e1618fa YW |
60 | int dhcp_identifier_set_duid( |
61 | DUIDType duid_type, | |
8cad358e | 62 | const struct hw_addr_data *hw_addr, |
5e1618fa YW |
63 | uint16_t arp_type, |
64 | usec_t llt_time, | |
ac680f76 | 65 | bool test_mode, |
5e1618fa YW |
66 | struct duid *ret_duid, |
67 | size_t *ret_len); | |
68 | int dhcp_identifier_set_iaid( | |
69 | int ifindex, | |
3b75435d | 70 | const struct hw_addr_data *hw_addr, |
5e1618fa YW |
71 | bool legacy_unstable_byteorder, |
72 | bool use_mac, | |
73 | void *ret); | |
f9971018 YW |
74 | |
75 | const char *duid_type_to_string(DUIDType t) _const_; |