Browse Source

lib: hide internal prefix list structures

These are about to be touched and there's no point in other code
touching into prefix list's internas.  Add some isolation.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter 3 years ago
parent
commit
e66cbd10d5
5 changed files with 84 additions and 45 deletions
  1. 3 0
      lib/Makefile.am
  2. 6 19
      lib/plist.c
  3. 2 24
      lib/plist.h
  4. 71 0
      lib/plist_int.h
  5. 2 2
      ospfd/ospf_zebra.c

+ 3 - 0
lib/Makefile.am

@@ -30,6 +30,9 @@ pkginclude_HEADERS = \
 	privs.h sigevent.h pqueue.h jhash.h zassert.h memtypes.h \
 	workqueue.h route_types.h libospf.h
 
+noinst_HEADERS = \
+	plist_int.h
+
 EXTRA_DIST = \
 	regex.c regex-gnu.h \
 	queue.h \

+ 6 - 19
lib/plist.c

@@ -30,25 +30,7 @@
 #include "stream.h"
 #include "log.h"
 
-/* Each prefix-list's entry. */
-struct prefix_list_entry
-{
-  int seq;
-
-  int le;
-  int ge;
-
-  enum prefix_list_type type;
-
-  int any;
-  struct prefix prefix;
-
-  unsigned long refcnt;
-  unsigned long hitcnt;
-
-  struct prefix_list_entry *next;
-  struct prefix_list_entry *prev;
-};
+#include "plist_int.h"
 
 /* List of struct prefix_list. */
 struct prefix_list_list
@@ -125,6 +107,11 @@ prefix_master_get (afi_t afi)
   return NULL;
 }
 
+const char *prefix_list_name (struct prefix_list *plist)
+{
+  return plist->name;
+}
+
 /* Lookup prefix_list from list of prefix_list by name. */
 struct prefix_list *
 prefix_list_lookup (afi_t afi, const char *name)

+ 2 - 24
lib/plist.h

@@ -31,30 +31,7 @@ enum prefix_list_type
   PREFIX_PERMIT,
 };
 
-enum prefix_name_type
-{
-  PREFIX_TYPE_STRING,
-  PREFIX_TYPE_NUMBER
-};
-
-struct prefix_list
-{
-  char *name;
-  char *desc;
-
-  struct prefix_master *master;
-
-  enum prefix_name_type type;
-
-  int count;
-  int rangecount;
-
-  struct prefix_list_entry *head;
-  struct prefix_list_entry *tail;
-
-  struct prefix_list *next;
-  struct prefix_list *prev;
-};
+struct prefix_list;
 
 struct orf_prefix
 {
@@ -70,6 +47,7 @@ extern void prefix_list_reset (void);
 extern void prefix_list_add_hook (void (*func) (struct prefix_list *));
 extern void prefix_list_delete_hook (void (*func) (struct prefix_list *));
 
+extern const char *prefix_list_name (struct prefix_list *);
 extern struct prefix_list *prefix_list_lookup (afi_t, const char *);
 extern enum prefix_list_type prefix_list_apply (struct prefix_list *, void *);
 

+ 71 - 0
lib/plist_int.h

@@ -0,0 +1,71 @@
+/*
+ * Prefix list internal definitions.
+ * Copyright (C) 1999 Kunihiro Ishiguro
+ *
+ * This file is part of GNU Zebra.
+ *
+ * GNU Zebra is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * GNU Zebra is distributed in the hope that 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 GNU Zebra; see the file COPYING.  If not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_PLIST_INT_H
+#define _QUAGGA_PLIST_INT_H
+
+enum prefix_name_type
+{
+  PREFIX_TYPE_STRING,
+  PREFIX_TYPE_NUMBER
+};
+
+struct prefix_list
+{
+  char *name;
+  char *desc;
+
+  struct prefix_master *master;
+
+  enum prefix_name_type type;
+
+  int count;
+  int rangecount;
+
+  struct prefix_list_entry *head;
+  struct prefix_list_entry *tail;
+
+  struct prefix_list *next;
+  struct prefix_list *prev;
+};
+
+/* Each prefix-list's entry. */
+struct prefix_list_entry
+{
+  int seq;
+
+  int le;
+  int ge;
+
+  enum prefix_list_type type;
+
+  int any;
+  struct prefix prefix;
+
+  unsigned long refcnt;
+  unsigned long hitcnt;
+
+  struct prefix_list_entry *next;
+  struct prefix_list_entry *prev;
+};
+
+#endif /* _QUAGGA_PLIST_INT_H */

+ 2 - 2
ospfd/ospf_zebra.c

@@ -1126,7 +1126,7 @@ ospf_prefix_list_update (struct prefix_list *plist)
     {
       /* Update filter-list in. */
       if (PREFIX_NAME_IN (area))
-        if (strcmp (PREFIX_NAME_IN (area), plist->name) == 0)
+        if (strcmp (PREFIX_NAME_IN (area), prefix_list_name (plist)) == 0)
           {
             PREFIX_LIST_IN (area) =
               prefix_list_lookup (AFI_IP, PREFIX_NAME_IN (area));
@@ -1135,7 +1135,7 @@ ospf_prefix_list_update (struct prefix_list *plist)
 
       /* Update filter-list out. */
       if (PREFIX_NAME_OUT (area))
-        if (strcmp (PREFIX_NAME_OUT (area), plist->name) == 0)
+        if (strcmp (PREFIX_NAME_OUT (area), prefix_list_name (plist)) == 0)
           {
             PREFIX_LIST_IN (area) =
               prefix_list_lookup (AFI_IP, PREFIX_NAME_OUT (area));