Skip to content

Commit a9090c9

Browse files
finikorgnashif
authored andcommitted
net: lldp: Move optional End TLV to send function
In a case we have optional TLVs we need to send End TLV in the very end. Signed-off-by: Andrei Emeltchenko <[email protected]>
1 parent c2dbbf7 commit a9090c9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

include/net/lldp.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ struct net_lldpdu {
141141
struct net_lldp_chassis_tlv chassis_id; /* Mandatory TLV */
142142
struct net_lldp_port_tlv port_id; /* Mandatory TLV */
143143
struct net_lldp_time_to_live_tlv ttl; /* Mandatory TLV */
144-
145-
#if defined(CONFIG_NET_LLDP_END_LLDPDU_TLV_ENABLED)
146-
/** Optional End of LLDPDU TLV. Must be set to 0x0000 always. */
147-
const uint16_t end_lldpdu_tlv;
148-
#endif /* CONFIG_NET_LLDP_END_LLDPDU_TLV_ENABLED */
149144
} __packed;
150145

151146
/**

subsys/net/l2/ethernet/lldp/lldp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ static int lldp_send(struct ethernet_lldp *lldp)
127127
}
128128
}
129129

130+
if (IS_ENABLED(CONFIG_NET_LLDP_END_LLDPDU_TLV_ENABLED)) {
131+
u16_t tlv_end = htons(NET_LLDP_END_LLDPDU_VALUE);
132+
133+
if (!net_pkt_write_new(pkt, (u8_t *)&tlv_end,
134+
sizeof(tlv_end))) {
135+
net_pkt_unref(pkt);
136+
ret = -ENOMEM;
137+
goto out;
138+
}
139+
}
140+
130141
net_pkt_lladdr_src(pkt)->addr = net_if_get_link_addr(lldp->iface)->addr;
131142
net_pkt_lladdr_src(pkt)->len = sizeof(struct net_eth_addr);
132143
net_pkt_lladdr_dst(pkt)->addr = (u8_t *)lldp_multicast_eth_addr.addr;

0 commit comments

Comments
 (0)