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