chiark / gitweb /
network: dhcp - split out dhcp_identifier_set_{iaid,duid_en} from dhcp6-client
[elogind.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 <net/ethernet.h>
25
26 #include "sparse-endian.h"
27 #include "sd-id128.h"
28
29 /* RFC 3315 section 9.1:
30  *      A DUID can be no more than 128 octets long (not including the type code).
31  */
32 #define MAX_DUID_LEN 128
33
34 struct duid {
35         uint16_t type;
36         union {
37                 struct {
38                         /* DHCP6_DUID_LLT */
39                         uint16_t htype;
40                         uint32_t time;
41                         uint8_t haddr[0];
42                 } _packed_ llt;
43                 struct {
44                         /* DHCP6_DUID_EN */
45                         uint32_t pen;
46                         uint8_t id[8];
47                 } _packed_ en;
48                 struct {
49                         /* DHCP6_DUID_LL */
50                         int16_t htype;
51                         uint8_t haddr[0];
52                 } _packed_ ll;
53                 struct {
54                         /* DHCP6_DUID_UUID */
55                         sd_id128_t uuid;
56                 } _packed_ uuid;
57                 struct {
58                         uint8_t data[MAX_DUID_LEN];
59                 } _packed_ raw;
60         };
61 } _packed_;
62
63 int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len);
64 int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, uint32_t *_id);