764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen#pragma once
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen/***
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen This file is part of systemd.
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen Copyright (C) 2015 Tom Gundersen <teg@jklmen>
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen systemd is free software; you can redistribute it and/or modify it
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen under the terms of the GNU Lesser General Public License as published by
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen (at your option) any later version.
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen systemd is distributed in the hope that it will be useful, but
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen Lesser General Public License for more details.
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen You should have received a copy of the GNU Lesser General Public License
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen***/
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include "sd-id128.h"
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
c1ff5570f4a04bb9aedea444c12dce81679224ecThomas Hindoe Paaboel Andersen#include "macro.h"
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen#include "sparse-endian.h"
9ee18af3a036074c4021c82ae2e67f5ccaa9ea9dTom Gundersen#include "unaligned.h"
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen/* RFC 3315 section 9.1:
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen * A DUID can be no more than 128 octets long (not including the type code).
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen#define MAX_DUID_LEN 128
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersenstruct duid {
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint16_t type;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen union {
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen struct {
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen /* DHCP6_DUID_LLT */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint16_t htype;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint32_t time;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint8_t haddr[0];
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen } _packed_ llt;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen struct {
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen /* DHCP6_DUID_EN */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint32_t pen;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint8_t id[8];
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen } _packed_ en;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen struct {
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen /* DHCP6_DUID_LL */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen int16_t htype;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint8_t haddr[0];
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen } _packed_ ll;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen struct {
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen /* DHCP6_DUID_UUID */
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen sd_id128_t uuid;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen } _packed_ uuid;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen struct {
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen uint8_t data[MAX_DUID_LEN];
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen } _packed_ raw;
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen };
764aad6258eec3bd4ae62ea341ea507bd69ce628Tom Gundersen} _packed_;
cfb5b3805759e63dc5e0cae6e92e1df885b5c5b6Tom Gundersen
cfb5b3805759e63dc5e0cae6e92e1df885b5c5b6Tom Gundersenint dhcp_identifier_set_duid_en(struct duid *duid, size_t *len);
9ee18af3a036074c4021c82ae2e67f5ccaa9ea9dTom Gundersenint dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id);