]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
e735f4d4 MP |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright (C) 2015 Tom Gundersen <teg@jklmen> | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
db2df898 | 23 | #include "sd-id128.h" |
e735f4d4 MP |
24 | |
25 | #include "macro.h" | |
26 | #include "sparse-endian.h" | |
e3bff60a | 27 | #include "unaligned.h" |
e735f4d4 | 28 | |
aa27b158 MP |
29 | typedef enum DUIDType { |
30 | DUID_TYPE_LLT = 1, | |
31 | DUID_TYPE_EN = 2, | |
32 | DUID_TYPE_LL = 3, | |
33 | DUID_TYPE_UUID = 4, | |
34 | _DUID_TYPE_MAX, | |
35 | _DUID_TYPE_INVALID = -1, | |
36 | } DUIDType; | |
37 | ||
e735f4d4 MP |
38 | /* RFC 3315 section 9.1: |
39 | * A DUID can be no more than 128 octets long (not including the type code). | |
40 | */ | |
41 | #define MAX_DUID_LEN 128 | |
42 | ||
aa27b158 | 43 | /* https://tools.ietf.org/html/rfc3315#section-9.1 */ |
e735f4d4 | 44 | struct duid { |
aa27b158 | 45 | be16_t type; |
e735f4d4 MP |
46 | union { |
47 | struct { | |
aa27b158 | 48 | /* DUID_TYPE_LLT */ |
e735f4d4 MP |
49 | uint16_t htype; |
50 | uint32_t time; | |
51 | uint8_t haddr[0]; | |
52 | } _packed_ llt; | |
53 | struct { | |
aa27b158 | 54 | /* DUID_TYPE_EN */ |
e735f4d4 MP |
55 | uint32_t pen; |
56 | uint8_t id[8]; | |
57 | } _packed_ en; | |
58 | struct { | |
aa27b158 | 59 | /* DUID_TYPE_LL */ |
e735f4d4 MP |
60 | int16_t htype; |
61 | uint8_t haddr[0]; | |
62 | } _packed_ ll; | |
63 | struct { | |
aa27b158 | 64 | /* DUID_TYPE_UUID */ |
e735f4d4 MP |
65 | sd_id128_t uuid; |
66 | } _packed_ uuid; | |
67 | struct { | |
68 | uint8_t data[MAX_DUID_LEN]; | |
69 | } _packed_ raw; | |
70 | }; | |
71 | } _packed_; | |
72 | ||
aa27b158 | 73 | int dhcp_validate_duid_len(uint16_t duid_type, size_t duid_len); |
e735f4d4 | 74 | int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len); |
e3bff60a | 75 | int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id); |