]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
764aad62 TG |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright (C) 2015 Tom Gundersen <teg@jklmen> | |
764aad62 TG |
8 | ***/ |
9 | ||
07630cea | 10 | #include "sd-id128.h" |
764aad62 | 11 | |
c1ff5570 | 12 | #include "macro.h" |
764aad62 | 13 | #include "sparse-endian.h" |
9ee18af3 | 14 | #include "unaligned.h" |
764aad62 | 15 | |
413708d1 | 16 | typedef enum DUIDType { |
413708d1 VK |
17 | DUID_TYPE_LLT = 1, |
18 | DUID_TYPE_EN = 2, | |
19 | DUID_TYPE_LL = 3, | |
20 | DUID_TYPE_UUID = 4, | |
21 | _DUID_TYPE_MAX, | |
22 | _DUID_TYPE_INVALID = -1, | |
23 | } DUIDType; | |
24 | ||
764aad62 TG |
25 | /* RFC 3315 section 9.1: |
26 | * A DUID can be no more than 128 octets long (not including the type code). | |
27 | */ | |
28 | #define MAX_DUID_LEN 128 | |
29 | ||
3b6a4e97 | 30 | /* https://tools.ietf.org/html/rfc3315#section-9.1 */ |
764aad62 | 31 | struct duid { |
413708d1 | 32 | be16_t type; |
764aad62 TG |
33 | union { |
34 | struct { | |
3b6a4e97 | 35 | /* DUID_TYPE_LLT */ |
764aad62 TG |
36 | uint16_t htype; |
37 | uint32_t time; | |
38 | uint8_t haddr[0]; | |
39 | } _packed_ llt; | |
40 | struct { | |
3b6a4e97 | 41 | /* DUID_TYPE_EN */ |
764aad62 TG |
42 | uint32_t pen; |
43 | uint8_t id[8]; | |
44 | } _packed_ en; | |
45 | struct { | |
3b6a4e97 | 46 | /* DUID_TYPE_LL */ |
764aad62 TG |
47 | int16_t htype; |
48 | uint8_t haddr[0]; | |
49 | } _packed_ ll; | |
50 | struct { | |
3b6a4e97 | 51 | /* DUID_TYPE_UUID */ |
764aad62 TG |
52 | sd_id128_t uuid; |
53 | } _packed_ uuid; | |
54 | struct { | |
55 | uint8_t data[MAX_DUID_LEN]; | |
56 | } _packed_ raw; | |
57 | }; | |
58 | } _packed_; | |
cfb5b380 | 59 | |
3b6a4e97 | 60 | int dhcp_validate_duid_len(uint16_t duid_type, size_t duid_len); |
cfb5b380 | 61 | int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len); |
9ee18af3 | 62 | int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id); |