]> git.puffer.fish Git - mirror/frr.git/commitdiff
[zebra] Fix mistake in previous commit and further compile warnings/errors.
authorpaul <paul>
Thu, 24 Nov 2005 15:15:17 +0000 (15:15 +0000)
committerpaul <paul>
Thu, 24 Nov 2005 15:15:17 +0000 (15:15 +0000)
2005-11-24 Paul Jakma <paul.jakma@sun.com>

* kernel_socket.h: New header for functions exported to sysctl
  methods.
* kernel_socket.c: include previous.
  Remove static qualifier from couple of functions which are
  used by sysctl methods, incorrectly added in previous commit.
  Add a workaround for a bogus gcc warning to the RTA_ macros.
* Makefile.am: Add kernel_socket.h to noinst_HEADERS
* if_sysctl.c: include rt.h and kernel_socket.h and remove
  redundant prototypes.
* rtread_sysctl.c: ditto.
  (route_read) fix mismatch of return values.
* {rt,zserv,rib}.h: Include lib headers depended on.

zebra/ChangeLog
zebra/Makefile.am
zebra/if_sysctl.c
zebra/kernel_socket.c
zebra/kernel_socket.h [new file with mode: 0644]
zebra/rib.h
zebra/rt.h
zebra/rtread_sysctl.c
zebra/zserv.h

index 734dd84b1610b92ba5cd29fbd04c3e594a2a31be..4764012c7fe0338f107c2bf66dd4b9cdc8b455e7 100644 (file)
@@ -1,3 +1,18 @@
+2005-11-24 Paul Jakma <paul.jakma@sun.com>
+
+       * kernel_socket.h: New header for functions exported to sysctl
+         methods.
+       * kernel_socket.c: include previous.
+         Remove static qualifier from couple of functions which are
+         used by sysctl methods.
+         Add a workaround for a bogus gcc warning to the RTA_ macros.
+       * Makefile.am: Add kernel_socket.h to noinst_HEADERS
+       * if_sysctl.c: include rt.h and kernel_socket.h and remove
+         redundant prototypes.
+       * rtread_sysctl.c: ditto.
+         (route_read) fix mismatch of return values.
+       * {rt,zserv,rib}.h: Include lib headers depended on.
+
 2005-11-23 Paul Jakma <paul.jakma@sun.com>
 
        * (general) fix some small compile errors, and mark several
index 7dc495e903e95843b69ff3c31ee192739b3bf0e1..751f606f8d2a201fca02f36c940ee855334a7ed9 100644 (file)
@@ -28,7 +28,7 @@ zebra_SOURCES = \
 
 noinst_HEADERS = \
        connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
-       interface.h ipforward.h irdp.h router-id.h
+       interface.h ipforward.h irdp.h router-id.h kernel_socket.h
 
 zebra_LDADD = $(otherobj) $(LIBCAP) $(LIB_IPV6) ../lib/libzebra.la
 
index 7ad570f4a401295b04b64cd61bbdc41e63de322f..f1e3dcde4fd8c04a386e593423cf4402d379f3f8 100644 (file)
@@ -30,6 +30,9 @@
 #include "ioctl.h"
 #include "log.h"
 
+#include "zebra/rt.h"
+#include "zebra/kernel_socket.h"
+
 int
 ifstat_update_sysctl ()
 {
@@ -91,8 +94,6 @@ interface_list ()
   caddr_t ref, buf, end;
   size_t bufsiz;
   struct if_msghdr *ifm;
-  int ifm_read (struct if_msghdr *);
-  int ifam_read (struct ifa_msghdr *);
 
 #define MIBSIZ 6
   int mib[MIBSIZ] =
index 903d67908ad98440e6324274a970dd520ed7fda0..3b290e96637cc6b2c7391fe2963a92bb6aebbc20 100644 (file)
@@ -36,6 +36,7 @@
 #include "zebra/interface.h"
 #include "zebra/zserv.h"
 #include "zebra/debug.h"
+#include "zebra/kernel_socket.h"
 
 extern struct zebra_privs_t zserv_privs;
 extern struct zebra_t zebrad;
@@ -77,27 +78,35 @@ extern struct zebra_t zebrad;
            ROUNDUP(sizeof(struct sockaddr_dl)) : sizeof(struct sockaddr)))
 #endif /* HAVE_SA_LEN */
 
