summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/lldp-internal.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-07-10 18:43:12 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-10-02 17:39:12 +0200
commit176c355b43e616b61552566303ad59d5fd910333 (patch)
tree9198ba7be4f24b643ef9c24b8e1d01b421fb4b3b /src/libsystemd-network/lldp-internal.c
parent97030a86f0137bca52c3cf9b30e5ed3bdf69b2f2 (diff)
lldp: export opaque TLV type and accessor functions
Export struct tlv_packet as a public opaque sd_lldp_packet type and make its accessor functions public.
Diffstat (limited to 'src/libsystemd-network/lldp-internal.c')
-rw-r--r--src/libsystemd-network/lldp-internal.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/libsystemd-network/lldp-internal.c b/src/libsystemd-network/lldp-internal.c
index 7695805946..762a1d2895 100644
--- a/src/libsystemd-network/lldp-internal.c
+++ b/src/libsystemd-network/lldp-internal.c
@@ -21,6 +21,7 @@
***/
#include "lldp-internal.h"
+#include "sd-lldp.h"
/* We store maximum 1K chassis entries */
#define LLDP_MIB_MAX_CHASSIS 1024
@@ -28,10 +29,10 @@
/* Maximum Ports can be attached to any chassis */
#define LLDP_MIB_MAX_PORT_PER_CHASSIS 32
-int lldp_read_chassis_id(tlv_packet *tlv,
- uint8_t *type,
- uint8_t **data,
- uint16_t *length) {
+int sd_lldp_packet_read_chassis_id(tlv_packet *tlv,
+ uint8_t *type,
+ uint8_t **data,
+ uint16_t *length) {
uint8_t subtype;
int r;
@@ -67,10 +68,10 @@ int lldp_read_chassis_id(tlv_packet *tlv,
return r;
}
-int lldp_read_port_id(tlv_packet *tlv,
- uint8_t *type,
- uint8_t **data,
- uint16_t *length) {
+int sd_lldp_packet_read_port_id(tlv_packet *tlv,
+ uint8_t *type,
+ uint8_t **data,
+ uint16_t *length) {
uint8_t subtype;
char *s;
int r;
@@ -119,7 +120,7 @@ int lldp_read_port_id(tlv_packet *tlv,
return r;
}
-int lldp_read_ttl(tlv_packet *tlv, uint16_t *ttl) {
+int sd_lldp_packet_read_ttl(tlv_packet *tlv, uint16_t *ttl) {
int r;
assert_return(tlv, -EINVAL);
@@ -136,9 +137,9 @@ int lldp_read_ttl(tlv_packet *tlv, uint16_t *ttl) {
return r;
}
-int lldp_read_system_name(tlv_packet *tlv,
- char **data,
- uint16_t *length) {
+int sd_lldp_packet_read_system_name(tlv_packet *tlv,
+ char **data,
+ uint16_t *length) {
char *s;
int r;
@@ -160,9 +161,9 @@ int lldp_read_system_name(tlv_packet *tlv,
return r;
}
-int lldp_read_system_description(tlv_packet *tlv,
- char **data,
- uint16_t *length) {
+int sd_lldp_packet_read_system_description(tlv_packet *tlv,
+ char **data,
+ uint16_t *length) {
char *s;
int r;
@@ -184,9 +185,9 @@ int lldp_read_system_description(tlv_packet *tlv,
return r;
}
-int lldp_read_port_description(tlv_packet *tlv,
- char **data,
- uint16_t *length) {
+int sd_lldp_packet_read_port_description(tlv_packet *tlv,
+ char **data,
+ uint16_t *length) {
char *s;
int r;
@@ -208,7 +209,7 @@ int lldp_read_port_description(tlv_packet *tlv,
return r;
}
-int lldp_read_system_capability(tlv_packet *tlv, uint16_t *data) {
+int sd_lldp_packet_read_system_capability(tlv_packet *tlv, uint16_t *data) {
int r;
assert_return(tlv, -EINVAL);
@@ -244,7 +245,7 @@ int lldp_mib_update_objects(lldp_chassis *c, tlv_packet *tlv) {
assert_return(c, -EINVAL);
assert_return(tlv, -EINVAL);
- r = lldp_read_port_id(tlv, &type, &data, &length);
+ r = sd_lldp_packet_read_port_id(tlv, &type, &data, &length);
if (r < 0)
return r;
@@ -253,13 +254,13 @@ int lldp_mib_update_objects(lldp_chassis *c, tlv_packet *tlv) {
if ((p->type == type && p->length == length && !memcmp(p->data, data, p->length))) {
- r = lldp_read_ttl(tlv, &ttl);
+ r = sd_lldp_packet_read_ttl(tlv, &ttl);
if (r < 0)
return r;
p->until = ttl * USEC_PER_SEC + now(clock_boottime_or_monotonic());
- tlv_packet_unref(p->packet);
+ sd_lldp_packet_unref(p->packet);
p->packet = tlv;
prioq_reshuffle(p->c->by_expiry, p, &p->prioq_idx);
@@ -281,7 +282,7 @@ int lldp_mib_remove_objects(lldp_chassis *c, tlv_packet *tlv) {
assert_return(c, -EINVAL);
assert_return(tlv, -EINVAL);
- r = lldp_read_port_id(tlv, &type, &data, &length);
+ r = sd_lldp_packet_read_port_id(tlv, &type, &data, &length);
if (r < 0)
return r;
@@ -312,11 +313,11 @@ int lldp_mib_add_objects(Prioq *by_expiry,
assert_return(neighbour_mib, -EINVAL);
assert_return(tlv, -EINVAL);
- r = lldp_read_chassis_id(tlv, &subtype, &data, &length);
+ r = sd_lldp_packet_read_chassis_id(tlv, &subtype, &data, &length);
if (r < 0)
goto drop;
- r = lldp_read_ttl(tlv, &ttl);
+ r = sd_lldp_packet_read_ttl(tlv, &ttl);
if (r < 0)
goto drop;
@@ -401,7 +402,7 @@ int lldp_mib_add_objects(Prioq *by_expiry,
return 0;
drop:
- tlv_packet_unref(tlv);
+ sd_lldp_packet_unref(tlv);
if (new_chassis)
hashmap_remove(neighbour_mib, &c->chassis_id);
@@ -435,7 +436,7 @@ void lldp_neighbour_port_free(lldp_neighbour_port *p) {
if(!p)
return;
- tlv_packet_unref(p->packet);
+ sd_lldp_packet_unref(p->packet);
free(p->data);
free(p);
@@ -452,11 +453,11 @@ int lldp_neighbour_port_new(lldp_chassis *c,
assert(tlv);
- r = lldp_read_port_id(tlv, &type, &data, &length);
+ r = sd_lldp_packet_read_port_id(tlv, &type, &data, &length);
if (r < 0)
return r;
- r = lldp_read_ttl(tlv, &ttl);
+ r = sd_lldp_packet_read_ttl(tlv, &ttl);
if (r < 0)
return r;
@@ -505,7 +506,7 @@ int lldp_chassis_new(tlv_packet *tlv,
assert(tlv);
- r = lldp_read_chassis_id(tlv, &type, &data, &length);
+ r = sd_lldp_packet_read_chassis_id(tlv, &type, &data, &length);
if (r < 0)
return r;