lldpad/lldpad-0.9.41-lldpad-get-functions-for-Local-and-Remote-MAC-addres.patch
2011-04-21 09:10:21 +02:00

93 lines
2.8 KiB
Diff

From 8b0e918921882fcf56d9b75acd3b39aa4a76169b Mon Sep 17 00:00:00 2001
From: Daruwalla, Sharookh P <sharookh.p.daruwalla@intel.com>
Date: Wed, 6 Apr 2011 08:48:13 -0700
Subject: [PATCH 44/51] lldpad: get() functions for Local and Remote MAC
addresses
Implements logic to extract the remote peer's MAC address from
the rx frame and store it in l2_packet_data's remote_mac_addr
field.
Removes get_san_mac_addr(). Instead uses l2_packet_get_own_src_addr()
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <psabata@redhat.com>
---
lldp/l2_packet.h | 3 +++
lldp/l2_packet_linux.c | 18 +++++++++++++++++-
lldp/rx.c | 2 +-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/lldp/l2_packet.h b/lldp/l2_packet.h
index 0bdacf1..7c88a5c 100644
--- a/lldp/l2_packet.h
+++ b/lldp/l2_packet.h
@@ -130,6 +130,9 @@ int l2_packet_get_own_src_addr(struct l2_packet_data *l2, u8 *addr);
*/
int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr);
+void get_remote_peer_mac_addr(struct port *port);
+void l2_packet_get_remote_addr(struct l2_packet_data *l2, u8 *addr);
+
/**
* l2_packet_send - Send a packet
* @l2: Pointer to internal l2_packet data from l2_packet_init()
diff --git a/lldp/l2_packet_linux.c b/lldp/l2_packet_linux.c
index 01e2b9c..b01d2c1 100644
--- a/lldp/l2_packet_linux.c
+++ b/lldp/l2_packet_linux.c
@@ -52,6 +52,7 @@ struct l2_packet_data {
u8 perm_mac_addr[ETH_ALEN];
u8 curr_mac_addr[ETH_ALEN];
u8 san_mac_addr[ETH_ALEN];
+ u8 remote_mac_addr[ETH_ALEN];
void (*rx_callback)(void *ctx, unsigned int ifindex,
const u8 *buf, size_t len);
void *rx_callback_ctx;
@@ -80,13 +81,28 @@ int l2_packet_get_own_src_addr(struct l2_packet_data *l2, u8 *addr)
return 0;
}
+
+/*
+ * Extracts the remote peer's MAC address from the rx frame and
+ * puts it in the l2_packet_data
+ */
+void get_remote_peer_mac_addr(struct port *port)
+{
+ int offset = ETH_ALEN; /* points to remote MAC address in RX frame */
+ memcpy(port->l2->remote_mac_addr, &port->rx.framein[offset], ETH_ALEN);
+}
+
+void l2_packet_get_remote_addr(struct l2_packet_data *l2, u8 *addr)
+{
+ memcpy(addr, l2->remote_mac_addr, ETH_ALEN);
+}
+
int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr)
{
memcpy(addr, l2->perm_mac_addr, ETH_ALEN);
return 0;
}
-
int l2_packet_send(struct l2_packet_data *l2, const u8 *dst_addr, u16 proto,
const u8 *buf, size_t len)
{
diff --git a/lldp/rx.c b/lldp/rx.c
index 5dd40c3..2b904b7 100644
--- a/lldp/rx.c
+++ b/lldp/rx.c
@@ -153,7 +153,7 @@ void rxProcessFrame(struct port * port)
return;
}
memset(port->rx.manifest,0, sizeof(rxmanifest));
-
+ get_remote_peer_mac_addr(port);
tlv_offset = sizeof(struct l2_ethhdr); /* Points to 1st TLV */
do {
--
1.7.4.4