]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/libsystemd-network/lldp-port.h
sd-lldp: drop keeping of statistics
[thirdparty/systemd.git] / src / libsystemd-network / lldp-port.h
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
23 #include <net/ethernet.h>
24
25 #include "sd-event.h"
26 #include "sd-lldp.h"
27
28 #include "util.h"
29
30 typedef struct lldp_port lldp_port;
31
32 typedef enum LLDPPortStatus {
33 LLDP_PORT_STATUS_NONE,
34 LLDP_PORT_STATUS_ENABLED,
35 LLDP_PORT_STATUS_DISABLED,
36 _LLDP_PORT_STATUS_MAX,
37 _LLDP_PORT_STATUS_INVALID = -1,
38 } LLDPPortStatus;
39
40 struct lldp_port {
41 LLDPPortStatus status;
42
43 int ifindex;
44 char *ifname;
45
46 struct ether_addr mac;
47
48 int rawfd;
49
50 sd_event *event;
51 sd_event_source *lldp_port_rx;
52
53 int event_priority;
54
55 void *userdata;
56 };
57
58 int lldp_port_new(int ifindex,
59 const char *ifname,
60 const struct ether_addr *addr,
61 void *userdata,
62 lldp_port **ret);
63 void lldp_port_free(lldp_port *p);
64
65 DEFINE_TRIVIAL_CLEANUP_FUNC(lldp_port*, lldp_port_free);
66 #define _cleanup_lldp_port_free_ _cleanup_(lldp_port_freep)
67
68 int lldp_port_start(lldp_port *p);
69 int lldp_port_stop(lldp_port *p);