]> git.puffer.fish Git - matthieu/frr.git/commitdiff
[lib] mes_lookup string lookup table argument should be marked const
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Thu, 14 Aug 2008 16:59:25 +0000 (17:59 +0100)
committerPaul Jakma <paul@quagga.net>
Fri, 22 Aug 2008 18:52:58 +0000 (19:52 +0100)
2008-08-14 Stephen Hemminger <stephen.hemminger@vyatta.com>

* lib/log.{c,h}: struct message argument should point to const
* */*.c: adjust to suit,

Signed-off-by: Paul Jakma <paul@quagga.net>
bgpd/bgp_network.c
lib/log.c
lib/log.h
lib/memory.c
lib/sockopt.c
lib/sockopt.h
ospfd/ospf_network.c
ripd/ripd.c
zebra/kernel_socket.c
zebra/kernel_socket.h
zebra/rt_netlink.c

index 71f3ec7dc683dffccd329946ffbd05765e88f52b..5dbd487227d4103181ff0c52df82405e474c2aff 100644 (file)
@@ -314,6 +314,11 @@ bgp_connect (struct peer *peer)
   sockopt_reuseaddr (peer->fd);
   sockopt_reuseport (peer->fd);
   
+#ifdef IPTOS_PREC_INTERNETCONTROL
+  if (sockunion_family (&peer->su) == AF_INET)
+    setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL);
+#endif
+
   if (peer->password)
     bgp_md5_set_connect (peer->fd, &peer->su, peer->password);
 
@@ -402,6 +407,11 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
       sockopt_reuseaddr (sock);
       sockopt_reuseport (sock);
       
+#ifdef IPTOS_PREC_INTERNETCONTROL
+      if (ainfo->ai_family == AF_INET)
+       setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
+#endif
+
       if (bgpd_privs.change (ZPRIVS_RAISE) )
         zlog_err ("bgp_socket: could not raise privs");
 
@@ -454,6 +464,10 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
   sockopt_reuseaddr (sock);
   sockopt_reuseport (sock);
 
+#ifdef IPTOS_PREC_INTERNETCONTROL
+  setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
+#endif
+
   memset (&sin, 0, sizeof (struct sockaddr_in));
 
   sin.sin_family = AF_INET;
index ce00bfbb04c2c4eb3bc50e9efa7f0bc5089c56a9..677cf9ade87ff6971308313ab353fda68b86a958 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -740,9 +740,9 @@ zlog_rotate (struct zlog *zl)
 \f
 /* Message lookup function. */
 const char *
