[lldp-devel] [PATCH 2/2] vdp remove file lldp_vdp_utils.c

Thomas Richter tmricht at linux.vnet.ibm.com
Mon Mar 11 15:51:44 UTC 2013


Remove file lldp_vdp_utils.c and move its functions to
file lldp_vdp.c.

Signed-off-by: Thomas Richter <tmricht at linux.vnet.ibm.com>
---
 Makefile.am      |    2 +-
 lldp_vdp.c       |   76 ++++++++++++++++++++++++++++++++++++++
 lldp_vdp_utils.c |  107 ------------------------------------------------------
 3 files changed, 77 insertions(+), 108 deletions(-)
 delete mode 100644 lldp_vdp_utils.c

diff --git a/Makefile.am b/Makefile.am
index 0b51c72..57e8613 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,7 +56,7 @@ lldp_dcbx.c include/lldp_dcbx.h tlv_dcbx.c include/tlv_dcbx.h \
 lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h lldp_util.c \
 lldp_mand.c include/lldp_mand.h \
 lldp_mand_cmds.c lldp_basman_cmds.c lldp_8023_cmds.c lldp_med_cmds.c \
-lldp_evb_cmds.c lldp_evb.c include/lldp_evb.h lldp_vdp_cmds.c lldp_vdp_utils.c \
+lldp_evb_cmds.c lldp_evb.c include/lldp_evb.h lldp_vdp_cmds.c \
 include/lldp_vdp_cmds.h \
 include/lldp_ecp.h include/lldp_qbg_utils.h lldp_ecp.c lldp_qbg_utils.c \
 lldp_vdp.c include/lldp_vdp.h \
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 72cf092..0753c71 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -98,6 +98,82 @@ void vdp_trace_profile(struct vsi_profile *p)
 	}
 }
 
+struct vsi_profile *vdp_alloc_profile()
+{
+	struct vsi_profile *prof;
+
+	prof = calloc(1, sizeof *prof);
+	if (prof)
+		LIST_INIT(&prof->macvid_head);
+	return prof;
+}
+
+/*
+ * vdp_remove_macvlan - remove all mac/vlan pairs in the profile
+ * @profile: profile to remove
+ *
+ * Remove all allocated <mac,vlan> pairs on the profile.
+ */
+static void vdp_remove_macvlan(struct vsi_profile *profile)
+{
+	struct mac_vlan *p;
+
+	while ((p = LIST_FIRST(&profile->macvid_head))) {
+		LIST_REMOVE(p, entry);
+		free(p);
+	}
+}
+
+void vdp_delete_profile(struct vsi_profile *prof)
+{
+	vdp_remove_macvlan(prof);
+	free(prof);
+}
+
+/* vdp_profile_equal - checks for equality of 2 profiles
+ * @p1: profile 1
+ * @p2: profile 2
+ *
+ * returns true if equal, false if not
+ *
+ * compares mgrid, id, version, instance 2 vsi profiles to find
+ * out if they are equal.
+ */
+static bool vdp_profile_equal(struct vsi_profile *p1, struct vsi_profile *p2)
+{
+	if (p1->mgrid != p2->mgrid)
+		return false;
+
+	if (p1->id != p2->id)
+		return false;
+
+	if (p1->version != p2->version)
+		return false;
+
+	if (memcmp(p1->instance, p2->instance, 16))
+		return false;
+
+	return true;
+}
+
+/*
+ * vdp_find_profile - Find a profile in the list of profiles already allocated
+ *
+ * Returns pointer to already allocated profile in list, 0 if not.
+ */
+
+struct vsi_profile *vdp_find_profile(struct vdp_data *vd,
+				     struct vsi_profile *thisone)
+{
+	struct vsi_profile *p;
+
+	LIST_FOREACH(p, &vd->profile_head, profile) {
+		if (vdp_profile_equal(p, thisone))
+			return p;
+	}
+	return 0;
+}
+
 /* vdp_data - searches vdp_data in the list of modules for this port
  * @ifname: interface name to search for
  *
diff --git a/lldp_vdp_utils.c b/lldp_vdp_utils.c
deleted file mode 100644
index 86e150d..0000000
--- a/lldp_vdp_utils.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/******************************************************************************
-
-  Implementation of VDP according to IEEE 802.1Qbg
-  (c) Copyright IBM Corp. 2012
-
-  Author(s): Thomas Richter <tmricht at linux.vnet.ibm.com>
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms and conditions of the GNU General Public License,
-  version 2, as published by the Free Software Foundation.
-
-  This program is distributed in the hope it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc.,
-  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-
-  The full GNU General Public License is included in this distribution in
-  the file called "COPYING".
-
-******************************************************************************/
-
-/*
- * This file contains utilities and support functions for the VDP protocol.
- */
-
-#include <stdlib.h>
-#include "lldp_vdp.h"
-
-struct vsi_profile *vdp_alloc_profile()
-{
-	struct vsi_profile *prof;
-
-	prof = calloc(1, sizeof *prof);
-	if (prof)
-		LIST_INIT(&prof->macvid_head);
-	return prof;
-}
-
-/*
- * vdp_remove_macvlan - remove all mac/vlan pairs in the profile
- * @profile: profile to remove
- *
- * Remove all allocated <mac,vlan> pairs on the profile.
- */
-static void vdp_remove_macvlan(struct vsi_profile *profile)
-{
-	struct mac_vlan *p;
-
-	while ((p = LIST_FIRST(&profile->macvid_head))) {
-		LIST_REMOVE(p, entry);
-		free(p);
-	}
-}
-
-void vdp_delete_profile(struct vsi_profile *prof)
-{
-	vdp_remove_macvlan(prof);
-	free(prof);
-}
-
-/* vdp_profile_equal - checks for equality of 2 profiles
- * @p1: profile 1
- * @p2: profile 2
- *
- * returns true if equal, false if not
- *
- * compares mgrid, id, version, instance 2 vsi profiles to find
- * out if they are equal.
- */
-static bool vdp_profile_equal(struct vsi_profile *p1, struct vsi_profile *p2)
-{
-	if (p1->mgrid != p2->mgrid)
-		return false;
-
-	if (p1->id != p2->id)
-		return false;
-
-	if (p1->version != p2->version)
-		return false;
-
-	if (memcmp(p1->instance, p2->instance, 16))
-		return false;
-
-	return true;
-}
-
-/*
- * vdp_find_profile - Find a profile in the list of profiles already allocated
- *
- * Returns pointer to already allocated profile in list, 0 if not.
- */
-
-struct vsi_profile *vdp_find_profile(struct vdp_data *vd,
-				     struct vsi_profile *thisone)
-{
-	struct vsi_profile *p;
-
-	LIST_FOREACH(p, &vd->profile_head, profile) {
-		if (vdp_profile_equal(p, thisone))
-			return p;
-	}
-	return 0;
-}
-- 
1.7.1



More information about the lldp-devel mailing list