]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemd/sd-lldp.h
Merge pull request #1465 from teg/siphash24
[thirdparty/systemd.git] / src / systemd / sd-lldp.h
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
25 #include "sd-event.h"
26
27 enum {
28 SD_LLDP_EVENT_UPDATE_INFO = 0,
29 };
30
31 enum {
32 SD_LLDP_DESTINATION_TYPE_NEAREST_BRIDGE,
33 SD_LLDP_DESTINATION_TYPE_NEAREST_NON_TPMR_BRIDGE,
34 SD_LLDP_DESTINATION_TYPE_NEAREST_CUSTOMER_BRIDGE,
35 };
36
37 typedef struct sd_lldp sd_lldp;
38 typedef struct tlv_packet sd_lldp_packet;
39
40 typedef void (*sd_lldp_cb_t)(sd_lldp *lldp, int event, void *userdata);
41
42 int sd_lldp_new(int ifindex, const char *ifname, const struct ether_addr *mac, sd_lldp **ret);
43 void sd_lldp_free(sd_lldp *lldp);
44
45 int sd_lldp_start(sd_lldp *lldp);
46 int sd_lldp_stop(sd_lldp *lldp);
47
48 int sd_lldp_attach_event(sd_lldp *lldp, sd_event *event, int priority);
49 int sd_lldp_detach_event(sd_lldp *lldp);
50
51 int sd_lldp_set_callback(sd_lldp *lldp, sd_lldp_cb_t cb, void *userdata);
52 int sd_lldp_save(sd_lldp *lldp, const char *file);
53
54 int sd_lldp_packet_read_chassis_id(sd_lldp_packet *tlv, uint8_t *type, uint8_t **data, uint16_t *length);
55 int sd_lldp_packet_read_port_id(sd_lldp_packet *tlv, uint8_t *type, uint8_t **data, uint16_t *length);
56 int sd_lldp_packet_read_ttl(sd_lldp_packet *tlv, uint16_t *ttl);
57 int sd_lldp_packet_read_system_name(sd_lldp_packet *tlv, char **data, uint16_t *length);
58 int sd_lldp_packet_read_system_description(sd_lldp_packet *tlv, char **data, uint16_t *length);
59 int sd_lldp_packet_read_system_capability(sd_lldp_packet *tlv, uint16_t *data);
60 int sd_lldp_packet_read_port_description(sd_lldp_packet *tlv, char **data, uint16_t *length);
61
62 /* IEEE 802.1 organizationally specific TLVs */
63 int sd_lldp_packet_read_port_vlan_id(sd_lldp_packet *tlv, uint16_t *id);
64 int sd_lldp_packet_read_port_protocol_vlan_id(sd_lldp_packet *tlv, uint8_t *flags, uint16_t *id);
65 int sd_lldp_packet_read_vlan_name(sd_lldp_packet *tlv, uint16_t *vlan_id, char **name, uint16_t *length);
66 int sd_lldp_packet_read_management_vid(sd_lldp_packet *tlv, uint16_t *id);
67 int sd_lldp_packet_read_link_aggregation(sd_lldp_packet *tlv, uint8_t *status, uint32_t *id);
68
69 sd_lldp_packet *sd_lldp_packet_ref(sd_lldp_packet *tlv);
70 sd_lldp_packet *sd_lldp_packet_unref(sd_lldp_packet *tlv);
71
72 int sd_lldp_packet_get_destination_type(sd_lldp_packet *tlv, int *dest);
73
74 int sd_lldp_get_packets(sd_lldp *lldp, sd_lldp_packet ***tlvs);