]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/dhcp-identifier.h
4 This file is part of systemd.
6 Copyright (C) 2015 Tom Gundersen <teg@jklmen>
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
25 #include "sparse-endian.h"
26 #include "unaligned.h"
28 typedef enum DUIDType
{
35 _DUID_TYPE_INVALID
= -1,
38 /* RFC 3315 section 9.1:
39 * A DUID can be no more than 128 octets long (not including the type code).
41 #define MAX_DUID_LEN 128
67 uint8_t data
[MAX_DUID_LEN
];
72 int dhcp_identifier_set_duid_en(struct duid
*duid
, size_t *len
);
73 int dhcp_identifier_set_iaid(int ifindex
, uint8_t *mac
, size_t mac_len
, void *_id
);
75 static inline int dhcp_validate_duid_len(uint16_t duid_type
, size_t duid_len
) {
78 assert_return(duid_len
> 0 && duid_len
<= MAX_DUID_LEN
, -EINVAL
);
82 if (duid_len
<= sizeof(d
.llt
))
86 if (duid_len
!= sizeof(d
.en
))
90 if (duid_len
<= sizeof(d
.ll
))
94 if (duid_len
!= sizeof(d
.uuid
))
98 /* accept unknown type in order to be forward compatible */