]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd-network/lldp-internal.h
Merge pull request #2495 from heftig/master
[thirdparty/systemd.git] / src / libsystemd-network / lldp-internal.h
CommitLineData
ad1ad5c8
SS
1/***
2 This file is part of systemd.
3
4 Copyright (C) 2014 Tom Gundersen
5 Copyright (C) 2014 Susant Sahani
6
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
11
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
19***/
20
21#pragma once
22
07630cea
LP
23#include "sd-event.h"
24
ad1ad5c8 25#include "list.h"
ad1ad5c8 26#include "lldp-tlv.h"
07630cea 27#include "log.h"
ad1ad5c8
SS
28#include "prioq.h"
29
30typedef struct lldp_neighbour_port lldp_neighbour_port;
31typedef struct lldp_chassis lldp_chassis;
32typedef struct lldp_chassis_id lldp_chassis_id;
6b3fd9a1 33typedef struct lldp_agent_statistics lldp_agent_statistics;
ad1ad5c8
SS
34
35struct lldp_neighbour_port {
36 uint8_t type;
37 uint8_t *data;
38
39 uint16_t length;
40 usec_t until;
41
42 unsigned prioq_idx;
43
44 lldp_chassis *c;
45 tlv_packet *packet;
46
47 LIST_FIELDS(lldp_neighbour_port, port);
48};
49
50int lldp_neighbour_port_new(lldp_chassis *c, tlv_packet *tlv, lldp_neighbour_port **ret);
51void lldp_neighbour_port_free(lldp_neighbour_port *p);
52void lldp_neighbour_port_remove_and_free(lldp_neighbour_port *p);
53
54DEFINE_TRIVIAL_CLEANUP_FUNC(lldp_neighbour_port *, lldp_neighbour_port_free);
55#define _cleanup_lldp_neighbour_port_free_ _cleanup_(lldp_neighbour_port_freep)
56
57struct lldp_chassis_id {
58 uint8_t type;
59 uint16_t length;
60
61 uint8_t *data;
62};
63
64struct lldp_chassis {
9c8e3101 65 unsigned n_ref;
ad1ad5c8
SS
66
67 lldp_chassis_id chassis_id;
68
69 Prioq *by_expiry;
70 Hashmap *neighbour_mib;
71
72 LIST_HEAD(lldp_neighbour_port, ports);
73};
74
75int lldp_chassis_new(tlv_packet *tlv,
76 Prioq *by_expiry,
77 Hashmap *neighbour_mib,
78 lldp_chassis **ret);
79
80void lldp_chassis_free(lldp_chassis *c);
81
82DEFINE_TRIVIAL_CLEANUP_FUNC(lldp_chassis *, lldp_chassis_free);
83#define _cleanup_lldp_chassis_free_ _cleanup_(lldp_chassis_freep)
84
85int lldp_mib_update_objects(lldp_chassis *c, tlv_packet *tlv);
86int lldp_mib_add_objects(Prioq *by_expiry, Hashmap *neighbour_mib, tlv_packet *tlv);
87int lldp_mib_remove_objects(lldp_chassis *c, tlv_packet *tlv);
88
7a6f1457 89int lldp_handle_packet(tlv_packet *m, uint16_t length);
0037c2dc 90int lldp_receive_packet(sd_event_source *s, int fd, uint32_t revents, void *userdata);
ad1ad5c8 91#define log_lldp(fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "LLDP: " fmt, ##__VA_ARGS__)