[lldp-devel] [PATCH 3/6] evb22 make function modules_notify generic

Thomas Richter tmricht at linux.vnet.ibm.com
Tue Feb 5 16:24:58 UTC 2013


Offer a generic function for notifications within qbg modules.
Add  module identifier identifier as sender id.

Signed-off-by: Thomas Richter <tmricht at linux.vnet.ibm.com>
---
 include/lldp_qbg_utils.h |    1 +
 lldp_qbg_utils.c         |   23 +++++++++++++++++++++++
 qbg/lldp_evb22.c         |   26 +++-----------------------
 3 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/include/lldp_qbg_utils.h b/include/lldp_qbg_utils.h
index c9b2afe..744e523 100644
--- a/include/lldp_qbg_utils.h
+++ b/include/lldp_qbg_utils.h
@@ -31,4 +31,5 @@
 #define LLDP_QBG_UTILS_H
 
 void hexdump_frame(const char *, char *, const unsigned char *, size_t);
+int modules_notify(int, int, char *, void *);
 #endif
diff --git a/lldp_qbg_utils.c b/lldp_qbg_utils.c
index 69b9ab1..ffac80b 100644
--- a/lldp_qbg_utils.c
+++ b/lldp_qbg_utils.c
@@ -31,10 +31,12 @@
 #include <linux/if_ether.h>
 
 #include "lldp.h"
+#include "lldp_mod.h"
 #include "messages.h"
 #include "lldp_qbg_utils.h"
 
 extern int loglvl;			/* Global lldpad log level */
+extern struct lldp_head lldp_head;
 
 /*
  * hexdump_frame - print raw evb/ecp/vdp frame
@@ -58,3 +60,24 @@ void hexdump_frame(const char *ifname, char *txt, const unsigned char *buf,
 	}
 	LLDPAD_DBG("%s:%s %s\n%s\n", __func__, ifname, txt, buffer);
 }
+
+/*
+ * Function to advertise changed variables to other modules.
+ *
+ * Parameters are interface name, target module id and data.
+ * When sending the data, the module call back function contains the
+ * module id of the sender.
+ *
+ * Return 0 when no addressee found or addressess found but addressee was
+ * unable to handle data.
+ */
+int modules_notify(int id, int sender_id, char *ifname, void *data)
+{
+	struct lldp_module *mp = find_module_by_id(&lldp_head, id);
+	int rc = 0;
+
+	if (mp && mp->ops->lldp_mod_notify)
+		rc = mp->ops->lldp_mod_notify(sender_id, ifname, data);
+	LLDPAD_DBG("%s:%s target-id:%#x rc:%d\n", __func__, ifname, id, rc);
+	return rc;
+}
diff --git a/qbg/lldp_evb22.c b/qbg/lldp_evb22.c
index 82d0cda..7625b25 100644
--- a/qbg/lldp_evb22.c
+++ b/qbg/lldp_evb22.c
@@ -31,33 +31,13 @@
 #include "lldp_tlv.h"
 #include "lldp_evb22.h"
 #include "lldp_ecp22.h"
+#include "lldp_qbg_utils.h"
 #include "lldp_evb_cmds.h"
 #include "messages.h"
 #include "config.h"
 
 extern struct lldp_head lldp_head;
 
-/*
- * Function to advertise changed variables to other modules.
- *
- * Parameters are interface name, target module id and data.
- * When sending the data, the module call back function contains the
- * module id of the sender.
- *
- * Return 0 when no addressee found or addressess found but addressee was
- * unable to handle data.
- */
-static int modules_notify(int id, char *ifname, void *data)
-{
-	struct lldp_module *mp = find_module_by_id(&lldp_head, id);
-	int rc = 0;
-
-	if (mp && mp->ops->lldp_mod_notify)
-		rc = mp->ops->lldp_mod_notify(LLDP_MOD_EVB22, ifname, data);
-	LLDPAD_DBG("%s:%s target-id:%#x rc:%d\n", __func__, ifname, id, rc);
-	return rc;
-}
-
 struct evb22_data *evb22_data(char *ifname, enum agent_type type)
 {
 	struct evb22_user_data *ud;
@@ -251,7 +231,7 @@ static void evb22_update_tlv(struct evb22_data *ed)
 	qbg.data_type = EVB22_TO_ECP22;
 	qbg.u.a.max_rte = evb_ex_rte(ed->out.r_rte);
 	qbg.u.a.max_retry = evb_ex_retries(ed->out.r_rte);
-	modules_notify(LLDP_MOD_ECP22, ed->ifname, &qbg);
+	modules_notify(LLDP_MOD_ECP22, LLDP_MOD_EVB22, ed->ifname, &qbg);
 
 	qbg.data_type = EVB22_TO_VDP22;
 	qbg.u.b.max_rka = evb_ex_rka(ed->out.rl_rka);
@@ -259,7 +239,7 @@ static void evb22_update_tlv(struct evb22_data *ed)
 	/* Support group identifiers when advertised by both sides */
 	qbg.u.b.gpid = evb_ex_bgid(ed->out.bridge_s)
 		       && evb_ex_sgid(ed->out.station_s);
-	modules_notify(LLDP_MOD_VDP22, ed->ifname, &qbg);
+	modules_notify(LLDP_MOD_VDP22, LLDP_MOD_EVB22, ed->ifname, &qbg);
 }
 
 /*
-- 
1.7.1



More information about the lldp-devel mailing list