Browse Source

[isisd] Fix compiler warnings and allow v4-only compilation

2006-12-08 Hannes Gredler <hannes@gredler.at>

	* isis_adjacency.c: (isis_new_adj) Allow NULL snpa argument.
	* isis_pdu.c: (various) Update calls to isis_new_adj() to pass
	  NULL and use default.
	* (general) Add forward declarations where required.
	  Fix up const char *'s.
	  Allow V4-only compilation.
Paul Jakma 13 years ago
parent
commit
41b36e9013

+ 9 - 0
isisd/ChangeLog

@@ -1,3 +1,12 @@
+2006-12-08 Hannes Gredler <hannes@gredler.at>
+
+	* isis_adjacency.c: (isis_new_adj) Allow NULL snpa argument.
+	* isis_pdu.c: (various) Update calls to isis_new_adj() to pass
+	  NULL and use default.
+	* (general) Add forward declarations where required.
+	  Fix up const char *'s.
+	  Allow V4-only compilation.
+
 2006-01-17 Paul Jakma <paul.jakma@sun.com>
 
 	* isis_zebra.c: (isis_zebra_route_add_ipv4) fix for new

+ 5 - 0
isisd/isis_adjacency.c

@@ -72,7 +72,12 @@ isis_new_adj (u_char * id, u_char * snpa, int level,
       return NULL;
     }
 
+  if (snpa) {
   memcpy (adj->snpa, snpa, 6);
+  } else {
+      memset (adj->snpa, ' ', 6);
+  }
+
   adj->circuit = circuit;
   adj->level = level;
   adj->flaps = 0;

+ 10 - 2
isisd/isis_circuit.c

@@ -57,6 +57,14 @@
 extern struct thread_master *master;
 extern struct isis *isis;
 
