[systemd-commits] Makefile.am src/libsystemd-network src/systemd

Tom Gundersen tomegun at kemper.freedesktop.org
Fri Dec 19 13:46:04 PST 2014


 Makefile.am                            |    1 
 src/libsystemd-network/lldp-internal.h |    2 +
 src/libsystemd-network/lldp-network.c  |    1 
 src/libsystemd-network/lldp-port.c     |    2 -
 src/libsystemd-network/lldp-port.h     |    4 +-
 src/libsystemd-network/lldp-util.h     |   26 ++++++++++++++
 src/libsystemd-network/sd-lldp.c       |    7 ++-
 src/libsystemd-network/sd-lldp.h       |   60 ---------------------------------
 src/systemd/sd-lldp.h                  |   53 +++++++++++++++++++++++++++++
 9 files changed, 91 insertions(+), 65 deletions(-)

New commits:
commit 7a6f1457462840ed52f2a332e2bd56ca210cff2d
Author: Tom Gundersen <teg at jklm.no>
Date:   Fri Dec 19 22:42:03 2014 +0100

    sd-lldp: minor header cleanup
    
     * (potentially) public headers must reside in src/systemd/ (not in
       src/libsystemd*)
     * some private (not prefixed with sd_) functions moved from sd-lldp.h to
       lldp-internal.h
     * introduce lldp-util.h for the cleanup macro, as these should not be public
     * rename the cleanup macro, we always name them _cleanup_foo_, never
       _cleanup_sd_foo_
     * mark some function arguments as 'const'

diff --git a/Makefile.am b/Makefile.am
index 9edc235..86bcfdf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3089,6 +3089,7 @@ libsystemd_network_la_SOURCES = \
 	src/libsystemd-network/lldp-port.c \
 	src/libsystemd-network/lldp-internal.h \
 	src/libsystemd-network/lldp-internal.c \
+	src/libsystemd-network/lldp-util.h \
 	src/libsystemd-network/sd-lldp.h \
 	src/libsystemd-network/sd-lldp.c
 
diff --git a/src/libsystemd-network/lldp-internal.h b/src/libsystemd-network/lldp-internal.h
index 028a35f..c7235c1 100644
--- a/src/libsystemd-network/lldp-internal.h
+++ b/src/libsystemd-network/lldp-internal.h
@@ -31,6 +31,7 @@
 typedef struct lldp_neighbour_port lldp_neighbour_port;
 typedef struct lldp_chassis lldp_chassis;
 typedef struct lldp_chassis_id lldp_chassis_id;
