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