-lookup (struct message *mes, int key)
+lookup (const struct message *mes, int key)
 {
-  struct message *pnt;
+  const struct message *pnt;
 
   for (pnt = mes; pnt->key != 0; pnt++) 
     if (pnt->key == key) 
index 7432b25e41e6fab74588dd89562c3545196eb609..777fd77df9376545d1b36d1a344272647cfff778 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -144,7 +144,7 @@ extern int zlog_rotate (struct zlog *);
 /* For hackey massage lookup and check */
 #define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)")
 
-extern const char *lookup (struct message *, int);
+extern const char *lookup (const struct message *, int);
 extern const char *mes_lookup (struct message *meslist, 
                                int max, int index,
                                const char *no_item);
index 9ed5e100aa18134c0c27934e8ff7cc4e71082865..28b3d89693b90e979e5402ae20af2272b2c24cb5 100644 (file)
@@ -33,7 +33,7 @@ static void alloc_inc (int);
 static void alloc_dec (int);
 static void log_memstats(int log_priority);
 \f
-static struct message mstr [] =
+static const struct message mstr [] =
 {
   { MTYPE_THREAD, "thread" },
   { MTYPE_THREAD_MASTER, "thread_master" },
index a2038a5c150b205829d0c343f629bce1f21da125..2f01199a76d5be6d5573a61f1155c17c1afbc4d1 100644 (file)
@@ -342,6 +342,19 @@ setsockopt_ipv4_ifindex (int sock, int val)
   return ret;
 }
 
+int
+setsockopt_ipv4_tos(int sock, int tos)
+{
+  int ret;
+
+  ret = setsockopt (sock, IPPROTO_IP, IP_TOS, &tos, sizeof (tos));
+  if (ret < 0)
+    zlog_warn ("Can't set IP_TOS option for fd %d to %#x: %s",
+              sock, tos, safe_strerror(errno));
+  return ret;
+}
+
+
 int
 setsockopt_ifindex (int af, int sock, int val)
 {
index 95382792dfa0a5a8166bb19f482a281dfe335647..cb05c6fbd1fe0add6663c99c19551da59363c283 100644 (file)
@@ -89,6 +89,7 @@ extern int setsockopt_multicast_ipv4(int sock, int optname,
                                     unsigned int ifindex
                                         /* optional: if non-zero, may be used
                                                instead of if_addr */);
+extern int setsockopt_ipv4_tos(int sock, int tos);
 
 /* Ask for, and get, ifindex, by whatever method is supported. */
 extern int setsockopt_ifindex (int, int, int);
index d5bf7493ee97209917431b6458446446cfe664ec..89ff2038bd26f5f2ed3da320b835b79ded636768 100644 (file)
@@ -165,11 +165,7 @@ int
 ospf_sock_init (void)
 {
   int ospf_sock;
-  /*
-   * XXX warning: unused variable `tos'
-   * tos should be ifdefed similarly to usage
-   */
-  int ret, tos, hincl = 1;
+  int ret, hincl = 1;
 
   if ( ospfd_privs.change (ZPRIVS_RAISE) )
     zlog_err ("ospf_sock_init: could not raise privs, %s",
@@ -201,10 +197,7 @@ ospf_sock_init (void)
 #elif defined (IPTOS_PREC_INTERNETCONTROL)
 #warning "IP_HDRINCL not available on this system"
 #warning "using IPTOS_PREC_INTERNETCONTROL"
-  /* Set precedence field. */
-  tos = IPTOS_PREC_INTERNETCONTROL;
-  ret = setsockopt (ospf_sock, IPPROTO_IP, IP_TOS,
-                   (char *) &tos, sizeof (int));
+  ret = setsockopt_ipv4_tos(ospf_sock, IPTOS_PREC_INTERNETCONTROL);
   if (ret < 0)
     {
       int save_errno = errno;
index 62d8691ccd835adac600d99ce770b3224cfea8f9..2525679c45232f0ce7bdb209aa2ea9d2d14f380b 100644 (file)
@@ -76,7 +76,7 @@ enum
 };
 \f
 /* RIP command strings. */
-struct message rip_msg[] = 
+static const struct message rip_msg[] =
 {
   {RIP_REQUEST,    "REQUEST"},
   {RIP_RESPONSE,   "RESPONSE"},
@@ -84,6 +84,7 @@ struct message rip_msg[] =
   {RIP_TRACEOFF,   "TRACEOFF"},
   {RIP_POLL,       "POLL"},
   {RIP_POLL_ENTRY, "POLL ENTRY"},
+  {0, NULL},
 };
 \f
 /* Utility function to set boradcast option to the socket. */
@@ -3508,7 +3509,7 @@ DEFUN (show_ip_rip_status,
   struct listnode *node;
   struct interface *ifp;
   struct rip_interface *ri;
-  extern struct message ri_version_msg[];
+  extern const struct message ri_version_msg[];
   const char *send_version;
   const char *receive_version;
 
index 2e04b031ea4871cc7ce528255ae5bfd59dec88a3..e77b9b78b2ffac09e18ef00026696126e5894fd6 100644 (file)
@@ -126,7 +126,7 @@ extern struct zebra_t zebrad;
       (LEN) = 0; \
     }
 /* Routing socket message types. */
-struct message rtm_type_str[] =
+const struct message rtm_type_str[] =
 {
   {RTM_ADD,      "RTM_ADD"},
   {RTM_DELETE,   "RTM_DELETE"},
index 8f8a20756ed74c0d077f2b973fae7b3bdaa8461d..e9558ad6dd708c5e80064b3896af28ab9100e108 100644 (file)
@@ -28,6 +28,6 @@ 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);
-extern struct message rtm_type_str[];
+extern const struct message rtm_type_str[];
 
 #endif /* __ZEBRA_KERNEL_SOCKET_H */
index 0a6b8dde429dc900a43bb0675b2f0ed6dd9e43b9..395f1ca6c5fb72e9934015c004f8303528bbff36 100644 (file)
@@ -52,7 +52,7 @@ struct nlsock
 } netlink      = { -1, 0, {0}, "netlink-listen"},     /* kernel messages */
   netlink_cmd  = { -1, 0, {0}, "netlink-cmd"};        /* command channel */
 
-static struct message nlmsg_str[] = {
+static const struct message nlmsg_str[] = {
   {RTM_NEWROUTE, "RTM_NEWROUTE"},
   {RTM_DELROUTE, "RTM_DELROUTE"},
   {RTM_GETROUTE, "RTM_GETROUTE"},
@@ -805,7 +805,7 @@ netlink_routing_table (struct sockaddr_nl *snl, struct nlmsghdr *h)
   return 0;
 }
 
-struct message rtproto_str[] = {
+static const struct message rtproto_str[] = {
   {RTPROT_REDIRECT, "redirect"},
   {RTPROT_KERNEL,   "kernel"},
   {RTPROT_BOOT,     "boot"},