]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-identifier.h
util-lib: split our string related calls from util.[ch] into its own file string...
[thirdparty/systemd.git] / src / libsystemd-network / dhcp-identifier.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6 This file is part of systemd.
7
8 Copyright (C) 2015 Tom Gundersen <teg@jklmen>
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include "sd-id128.h"
25
26 #include "macro.h"
27 #include "sparse-endian.h"
28 #include "unaligned.h"
29
30 /* RFC 3315 section 9.1:
31 * A DUID can be no more than 128 octets long (not including the type code).
32 */
33 #define MAX_DUID_LEN 128
34
35 struct duid {
36 uint16_t type;
37 union {
38 struct {
39 /* DHCP6_DUID_LLT */
40 uint16_t htype;
41 uint32_t time;
42 uint8_t haddr[0];
43 } _packed_ llt;
44 struct {
45 /* DHCP6_DUID_EN */
46 uint32_t pen;
47 uint8_t id[8];
48 } _packed_ en;
49 struct {
50 /* DHCP6_DUID_LL */
51 int16_t htype;
52 uint8_t haddr[0];
53 } _packed_ ll;
54 struct {
55 /* DHCP6_DUID_UUID */
56 sd_id128_t uuid;
57 } _packed_ uuid;
58 struct {
59 uint8_t data[MAX_DUID_LEN];
60 } _packed_ raw;
61 };
62 } _packed_;
63
64 int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len);
65 int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id);