]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/dhcp-identifier.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-identifier.h
CommitLineData
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>
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
07630cea 23#include "sd-id128.h"
764aad62 24
c1ff5570 25#include "macro.h"
764aad62 26#include "sparse-endian.h"
9ee18af3 27#include "unaligned.h"
764aad62 28
413708d1 29typedef enum DUIDType {
413708d1
VK
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
764aad62
TG
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
3b6a4e97 43/* https://tools.ietf.org/html/rfc3315#section-9.1 */
764aad62 44struct duid {
413708d1 45 be16_t type;
764aad62
TG
46 union {
47 struct {
3b6a4e97 48 /* DUID_TYPE_LLT */
764aad62
TG
49 uint16_t htype;
50 uint32_t time;
51 uint8_t haddr[0];
52 } _packed_ llt;
53 struct {
3b6a4e97 54 /* DUID_TYPE_EN */
764aad62
TG
55 uint32_t pen;
56 uint8_t id[8];
57 } _packed_ en;
58 struct {
3b6a4e97 59 /* DUID_TYPE_LL */
764aad62
TG
60 int16_t htype;
61 uint8_t haddr[0];
62 } _packed_ ll;
63 struct {
3b6a4e97 64 /* DUID_TYPE_UUID */
764aad62
TG
65 sd_id128_t uuid;
66 } _packed_ uuid;
67 struct {
68 uint8_t data[MAX_DUID_LEN];
69 } _packed_ raw;
70 };
71} _packed_;
cfb5b380 72
3b6a4e97 73int dhcp_validate_duid_len(uint16_t duid_type, size_t duid_len);
cfb5b380 74int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len);
9ee18af3 75int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id);