+/*
+ * Prototypes.
+ */
+void isis_circuit_down(struct isis_circuit *);
+int isis_interface_config_write(struct vty *);
+int isis_if_new_hook(struct interface *);
+int isis_if_delete_hook(struct interface *);
+
 struct isis_circuit *
 isis_circuit_new ()
 {
@@ -275,10 +283,10 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
 {
   struct prefix_ipv4 *ipv4, *ip = NULL;
   struct listnode *node;
-  int found = 0;
   u_char buf[BUFSIZ];
 #ifdef HAVE_IPV6
   struct prefix_ipv6 *ipv6, *ip6 = NULL;
+  int found = 0;
 #endif /* HAVE_IPV6 */
 
   memset (&buf, 0, BUFSIZ);
@@ -944,7 +952,7 @@ DEFUN (isis_circuit_type,
 
   assert (circuit);
 
-  circuit_t = string2circuit_t ((u_char *)argv[0]);
+  circuit_t = string2circuit_t (argv[0]);
 
   if (!circuit_t)
     {

+ 1 - 1
isisd/isis_lsp.c

@@ -727,10 +727,10 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
 #ifdef HAVE_IPV6
   struct ipv6_reachability *ipv6_reach;
   struct in6_addr in6;
+  u_char buff[BUFSIZ];
 #endif
   u_char LSPid[255];
   u_char hostname[255];
-  u_char buff[BUFSIZ];
   u_char ipv4_reach_prefix[20];
   u_char ipv4_reach_mask[20];
   u_char ipv4_address[20];

+ 10 - 0
isisd/isis_main.c

@@ -107,6 +107,16 @@ int _argc;
 char **_argv;
 char **_envp;
 
+/*
+ * Prototypes.
+ */
+void reload(void);
+void sighup(void);
+void sigint(void);
+void sigterm(void);
+void sigusr1(void);
+
+
 /* Help information display. */
 static void
 usage (int status)

+ 8 - 8
isisd/isis_misc.c

@@ -99,15 +99,15 @@ isonet_print (u_char * from, int len)
  * extract dot from the dotted str, and insert all the number in a buff 
  */
 int
-dotformat2buff (u_char * buff, u_char * dotted)
+dotformat2buff (u_char * buff, const u_char * dotted)
 {
   int dotlen, len = 0;
-  u_char *pos = dotted;
+  const u_char *pos = dotted;
   u_char number[3];
   int nextdotpos = 2;
 
   number[2] = '\0';
-  dotlen = strlen ((char *)dotted);
+  dotlen = strlen(dotted);
   if (dotlen > 50)
     {
       /* this can't be an iso net, its too long */
@@ -165,7 +165,7 @@ sysid2buff (u_char * buff, const u_char * dotted)
 
   number[2] = '\0';
   // surely not a sysid_string if not 14 length
-  if (strlen ((char *)dotted) != 14)
+  if (strlen (dotted) != 14)
     {
       return 0;
     }
@@ -271,19 +271,19 @@ speaks (struct nlpids *nlpids, int family)
  * Returns 0 on error, IS-IS Circuit Type on ok
  */
 int
-string2circuit_t (u_char * str)
+string2circuit_t (const u_char * str)
 {
 
   if (!str)
     return 0;
 
-  if (!strcmp ((char *)str, "level-1"))
+  if (!strcmp (str, "level-1"))
     return IS_LEVEL_1;
 
-  if (!strcmp ((char *)str, "level-2-only") || !strcmp ((char *)str, "level-2"))
+  if (!strcmp (str, "level-2-only") || !strcmp (str, "level-2"))
     return IS_LEVEL_2;
 
-  if (!strcmp ((char *)str, "level-1-2"))
+  if (!strcmp (str, "level-1-2"))
     return IS_LEVEL_1_AND_2;
 
   return 0;

+ 2 - 3
isisd/isis_misc.h

@@ -24,8 +24,7 @@
 #ifndef _ZEBRA_ISIS_MISC_H
 #define _ZEBRA_ISIS_MISC_H
 
-int dotformat2buff (u_char *, u_char *);
-int string2circuit_t (u_char *);
+int string2circuit_t (const u_char *);
 const char *circuit_t2string (int);
 const char *syst2string (int);
 struct in_addr newprefix2inaddr (u_char * prefix_start,
@@ -34,7 +33,7 @@ struct in_addr newprefix2inaddr (u_char * prefix_start,
  * Converting input to memory stored format
  * return value of 0 indicates wrong input
  */
-int dotformat2buff (u_char *, u_char *);
+int dotformat2buff (u_char *, const u_char *);
 int sysid2buff (u_char *, const u_char *);
 
 /*

+ 3 - 3
isisd/isis_pdu.c

@@ -335,7 +335,7 @@ process_p2p_hello (struct isis_circuit *circuit)
   adj = circuit->u.p2p.neighbor;
   if (!adj)
     {
-      adj = isis_new_adj (hdr->source_id, (u_char *) "      ", 0, circuit);
+      adj = isis_new_adj (hdr->source_id, NULL, 0, circuit);
       if (adj == NULL)
 	return ISIS_ERROR;
       circuit->u.p2p.neighbor = adj;
@@ -1596,7 +1596,7 @@ process_is_hello (struct isis_circuit *circuit)
   if (!adj)
     {
       /* 8.2.2 */
-      adj = isis_new_adj (sysid, (u_char *) "      ", 0, circuit);
+      adj = isis_new_adj (sysid, NULL, 0, circuit);
       if (adj == NULL)
 	return ISIS_ERROR;
 
@@ -1612,7 +1612,7 @@ process_is_hello (struct isis_circuit *circuit)
       /* 8.2.2 a) 2) delete the adj */
       XFREE (MTYPE_ISIS_ADJACENCY, adj);
       /* 8.2.2 a) 3) create a new adj */
-      adj = isis_new_adj (sysid, (u_char *) "      ", 0, circuit);
+      adj = isis_new_adj (sysid, NULL, 0, circuit);
       if (adj == NULL)
 	return ISIS_ERROR;
 

+ 8 - 1
isisd/isis_route.c

@@ -631,6 +631,8 @@ isis_route_validate_table (struct isis_area *area, struct route_table *table)
 	      if (drnode->info == rnode->info)
 		drnode->info = NULL;
 	    }
+
+#ifdef HAVE_IPV6
 	  if (rnode->p.family == AF_INET6)
 	    {
 	      drnode = route_node_get (area->route_table6[0], &rnode->p);
@@ -640,6 +642,7 @@ isis_route_validate_table (struct isis_area *area, struct route_table *table)
 	      if (drnode->info == rnode->info)
 		drnode->info = NULL;
 	    }
+#endif
 	      
 	  isis_route_delete (&rnode->p, table);
 	}
@@ -667,8 +670,10 @@ isis_route_validate_merge (struct isis_area *area, int family)
 
   if (family == AF_INET)
     table = area->route_table[0];
+#ifdef HAVE_IPV6
   else if (family == AF_INET6)
     table = area->route_table6[0];
+#endif
 
   for (rnode = route_top (table); rnode; rnode = route_next (rnode))
     {
@@ -680,8 +685,10 @@ isis_route_validate_merge (struct isis_area *area, int family)
 
   if (family == AF_INET)
     table = area->route_table[1];
+#ifdef HAVE_IPV6
   else if (family == AF_INET6)
     table = area->route_table6[1];
+#endif
 
   for (rnode = route_top (table); rnode; rnode = route_next (rnode))
     {
@@ -719,8 +726,8 @@ isis_route_validate (struct thread *thread)
 
   isis_route_validate_merge (area, AF_INET);
 
-#ifdef HAVE_IPV6
 validate_ipv6:
+#ifdef HAVE_IPV6
   if (area->is_type == IS_LEVEL_1)
     {
       isis_route_validate_table (area, area->route_table6[0]);

+ 8 - 0
isisd/isis_routemap.c

@@ -49,6 +49,14 @@
 
 extern struct isis *isis;
 
+/*
+ * Prototypes.
+ */
+void isis_route_map_upd(const char *);
+void isis_route_map_event(route_map_event_t, const char *);
+void isis_route_map_init(void);
+
+
 void
 isis_route_map_upd (const char *name)
 {

+ 5 - 3
isisd/isis_spf.c

@@ -998,8 +998,10 @@ isis_run_spf (struct isis_area *area, int level, int family)
   /* Make all routes in current route table inactive. */
   if (family == AF_INET)
     table = area->route_table[level - 1];
+#ifdef HAVE_IPV6
   else if (family == AF_INET6)
     table = area->route_table6[level - 1];
+#endif
 
   for (rode = route_top (table); rode; rode = route_next (rode))
     {
@@ -1333,16 +1335,16 @@ isis_print_paths (struct vty *vty, struct list *paths)
 	      nh_dyn = dynhn_find_by_id (adj->sysid);
 	      vty_out (vty, "%-20s %-10u %-20s %-11s %-5s%s",
 		       (dyn != NULL) ? dyn->name.name :
-		       (u_char *) rawlspid_print ((u_char *) vertex->N.id),
+		       (const u_char *)rawlspid_print ((u_char *) vertex->N.id),
 		       vertex->d_N, (nh_dyn != NULL) ? nh_dyn->name.name :
-		       (u_char *) rawlspid_print (adj->sysid),
+		       (const u_char *)rawlspid_print (adj->sysid),
 		       adj->circuit->interface->name,
 		       snpa_print (adj->snpa), VTY_NEWLINE);
 	    }
 	  else
 	    {
 	      vty_out (vty, "%s              %u %s", dyn ? dyn->name.name :
-		       (u_char *) rawlspid_print (vertex->N.id),
+		       (const u_char *) rawlspid_print (vertex->N.id),
 		       vertex->d_N, VTY_NEWLINE);
 	    }
 	}

+ 5 - 0
isisd/isis_tlv.c

@@ -45,6 +45,11 @@
 
 extern struct isis *isis;
 
+/*
+ * Prototypes.
+ */
+int add_tlv (u_char, u_char, u_char *, struct stream *);
+
 void
 free_tlv (void *val)
 {

+ 4 - 2
isisd/isis_zebra.c

@@ -72,7 +72,7 @@ isis_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length)
 
   if (isis->debugs & DEBUG_ZEBRA)
     zlog_debug ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d",
-		ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
+		ifp->name, ifp->ifindex, (long)ifp->flags, ifp->metric, ifp->mtu);
 
   if (if_is_operative (ifp))
     isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
@@ -98,7 +98,7 @@ isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length)
 
   if (isis->debugs & DEBUG_ZEBRA)
     zlog_debug ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d",
-		ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
+		ifp->name, ifp->ifindex, (long)ifp->flags, ifp->metric, ifp->mtu);
 
 
   /* Cannot call if_delete because we should retain the pseudo interface
@@ -571,12 +571,14 @@ isis_zebra_read_ipv4 (int command, struct zclient *zclient,
   return 0;
 }
 
+#ifdef HAVE_IPV6
 static int
 isis_zebra_read_ipv6 (int command, struct zclient *zclient,
 		      zebra_size_t length)
 {
   return 0;
 }
+#endif
 
 #define ISIS_TYPE_IS_REDISTRIBUTED(T) \
 T == ZEBRA_ROUTE_MAX ? zclient->default_information : zclient->redist[type]

+ 20 - 5
isisd/isisd.c

@@ -61,6 +61,21 @@ u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
 struct isis *isis = NULL;
 extern struct thread_master *master;
 
+/*
+ * Prototypes.
+ */
+void isis_new(unsigned long);
+struct isis_area *isis_area_create(void);
+int isis_area_get(struct vty *, const char *);
+int isis_area_destroy(struct vty *, const char *);
+int area_net_title(struct vty *, const u_char *);
+int area_clear_net_title(struct vty *, const u_char *);
+int show_clns_neigh(struct vty *, char);
+void print_debug(struct vty *, int, int);
+int isis_config_write(struct vty *);
+
+
+
 void
 isis_new (unsigned long process_id)
 {
@@ -217,7 +232,7 @@ isis_area_destroy (struct vty *vty, const char *area_tag)
 }
 
 int
-area_net_title (struct vty *vty, u_char *net_title)
+area_net_title (struct vty *vty, const u_char *net_title)
 {
   struct isis_area *area;
   struct area_addr *addr;
@@ -311,7 +326,7 @@ area_net_title (struct vty *vty, u_char *net_title)
 }
 
 int
-area_clear_net_title (struct vty *vty, u_char *net_title)
+area_clear_net_title (struct vty *vty, const u_char *net_title)
 {
   struct isis_area *area;
   struct area_addr addr, *addrp = NULL;
@@ -997,7 +1012,7 @@ DEFUN (net,
        "A Network Entity Title for this process (OSI only)\n"
        "XX.XXXX. ... .XXX.XX  Network entity title (NET)\n")
 {
-  return area_net_title (vty, (u_char *)argv[0]);
+  return area_net_title (vty, argv[0]);
 }
 
 /*
@@ -1010,7 +1025,7 @@ DEFUN (no_net,
        "A Network Entity Title for this process (OSI only)\n"
        "XX.XXXX. ... .XXX.XX  Network entity title (NET)\n")
 {
-  return area_clear_net_title (vty, (u_char *)argv[0]);
+  return area_clear_net_title (vty, argv[0]);
 }
 
 DEFUN (area_passwd,
@@ -1182,7 +1197,7 @@ DEFUN (is_type,
       return CMD_WARNING;
     }
 
-  type = string2circuit_t ((u_char *)argv[0]);
+  type = string2circuit_t (argv[0]);
   if (!type)
     {
       vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);

+ 0 - 6
isisd/iso_checksum.c

@@ -191,9 +191,3 @@ iso_csum_create (u_char * buffer, int len, u_int16_t n)
   /* return the checksum for user usage */
   return checksum;
 }
-
-int
-iso_csum_modify (u_char * buffer, int len, uint16_t * csum)
-{
-  return 0;
-}

+ 11 - 1
isisd/topology/random.c

@@ -10,7 +10,17 @@
 #include <sys/types.h>
 #include <sys/times.h>
 
-unsigned long timer()
+/*
+ * Prototypes.
+ */
+unsigned long timer(void);
+void init_rand(long);
+double rand01(void);
+double randg01(void);
+long nrand(long);
+void free_arc(void *);
+
+unsigned long timer ()
    { struct tms hold;
 
         times(&hold);

+ 9 - 0
isisd/topology/spgrid.c

@@ -26,6 +26,15 @@
 
 #define NODE( x, y ) (x*Y + y + 1)
 
+/*
+ * Prototypes.
+ */
+void free_arc(void *);
+void help(struct vty *);
+void print_arc(struct vty *, struct list *, long, long, long);
+void hhelp(struct vty *);
+void usage(struct vty *);
+
 const char   *graph_type[] =  {
   "double cycle",
   "cycle",