summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/test-lldp.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-06-02 17:45:08 +0200
committerLennart Poettering <lennart@poettering.net>2016-06-06 19:59:07 +0200
commitfc6a313b5b836a8642a47348272d7883e1b9349d (patch)
tree45de1fba29d09750b420789735adcc8f97b8f188 /src/libsystemd-network/test-lldp.c
parent5f94b4e62e9439b3580653e30082981e33128b8a (diff)
downloadsystemd-fc6a313b5b836a8642a47348272d7883e1b9349d.tar.gz
lldp: add proper ref counting to sd_lldp object and a separate call for setting the ifindex
Let's make sd-lldp a bit more like sd-ndisc ant the other APIs, and add proper ref counting and a separate call for setting the ifindex. This also adds a new lldp_reset() call we can use at various places to close all fds. This is also similar to how sd-ndisc already does it.
Diffstat (limited to 'src/libsystemd-network/test-lldp.c')
-rw-r--r--src/libsystemd-network/test-lldp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsystemd-network/test-lldp.c b/src/libsystemd-network/test-lldp.c
index 1aae2253c0..6bcd65de0a 100644
--- a/src/libsystemd-network/test-lldp.c
+++ b/src/libsystemd-network/test-lldp.c
@@ -54,11 +54,11 @@ static void lldp_handler(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n
static int start_lldp(sd_lldp **lldp, sd_event *e, sd_lldp_callback_t cb, void *cb_data) {
int r;
- r = sd_lldp_new(lldp, 42);
+ r = sd_lldp_new(lldp);
if (r < 0)
return r;
- r = sd_lldp_attach_event(*lldp, e, 0);
+ r = sd_lldp_set_ifindex(*lldp, 42);
if (r < 0)
return r;
@@ -66,6 +66,10 @@ static int start_lldp(sd_lldp **lldp, sd_event *e, sd_lldp_callback_t cb, void *
if (r < 0)
return r;
+ r = sd_lldp_attach_event(*lldp, e, 0);
+ if (r < 0)
+ return r;
+
r = sd_lldp_start(*lldp);
if (r < 0)
return r;