+/* We use an additional pointer in following, pdest, rather than (DEST)
+ * directly, because gcc will warn if the macro is expanded and DEST is NULL,
+ * complaining that memcpy is being passed a NULL value, despite the fact
+ * the if (NULL) makes it impossible.
+ */
 #define RTA_ADDR_GET(DEST, RTA, RTMADDRS, PNT) \
   if ((RTMADDRS) & (RTA)) \
     { \
+      void *pdest = (DEST); \
       int len = SAROUNDUP ((PNT)); \
       if ( ((DEST) != NULL) && \
            af_check (((struct sockaddr *)(PNT))->sa_family)) \
-        memcpy ((DEST), (PNT), len); \
+        memcpy (pdest, (PNT), len); \
       (PNT) += len; \
     }
 #define RTA_ATTR_GET(DEST, RTA, RTMADDRS, PNT) \
   if ((RTMADDRS) & (RTA)) \
     { \
+      void *pdest = (DEST); \
       int len = SAROUNDUP ((PNT)); \
-      if ( ((DEST) != NULL) ) \
-        memcpy ((DEST), (PNT), len); \
+      if ((DEST) != NULL) \
+        memcpy (pdest, (PNT), len); \
       (PNT) += len; \
     }
 
 #define RTA_NAME_GET(DEST, RTA, RTMADDRS, PNT, LEN) \
   if ((RTMADDRS) & (RTA)) \
     { \
+      u_char *pdest = (u_char *) (DEST); \
       int len = SAROUNDUP ((PNT)); \
       struct sockaddr_dl *sdl = (struct sockaddr_dl *)(PNT); \
       if (IS_ZEBRA_DEBUG_KERNEL) \
@@ -106,8 +115,8 @@ extern struct zebra_t zebrad;
       if ( ((DEST) != NULL) && (sdl->sdl_family == AF_LINK) \
            && (sdl->sdl_nlen < IFNAMSIZ) && (sdl->sdl_nlen <= len) ) \
         { \
-          memcpy ((DEST), sdl->sdl_data, sdl->sdl_nlen); \
-          (DEST)[sdl->sdl_nlen] = '\0'; \
+          memcpy (pdest, sdl->sdl_data, sdl->sdl_nlen); \
+          pdest[sdl->sdl_nlen] = '\0'; \
           (LEN) = sdl->sdl_nlen; \
         } \
       (PNT) += len; \
@@ -251,8 +260,9 @@ ifan_read (struct if_announcemsghdr *ifan)
     assert ( (ifp->ifindex == ifan->ifan_index) 
              || (ifp->ifindex == IFINDEX_INTERNAL) );
 
-  if ( (ifp == NULL) || (ifp->ifindex == IFINDEX_INTERNAL)
-      && (ifan->ifan_what == IFAN_ARRIVAL) )
+  if ( (ifp == NULL) 
+      || ((ifp->ifindex == IFINDEX_INTERNAL)
+          && (ifan->ifan_what == IFAN_ARRIVAL)) )
     {
       if (IS_ZEBRA_DEBUG_KERNEL)
         zlog_debug ("%s: creating interface for ifindex %d, name %s",
@@ -286,7 +296,7 @@ ifan_read (struct if_announcemsghdr *ifan)
  * sysctl (from interface_list).  There may or may not be sockaddrs
  * present after the header.
  */
-static int
+int
 ifm_read (struct if_msghdr *ifm)
 {
   struct interface *ifp = NULL;
@@ -510,7 +520,7 @@ ifam_read_mesg (struct ifa_msghdr *ifm,
 }
 
 /* Interface's address information get. */
-static int
+int
 ifam_read (struct ifa_msghdr *ifam)
 {
   struct interface *ifp = NULL;
@@ -624,7 +634,7 @@ rtm_read_mesg (struct rt_msghdr *rtm,
   return rtm->rtm_flags;
 }
 
-static void
+void
 rtm_read (struct rt_msghdr *rtm)
 {
   int flags;
diff --git a/zebra/kernel_socket.h b/zebra/kernel_socket.h
new file mode 100644 (file)
index 0000000..a3923c5
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Exported kernel_socket functions, exported only for convenience of
+ * sysctl methods.
+ *
+ * This file is part of Quagga.
+ *
+ * Quagga 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.
+ *
+ * Quagga 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 Quagga; see the file COPYING.  If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.  
+ */
+
+#ifndef __ZEBRA_KERNEL_SOCKET_H
+#define __ZEBRA_KERNEL_SOCKET_H
+
+extern void rtm_read (struct rt_msghdr *);
+extern int ifam_read (struct ifa_msghdr *);
+extern int ifm_read (struct if_msghdr *);
+extern int rtm_write (int, union sockunion *, union sockunion *,
+                      union sockunion *, unsigned int, int, int);
+
+#endif /* __ZEBRA_KERNEL_SOCKET_H */
index 8d1284642e1d2b2681c2245c448aae223ba90db5..a1a9e1dbc4fc1aae185b3f3a440162b17b8ce374 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef _ZEBRA_RIB_H
 #define _ZEBRA_RIB_H
 
+#include "prefix.h"
+
 #define DISTANCE_INFINITY  255
 
 /* Routing information base. */
index e902b21091e40e8f5410ca5cfe7dfa2c6c76d706..82747d3d73eee3e662bedd641d8c1f5bcbd4a04b 100644 (file)
@@ -23,6 +23,9 @@
 #ifndef _ZEBRA_RT_H
 #define _ZEBRA_RT_H
 
+#include "prefix.h"
+#include "if.h"
+
 extern int kernel_add_ipv4 (struct prefix *, struct rib *);
 extern int kernel_delete_ipv4 (struct prefix *, struct rib *);
 extern int kernel_add_route (struct prefix_ipv4 *, struct in_addr *, int, int);
index e39d8cb153447e3a9b30eb5d3cb4756b71d351b2..88527b374391831897c870ec5728ab3cad814a94 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "zebra/zserv.h"
 #include "zebra/rt.h"
+#include "zebra/kernel_socket.h"
 
 /* Kernel routing table read up by sysctl function. */
 void
@@ -35,7 +36,6 @@ route_read (void)
   caddr_t buf, end, ref;
   size_t bufsiz;
   struct rt_msghdr *rtm;
-  void rtm_read (struct rt_msghdr *);
   
 #define MIBSIZ 6
   int mib[MIBSIZ] = 
@@ -52,7 +52,7 @@ route_read (void)
   if (sysctl (mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0) 
     {
       zlog_warn ("sysctl fail: %s", safe_strerror (errno));
-      return -1;
+      return;
     }
 
   /* Allocate buffer. */
@@ -62,7 +62,7 @@ route_read (void)
   if (sysctl (mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0) 
     {
       zlog_warn ("sysctl() fail by %s", safe_strerror (errno));
-      return -1;
+      return;
     }
 
   for (end = buf + bufsiz; buf < end; buf += rtm->rtm_msglen) 
@@ -74,5 +74,5 @@ route_read (void)
   /* Free buffer. */
   XFREE (MTYPE_TMP, ref);
 
-  return 0;
+  return;
 }
index f7d3f8c07e87b8032410f27d36ecb892bffd7b20..9a570fb3bea19ef8e8587e490576a7256c0b879d 100644 (file)
@@ -23,6 +23,7 @@
 #define _ZEBRA_ZSERV_H
 
 #include "rib.h"
+#include "if.h"
 #include "workqueue.h"
 
 /* Default port information. */