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