lldp-internal.h revision 07630cea1f3a845c09309f197ac7c4f11edd3b62
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync/***
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync This file is part of systemd.
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync
772269936494ffaddd0750ba9e28e805ba81398cvboxsync Copyright (C) 2014 Tom Gundersen
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync Copyright (C) 2014 Susant Sahani
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync systemd is free software; you can redistribute it and/or modify it
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync under the terms of the GNU Lesser General Public License as published by
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync the Free Software Foundation; either version 2.1 of the License, or
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync (at your option) any later version.
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync systemd is distributed in the hope that it will be useful, but
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync WITHOUT ANY WARRANTY; without even the implied warranty of
0b87790df72dd730ef361a1ce1a8d40ed4d15e10vboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync Lesser General Public License for more details.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync You should have received a copy of the GNU Lesser General Public License
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync along with systemd; If not, see <http://www.gnu.org/licenses/>.
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync***/
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync#pragma once
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync#include "sd-event.h"
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync#include "list.h"
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync#include "lldp-tlv.h"
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync#include "log.h"
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync#include "prioq.h"
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsynctypedef struct lldp_neighbour_port lldp_neighbour_port;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsynctypedef struct lldp_chassis lldp_chassis;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsynctypedef struct lldp_chassis_id lldp_chassis_id;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsynctypedef struct lldp_agent_statistics lldp_agent_statistics;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncstruct lldp_neighbour_port {
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync uint8_t type;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync uint8_t *data;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync uint16_t length;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync usec_t until;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync unsigned prioq_idx;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync lldp_chassis *c;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync tlv_packet *packet;
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync LIST_FIELDS(lldp_neighbour_port, port);
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync};
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncint lldp_neighbour_port_new(lldp_chassis *c, tlv_packet *tlv, lldp_neighbour_port **ret);
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncvoid lldp_neighbour_port_free(lldp_neighbour_port *p);
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncvoid lldp_neighbour_port_remove_and_free(lldp_neighbour_port *p);
52831df2c11f241bf670f904d23a4fbb3ef5e5bbvboxsync
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsyncDEFINE_TRIVIAL_CLEANUP_FUNC(lldp_neighbour_port *, lldp_neighbour_port_free);
d1a00c93378091ef28db9d959b2d692cc8143a07vboxsync#define _cleanup_lldp_neighbour_port_free_ _cleanup_(lldp_neighbour_port_freep)
772269936494ffaddd0750ba9e28e805ba81398cvboxsync
struct lldp_chassis_id {
uint8_t type;
uint16_t length;
uint8_t *data;
};
struct lldp_chassis {
unsigned n_ref;
lldp_chassis_id chassis_id;
Prioq *by_expiry;
Hashmap *neighbour_mib;
LIST_HEAD(lldp_neighbour_port, ports);
};
int lldp_chassis_new(tlv_packet *tlv,
Prioq *by_expiry,
Hashmap *neighbour_mib,
lldp_chassis **ret);
void lldp_chassis_free(lldp_chassis *c);
DEFINE_TRIVIAL_CLEANUP_FUNC(lldp_chassis *, lldp_chassis_free);
#define _cleanup_lldp_chassis_free_ _cleanup_(lldp_chassis_freep)
int lldp_mib_update_objects(lldp_chassis *c, tlv_packet *tlv);
int lldp_mib_add_objects(Prioq *by_expiry, Hashmap *neighbour_mib, tlv_packet *tlv);
int lldp_mib_remove_objects(lldp_chassis *c, tlv_packet *tlv);
int lldp_handle_packet(tlv_packet *m, uint16_t length);
int lldp_receive_packet(sd_event_source *s, int fd, uint32_t revents, void *userdata);
#define log_lldp(fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "LLDP: " fmt, ##__VA_ARGS__)