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