+typedef struct lldp_agent_statitics lldp_agent_statitics;
 
 struct lldp_neighbour_port {
         uint8_t type;
@@ -94,4 +95,5 @@ int lldp_read_system_description(tlv_packet *tlv, uint16_t *length, char **data)
 int lldp_read_system_capability(tlv_packet *tlv, uint16_t *data);
 int lldp_read_port_description(tlv_packet *tlv, uint16_t *length, char **data);
 
+int lldp_handle_packet(tlv_packet *m, uint16_t length);
 #define log_lldp(fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "LLDP: " fmt, ##__VA_ARGS__)
diff --git a/src/libsystemd-network/lldp-network.c b/src/libsystemd-network/lldp-network.c
index cfab911..a2bc7d5 100644
--- a/src/libsystemd-network/lldp-network.c
+++ b/src/libsystemd-network/lldp-network.c
@@ -26,6 +26,7 @@
 #include "socket-util.h"
 #include "lldp-tlv.h"
 #include "lldp-network.h"
+#include "lldp-internal.h"
 #include "sd-lldp.h"
 
 int lldp_network_bind_raw_socket(int ifindex) {
diff --git a/src/libsystemd-network/lldp-port.c b/src/libsystemd-network/lldp-port.c
index 12b72ee..aa6a3b9 100644
--- a/src/libsystemd-network/lldp-port.c
+++ b/src/libsystemd-network/lldp-port.c
@@ -83,7 +83,7 @@ void lldp_port_free(lldp_port *p) {
 }
 
 int lldp_port_new(int ifindex,
-                  char *ifname,
+                  const char *ifname,
                   const struct ether_addr *addr,
                   void *userdata,
                   lldp_port **ret) {
diff --git a/src/libsystemd-network/lldp-port.h b/src/libsystemd-network/lldp-port.h
index 1b1ae04..b2d3180 100644
--- a/src/libsystemd-network/lldp-port.h
+++ b/src/libsystemd-network/lldp-port.h
@@ -27,6 +27,8 @@
 #include "sd-event.h"
 #include "sd-lldp.h"
 
+#include "util.h"
+
 typedef struct lldp_port lldp_port;
 
 struct lldp_port {
@@ -48,7 +50,7 @@ struct lldp_port {
 };
 
 int lldp_port_new(int ifindex,
-                  char *ifname,
+                  const char *ifname,
                   const struct ether_addr *addr,
                   void *userdata,
                   lldp_port **ret);
diff --git a/src/libsystemd-network/lldp-util.h b/src/libsystemd-network/lldp-util.h
new file mode 100644
index 0000000..112001e
--- /dev/null
+++ b/src/libsystemd-network/lldp-util.h
@@ -0,0 +1,26 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright (C) 2014 Tom Gundersen
+  Copyright (C) 2014 Susant Sahani
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#pragma once
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_lldp *, sd_lldp_free);
+#define _cleanup_lldp_free_ _cleanup_(sd_lldp_freep)
diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c
index 45881e5..08cd092 100644
--- a/src/libsystemd-network/sd-lldp.c
+++ b/src/libsystemd-network/sd-lldp.c
@@ -32,6 +32,7 @@
 #include "prioq.h"
 #include "strv.h"
 #include "lldp-internal.h"
+#include "lldp-util.h"
 #include "ether-addr-util.h"
 
 typedef enum LLDPAgentRXState {
@@ -668,10 +669,10 @@ void sd_lldp_free(sd_lldp *lldp) {
 }
 
 int sd_lldp_new(int ifindex,
-                char *ifname,
-                struct ether_addr *mac,
+                const char *ifname,
+                const struct ether_addr *mac,
                 sd_lldp **ret) {
-        _cleanup_sd_lldp_free_ sd_lldp *lldp = NULL;
+        _cleanup_lldp_free_ sd_lldp *lldp = NULL;
         int r;
 
         assert_return(ret, -EINVAL);
diff --git a/src/libsystemd-network/sd-lldp.h b/src/libsystemd-network/sd-lldp.h
deleted file mode 100644
index ee064c6..0000000
--- a/src/libsystemd-network/sd-lldp.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright (C) 2014 Tom Gundersen
-  Copyright (C) 2014 Susant Sahani
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#pragma once
-
-#include "lldp-tlv.h"
-#include "sd-event.h"
-
-typedef struct sd_lldp sd_lldp;
-typedef struct lldp_agent_statitics lldp_agent_statitics;
-
-typedef void (*sd_lldp_cb_t)(sd_lldp *lldp, int event, void *userdata);
-
-enum {
-        UPDATE_INFO = 10,
-};
-
-typedef enum LLDPPortStatus {
-        LLDP_PORT_STATUS_NONE,
-        LLDP_PORT_STATUS_ENABLED,
-        LLDP_PORT_STATUS_DISABLED,
-        _LLDP_PORT_STATUS_MAX,
-        _LLDP_PORT_STATUS_INVALID = -1,
-} LLDPPortStatus;
-
-int sd_lldp_new(int ifindex, char *ifname, struct ether_addr *mac, sd_lldp **ret);
-void sd_lldp_free(sd_lldp *lldp);
-
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_lldp *, sd_lldp_free);
-#define _cleanup_sd_lldp_free_ _cleanup_(sd_lldp_freep)
-
-int sd_lldp_start(sd_lldp *lldp);
-int sd_lldp_stop(sd_lldp *lldp);
-
-int sd_lldp_attach_event(sd_lldp *lldp, sd_event *event, int priority);
-int sd_lldp_detach_event(sd_lldp *lldp);
-
-int sd_lldp_set_callback(sd_lldp *lldp, sd_lldp_cb_t cb, void *userdata);
-int sd_lldp_save(sd_lldp *lldp, const char *file);
-
-int lldp_handle_packet(tlv_packet *m, uint16_t length);
diff --git a/src/systemd/sd-lldp.h b/src/systemd/sd-lldp.h
new file mode 100644
index 0000000..700146a
--- /dev/null
+++ b/src/systemd/sd-lldp.h
@@ -0,0 +1,53 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright (C) 2014 Tom Gundersen
+  Copyright (C) 2014 Susant Sahani
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#pragma once
+
+#include "sd-event.h"
+
+typedef struct sd_lldp sd_lldp;
+
+typedef void (*sd_lldp_cb_t)(sd_lldp *lldp, int event, void *userdata);
+
+enum {
+        UPDATE_INFO = 10,
+};
+
+typedef enum LLDPPortStatus {
+        LLDP_PORT_STATUS_NONE,
+        LLDP_PORT_STATUS_ENABLED,
+        LLDP_PORT_STATUS_DISABLED,
+        _LLDP_PORT_STATUS_MAX,
+        _LLDP_PORT_STATUS_INVALID = -1,
+} LLDPPortStatus;
+
+int sd_lldp_new(int ifindex, const char *ifname, const struct ether_addr *mac, sd_lldp **ret);
+void sd_lldp_free(sd_lldp *lldp);
+
+int sd_lldp_start(sd_lldp *lldp);
+int sd_lldp_stop(sd_lldp *lldp);
+
+int sd_lldp_attach_event(sd_lldp *lldp, sd_event *event, int priority);
+int sd_lldp_detach_event(sd_lldp *lldp);
+
+int sd_lldp_set_callback(sd_lldp *lldp, sd_lldp_cb_t cb, void *userdata);
+int sd_lldp_save(sd_lldp *lldp, const char *file);



More information about the systemd-commits mailing list