Blame SOURCES/open-lldp-v1.0.1-10-VDP-Support-for-OUI-infrastructure-in-vdp22.patch

436175
From 7289ac24898ae74a3a47fb4e4378d1535c21adba Mon Sep 17 00:00:00 2001
436175
From: padkrish <padkrish@cisco.com>
436175
Date: Wed, 21 Jan 2015 03:39:47 +0000
436175
Subject: [PATCH] VDP: Support for OUI infrastructure in vdp22.
436175
436175
This commit is a framework for supporting OUI fields
436175
in VDP22. This specific patch adds helper functions
436175
(functions exported by VDP to OUI code) to be called by OUI
436175
specific handler code.
436175
436175
Signed-off-by: padkrish <padkrish@cisco.com>
436175
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
436175
---
436175
 Makefile.am             |  2 +-
436175
 include/qbg_utils.h     |  1 +
436175
 include/qbg_vdp22_oui.h | 48 +++++++++++++++++++++++++++++++++++++
436175
 qbg/vdp22_oui.c         | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
436175
 4 files changed, 113 insertions(+), 1 deletion(-)
436175
 create mode 100644 qbg/vdp22_oui.c
436175
436175
diff --git a/Makefile.am b/Makefile.am
436175
index 403088b..f63311c 100644
436175
--- a/Makefile.am
436175
+++ b/Makefile.am
436175
@@ -70,7 +70,7 @@ include/lldp_evb22.h lldp_evb22.c lldp_evb22_cmds.c \
436175
 include/qbg22.h include/qbg_ecp22.h qbg/ecp22.c \
436175
 include/qbg_vdp22.h qbg/vdp22.c qbg/vdpnl.c qbg/vdp22sm.c qbg/vdp22br.c \
436175
 include/qbg_vdp22def.h qbg/vdp22_cmds.c qbg/vdp_ascii.c \
436175
-include/qbg_vdp22_oui.h
436175
+include/qbg_vdp22_oui.h qbg/vdp22_oui.c
436175
 
436175
 lib_LTLIBRARIES = liblldp_clif.la
436175
 liblldp_clif_la_LDFLAGS = -version-info 1:0:0
436175
diff --git a/include/qbg_utils.h b/include/qbg_utils.h
436175
index 6033556..963cb87 100644
436175
--- a/include/qbg_utils.h
436175
+++ b/include/qbg_utils.h
436175
@@ -42,4 +42,5 @@ int modules_notify(int, int, char *, void *);
436175
 
436175
 /* Convert VSI IDs to strings */
436175
 int vdp_uuid2str(const unsigned char *, char *, size_t);
436175
+int vdp_str2uuid(unsigned char *, char *, size_t);
436175
 #endif
436175
diff --git a/include/qbg_vdp22_oui.h b/include/qbg_vdp22_oui.h
436175
index 0cce31e..79e1ff5 100644
436175
--- a/include/qbg_vdp22_oui.h
436175
+++ b/include/qbg_vdp22_oui.h
436175
@@ -92,4 +92,52 @@ struct vdp22_oui_handler_s {
436175
 	unsigned long (*oui_ptlv_size_hndlr)(void *);
436175
 };
436175
 
