chiark / gitweb /
b2d3180091921450ae48ee655a82d124fb7c30ff
[elogind.git] / src / libsystemd-network / lldp-port.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 <net/ethernet.h>
26
27 #include "sd-event.h"
28 #include "sd-lldp.h"
29
30 #include "util.h"
31
32 typedef struct lldp_port lldp_port;
33
34 struct lldp_port {
35         LLDPPortStatus status;
36
37         int ifindex;
38         char *ifname;
39
40         struct ether_addr mac;
41
42         int rawfd;
43
44         sd_event *event;
45         sd_event_source *lldp_port_rx;
46
47         int event_priority;
48
49         void *userdata;
50 };
51
52 int lldp_port_new(int ifindex,
53                   const char *ifname,
54                   const struct ether_addr *addr,
55                   void *userdata,
56                   lldp_port **ret);
57 void lldp_port_free(lldp_port *p);
58
59 DEFINE_TRIVIAL_CLEANUP_FUNC(lldp_port*, lldp_port_free);
60 #define _cleanup_lldp_port_free_ _cleanup_(lldp_port_freep)
61
62 int lldp_port_start(lldp_port *p);
63 int lldp_port_stop(lldp_port *p);