436175
+unsigned char vdp22_oui_get_vsi22_fmt(void *);
436175
+unsigned char *vdp22_oui_get_vsi22_len(void *, unsigned char *);
436175
+int oui_vdp_str2uuid(unsigned char *, char *, size_t);
436175
+bool oui_vdp_hndlr_init(struct vdp22_oui_handler_s *);
436175
+int oui_vdp_hexstr2bin(const char *hex, unsigned char *buf, size_t len);
436175
+
436175
+static inline size_t oui_append_1o(unsigned char *cp, const unsigned char data)
436175
+{
436175
+	*cp = data;
436175
+	return 1;
436175
+}
436175
+
436175
+static inline size_t oui_append_2o(unsigned char *cp, const unsigned short data)
436175
+{
436175
+	*cp = (data >> 8) & 0xff;
436175
+	*(cp + 1) = data & 0xff;
436175
+	return 2;
436175
+}
436175
+
436175
+static inline size_t oui_append_3o(unsigned char *cp, const unsigned long data)
436175
+{
436175
+	*cp = (data >> 16) & 0xff;
436175
+	*(cp + 1) = (data >> 8) & 0xff;
436175
+	*(cp + 2) = data & 0xff;
436175
+	return 3;
436175
+}
436175
+static inline size_t oui_append_4o(unsigned char *cp, const unsigned long data)
436175
+{
436175
+	*cp = (data >> 24) & 0xff;
436175
+	*(cp + 1) = (data >> 16) & 0xff;
436175
+	*(cp + 2) = (data >> 8) & 0xff;
436175
+	*(cp + 3) = data & 0xff;
436175
+	return 4;
436175
+}
436175
+
436175
+static inline size_t oui_append_nb(unsigned char *cp, const unsigned char *data,
436175
+				   const size_t nlen)
436175
+{
436175
+	memcpy(cp, data, nlen);
436175
+	return nlen;
436175
+}
436175
+
436175
+static inline unsigned short oui_get_tlv_head(unsigned short type,
436175
+					      unsigned short len)
436175
+{
436175
+	return (type & 0x7f) << 9 | (len & 0x1ff);
436175
+}
436175
+
436175
 #endif /* __VDP22_OUI_H__ */
436175
diff --git a/qbg/vdp22_oui.c b/qbg/vdp22_oui.c
436175
new file mode 100644
436175
index 0000000..3a2d0cc
436175
--- /dev/null
436175
+++ b/qbg/vdp22_oui.c
436175
@@ -0,0 +1,63 @@
436175
+/*******************************************************************************
436175
+
436175
+  Implementation of OUI Functionality for VDP2.2
436175
+  This file contains the exported functions from VDP to the OUI handlers file.
436175
+  Copyright (c) 2012-2014 by Cisco Systems, Inc.
436175
+
436175
+  Author(s): Padmanabhan Krishnan <padkrish at cisco dot com>
436175
+
436175
+  This program is free software; you can redistribute it and/or modify it
436175
+  under the terms and conditions of the GNU General Public License,
436175
+  version 2, as published by the Free Software Foundation.
436175
+
436175
+  This program is distributed in the hope it will be useful, but WITHOUT
436175
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
436175
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
436175
+  more details.
436175
+
436175
+  You should have received a copy of the GNU General Public License along with
436175
+  this program; if not, write to the Free Software Foundation, Inc.,
436175
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
436175
+
436175
+  The full GNU General Public License is included in this distribution in
436175
+  the file called "COPYING".
436175
+*******************************************************************************/
436175
+
436175
+#include <stdio.h>
436175
+#include <stdlib.h>
436175
+#include <string.h>
436175
+#include <errno.h>
436175
+#include <ctype.h>
436175
+#include "messages.h"
436175
+#include "lldp_util.h"
436175
+#include "qbg_vdp22.h"
436175
+#include "qbg_utils.h"
436175
+#include "qbg_vdp22_oui.h"
436175
+
436175
+unsigned char vdp22_oui_get_vsi22_fmt(void *vsi_data)
436175
+{
436175
+	if (vsi_data != NULL)
436175
+		return ((struct vsi22 *)(vsi_data))->vsi_fmt;
436175
+	LLDPAD_ERR("%s: NULL Arg\n", __func__);
436175
+	return 0;
436175
+}
436175
+
436175
+unsigned char *vdp22_oui_get_vsi22_len(void *vsi_data, unsigned char *len)
436175
+{
436175
+	if ((vsi_data != NULL) && (len != NULL)) {
436175
+		*len = VDP22_IDSZ;
436175
+		return ((struct vsi22 *)(vsi_data))->vsi;
436175
+	}
436175
+	LLDPAD_ERR("%s: NULL Arg\n", __func__);
436175
+	return NULL;
436175
+}
436175
+
436175
+int oui_vdp_str2uuid(unsigned char *to, char *buffer, size_t max)
436175
+{
436175
+	return vdp_str2uuid(to, buffer, max);
436175
+}
436175
+
436175
+int oui_vdp_hexstr2bin(const char *hex, unsigned char *buf, size_t len)
436175
+{
436175
+	return hexstr2bin(hex, buf, len);
436175
+}
436175
-- 
436175
2.1.0
436175