Browse Source

Indentation only. No any functional changes.

hasso 15 years ago
parent
commit
f390d2c783

File diff suppressed because it is too large
+ 1137 - 953
isisd/dict.c


+ 67 - 61
isisd/dict.h

@@ -14,7 +14,7 @@
  * into proprietary software; there is no requirement for such software to
  * contain a copyright notice related to this source.
  *
- * $Id: dict.h,v 1.1 2003/12/23 08:09:48 jardin Exp $
+ * $Id: dict.h,v 1.2 2004/09/10 20:48:21 hasso Exp $
  * $Name:  $
  */
 
@@ -31,37 +31,41 @@
  */
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
-typedef unsigned long dictcount_t;
+  typedef unsigned long dictcount_t;
 #define DICTCOUNT_T_MAX ULONG_MAX
 
 /*
  * The dictionary is implemented as a red-black tree
  */
 
-typedef enum { dnode_red, dnode_black } dnode_color_t;
+  typedef enum
+  { dnode_red, dnode_black } dnode_color_t;
 
-typedef struct dnode_t {
-    #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
+  typedef struct dnode_t
+  {
+#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
     struct dnode_t *dict_left;
     struct dnode_t *dict_right;
     struct dnode_t *dict_parent;
     dnode_color_t dict_color;
     const void *dict_key;
     void *dict_data;
-    #else
+#else
     int dict_dummy;
-    #endif
-} dnode_t;
+#endif
+  } dnode_t;
 
-typedef int (*dict_comp_t)(const void *, const void *);
-typedef dnode_t *(*dnode_alloc_t)(void *);
-typedef void (*dnode_free_t)(dnode_t *, void *);
+  typedef int (*dict_comp_t) (const void *, const void *);
+  typedef dnode_t *(*dnode_alloc_t) (void *);
+  typedef void (*dnode_free_t) (dnode_t *, void *);
 
-typedef struct dict_t {
-    #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
+  typedef struct dict_t
+  {
+#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
     dnode_t dict_nilnode;
     dictcount_t dict_nodecount;
     dictcount_t dict_maxcount;
@@ -70,59 +74,61 @@ typedef struct dict_t {
     dnode_free_t dict_freenode;
     void *dict_context;
     int dict_dupes;
-    #else
+#else
     int dict_dummmy;
-    #endif
-} dict_t;
+#endif
+  } dict_t;
 
-typedef void (*dnode_process_t)(dict_t *, dnode_t *, void *);
+  typedef void (*dnode_process_t) (dict_t *, dnode_t *, void *);
 
-typedef struct dict_load_t {
-    #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
+  typedef struct dict_load_t
+  {
+#if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
     dict_t *dict_dictptr;
     dnode_t dict_nilnode;
-    #else
+#else
     int dict_dummmy;
-    #endif
-} dict_load_t;
-
-extern dict_t *dict_create(dictcount_t, dict_comp_t);
-extern void dict_set_allocator(dict_t *, dnode_alloc_t, dnode_free_t, void *);
-extern void dict_destroy(dict_t *);
-extern void dict_free_nodes(dict_t *);
-extern void dict_free(dict_t *);
-extern dict_t *dict_init(dict_t *, dictcount_t, dict_comp_t);
-extern void dict_init_like(dict_t *, const dict_t *);
-extern int dict_verify(dict_t *);
-extern int dict_similar(const dict_t *, const dict_t *);
-extern dnode_t *dict_lookup(dict_t *, const void *);
-extern dnode_t *dict_lower_bound(dict_t *, const void *);
-extern dnode_t *dict_upper_bound(dict_t *, const void *);
-extern void dict_insert(dict_t *, dnode_t *, const void *);
-extern dnode_t *dict_delete(dict_t *, dnode_t *);
-extern int dict_alloc_insert(dict_t *, const void *, void *);
-extern void dict_delete_free(dict_t *, dnode_t *);
-extern dnode_t *dict_first(dict_t *);
-extern dnode_t *dict_last(dict_t *);
-extern dnode_t *dict_next(dict_t *, dnode_t *);
-extern dnode_t *dict_prev(dict_t *, dnode_t *);
-extern dictcount_t dict_count(dict_t *);
-extern int dict_isempty(dict_t *);
-extern int dict_isfull(dict_t *);
-extern int dict_contains(dict_t *, dnode_t *);
-extern void dict_allow_dupes(dict_t *);
-extern int dnode_is_in_a_dict(dnode_t *);
-extern dnode_t *dnode_create(void *);
-extern dnode_t *dnode_init(dnode_t *, void *);
-extern void dnode_destroy(dnode_t *);
-extern void *dnode_get(dnode_t *);
-extern const void *dnode_getkey(dnode_t *);
-extern void dnode_put(dnode_t *, void *);
-extern void dict_process(dict_t *, void *, dnode_process_t);
-extern void dict_load_begin(dict_load_t *, dict_t *);
-extern void dict_load_next(dict_load_t *, dnode_t *, const void *);
-extern void dict_load_end(dict_load_t *);
-extern void dict_merge(dict_t *, dict_t *);
+#endif
+  } dict_load_t;
+
+  extern dict_t *dict_create (dictcount_t, dict_comp_t);
+  extern void dict_set_allocator (dict_t *, dnode_alloc_t, dnode_free_t,
+				  void *);
+  extern void dict_destroy (dict_t *);
+  extern void dict_free_nodes (dict_t *);
+  extern void dict_free (dict_t *);
+  extern dict_t *dict_init (dict_t *, dictcount_t, dict_comp_t);
+  extern void dict_init_like (dict_t *, const dict_t *);
+  extern int dict_verify (dict_t *);
+  extern int dict_similar (const dict_t *, const dict_t *);
+  extern dnode_t *dict_lookup (dict_t *, const void *);
+  extern dnode_t *dict_lower_bound (dict_t *, const void *);
+  extern dnode_t *dict_upper_bound (dict_t *, const void *);
+  extern void dict_insert (dict_t *, dnode_t *, const void *);
+  extern dnode_t *dict_delete (dict_t *, dnode_t *);
+  extern int dict_alloc_insert (dict_t *, const void *, void *);
+  extern void dict_delete_free (dict_t *, dnode_t *);
+  extern dnode_t *dict_first (dict_t *);
+  extern dnode_t *dict_last (dict_t *);
+  extern dnode_t *dict_next (dict_t *, dnode_t *);
+  extern dnode_t *dict_prev (dict_t *, dnode_t *);
+  extern dictcount_t dict_count (dict_t *);
+  extern int dict_isempty (dict_t *);
+  extern int dict_isfull (dict_t *);
+  extern int dict_contains (dict_t *, dnode_t *);
+  extern void dict_allow_dupes (dict_t *);
+  extern int dnode_is_in_a_dict (dnode_t *);
+  extern dnode_t *dnode_create (void *);
+  extern dnode_t *dnode_init (dnode_t *, void *);
+  extern void dnode_destroy (dnode_t *);
+  extern void *dnode_get (dnode_t *);
+  extern const void *dnode_getkey (dnode_t *);
+  extern void dnode_put (dnode_t *, void *);
+  extern void dict_process (dict_t *, void *, dnode_process_t);
+  extern void dict_load_begin (dict_load_t *, dict_t *);
+  extern void dict_load_next (dict_load_t *, dnode_t *, const void *);
+  extern void dict_load_end (dict_load_t *);
+  extern void dict_merge (dict_t *, dict_t *);
 
 #if defined(DICT_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
 #ifdef KAZLIB_SIDEEFFECT_DEBUG

+ 284 - 268
isisd/isis_adjacency.c

@@ -47,172 +47,180 @@
 #include "isisd/isis_dynhn.h"
 #include "isisd/isis_pdu.h"
 
-
 extern struct isis *isis;
 
-
 struct isis_adjacency *
-adj_alloc (u_char *id)
+adj_alloc (u_char * id)
 {
-    struct isis_adjacency *adj;
+  struct isis_adjacency *adj;
 
-    adj = XMALLOC (MTYPE_ISIS_ADJACENCY, sizeof (struct isis_adjacency));
-    memset (adj, 0, sizeof (struct isis_adjacency));
-    memcpy (adj->sysid, id, ISIS_SYS_ID_LEN);
-    
-    return adj;
+  adj = XMALLOC (MTYPE_ISIS_ADJACENCY, sizeof (struct isis_adjacency));
+  memset (adj, 0, sizeof (struct isis_adjacency));
+  memcpy (adj->sysid, id, ISIS_SYS_ID_LEN);
+
+  return adj;
 }
 
 struct isis_adjacency *
-isis_new_adj (u_char *id, u_char *snpa, int level, 
+isis_new_adj (u_char * id, u_char * snpa, int level,
 	      struct isis_circuit *circuit)
 {
-
   struct isis_adjacency *adj;
-  int i;  
+  int i;
+
+  adj = adj_alloc (id);		/* P2P kludge */
 
-  adj = adj_alloc (id); /* P2P kludge */
-  
-  if (adj == NULL){
-    zlog_err ("Out of memory!");
-    return NULL;
-  }
+  if (adj == NULL)
+    {
+      zlog_err ("Out of memory!");
+      return NULL;
+    }
 
   memcpy (adj->snpa, snpa, 6);
   adj->circuit = circuit;
   adj->level = level;
   adj->flaps = 0;
   adj->last_flap = time (NULL);
-  if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
-    listnode_add (circuit->u.bc.adjdb[level-1], adj);
-    adj->dischanges[level - 1] = 0;
-    for (i = 0; i < DIS_RECORDS; i++) /* clear N DIS state change records */
+  if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+    {
+      listnode_add (circuit->u.bc.adjdb[level - 1], adj);
+      adj->dischanges[level - 1] = 0;
+      for (i = 0; i < DIS_RECORDS; i++)	/* clear N DIS state change records */
 	{
-	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].dis 
+	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].dis
 	    = ISIS_UNKNOWN_DIS;
-	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].last_dis_change 
-            = time (NULL);
+	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].last_dis_change
+	    = time (NULL);
 	}
-  }
+    }
 
   return adj;
 }
 
 struct isis_adjacency *
-isis_adj_lookup (u_char *sysid,  struct list *adjdb)
+isis_adj_lookup (u_char * sysid, struct list *adjdb)
 {
   struct isis_adjacency *adj;
   struct listnode *node;
 
-  for (node = listhead (adjdb); node; nextnode (node)) {
-    adj = getdata (node);
-    if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0)
-      return adj;
-  }
-  
+  for (node = listhead (adjdb); node; nextnode (node))
+    {
+      adj = getdata (node);
+      if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0)
+	return adj;
+    }
+
   return NULL;
 }
 
 
 struct isis_adjacency *
-isis_adj_lookup_snpa (u_char *ssnpa, struct list *adjdb)
+isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb)
 {
   struct listnode *node;
   struct isis_adjacency *adj;
 
-  for (node = listhead (adjdb); node; nextnode (node)) {
-    adj = getdata (node);
-    if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0)
-      return adj;
-  }
-  
+  for (node = listhead (adjdb); node; nextnode (node))
+    {
+      adj = getdata (node);
+      if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0)
+	return adj;
+    }
+
   return NULL;
 }
 
 /*
  * When we recieve a NULL list, we will know its p2p
  */
-void 
+void
 isis_delete_adj (struct isis_adjacency *adj, struct list *adjdb)
 {
   struct isis_adjacency *adj2;
   struct listnode *node;
-  
-  if (adjdb) {
-    for (node = listhead (adjdb); node; nextnode (node)) {
-      adj2 = getdata (node);
-      if (adj2 == adj)
-        break;
+
+  if (adjdb)
+    {
+      for (node = listhead (adjdb); node; nextnode (node))
+	{
+	  adj2 = getdata (node);
+	  if (adj2 == adj)
+	    break;
+	}
+      listnode_delete (adjdb, adj);
     }
-    listnode_delete (adjdb, adj);
-  }
-  
+
   if (adj->ipv4_addrs)
     list_delete (adj->ipv4_addrs);
 #ifdef HAVE_IPV6
   if (adj->ipv6_addrs)
     list_delete (adj->ipv6_addrs);
 #endif
-  if (adj) {
-    XFREE (MTYPE_ISIS_ADJACENCY,adj);
-  } else {
-    zlog_info ("tried to delete a non-existent adjacency");
-  }
-  
-  
+  if (adj)
+    {
+      XFREE (MTYPE_ISIS_ADJACENCY, adj);
+    }
+  else
+    {
+      zlog_info ("tried to delete a non-existent adjacency");
+    }
 
   return;
 }
 
-void 
-isis_adj_state_change (struct isis_adjacency *adj, enum isis_adj_state state, 
-                       char *reason)
-
+void
+isis_adj_state_change (struct isis_adjacency *adj, enum isis_adj_state state,
+		       char *reason)
 {
   int old_state;
   int level = adj->level;
   struct isis_circuit *circuit;
-  
+
   old_state = adj->adj_state;
   adj->adj_state = state;
 
   circuit = adj->circuit;
-  
-  if (isis->debugs & DEBUG_ADJ_PACKETS) {
-    zlog_info ("ISIS-Adj (%s): Adjacency state change %d->%d: %s",
-               circuit->area->area_tag,
-               old_state,
-               state, 
-               reason ? reason : "unspecified");
-  }
-
-  if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
-    if (state == ISIS_ADJ_UP)
-      circuit->upadjcount[level-1]++;
-    if (state == ISIS_ADJ_DOWN) {
-      isis_delete_adj (adj, adj->circuit->u.bc.adjdb[level - 1]);
-      circuit->upadjcount[level-1]--;
+
+  if (isis->debugs & DEBUG_ADJ_PACKETS)
+    {
+      zlog_info ("ISIS-Adj (%s): Adjacency state change %d->%d: %s",
+		 circuit->area->area_tag,
+		 old_state, state, reason ? reason : "unspecified");
     }
 
-    list_delete_all_node (circuit->u.bc.lan_neighs[level - 1]);
-    isis_adj_build_neigh_list (circuit->u.bc.adjdb[level - 1],
-                               circuit->u.bc.lan_neighs[level - 1]);
-  } else if (state == ISIS_ADJ_UP) { /* p2p interface */
-    if (adj->sys_type == ISIS_SYSTYPE_UNKNOWN)
-      send_hello (circuit, 1);
-    
-    /* update counter & timers for debugging purposes */
-    adj->last_flap = time(NULL);
-    adj->flaps++;
-
-    /* 7.3.17 - going up on P2P -> send CSNP */
-    /* FIXME: yup, I know its wrong... but i will do it! (for now) */
-    send_csnp (circuit,1);
-    send_csnp (circuit,2);
-  } else if (state == ISIS_ADJ_DOWN) { /* p2p interface */
-    adj->circuit->u.p2p.neighbor = NULL;
-    isis_delete_adj (adj, NULL);
-  }
+  if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+    {
+      if (state == ISIS_ADJ_UP)
+	circuit->upadjcount[level - 1]++;
+      if (state == ISIS_ADJ_DOWN)
+	{
+	  isis_delete_adj (adj, adj->circuit->u.bc.adjdb[level - 1]);
+	  circuit->upadjcount[level - 1]--;
+	}
+
+      list_delete_all_node (circuit->u.bc.lan_neighs[level - 1]);
+      isis_adj_build_neigh_list (circuit->u.bc.adjdb[level - 1],
+				 circuit->u.bc.lan_neighs[level - 1]);
+    }
+  else if (state == ISIS_ADJ_UP)
+    {				/* p2p interface */
+      if (adj->sys_type == ISIS_SYSTYPE_UNKNOWN)
+	send_hello (circuit, 1);
+
+      /* update counter & timers for debugging purposes */
+      adj->last_flap = time (NULL);
+      adj->flaps++;
+
+      /* 7.3.17 - going up on P2P -> send CSNP */
+      /* FIXME: yup, I know its wrong... but i will do it! (for now) */
+      send_csnp (circuit, 1);
+      send_csnp (circuit, 2);
+    }
+  else if (state == ISIS_ADJ_DOWN)
+    {				/* p2p interface */
+      adj->circuit->u.p2p.neighbor = NULL;
+      isis_delete_adj (adj, NULL);
+    }
   return;
 }
 
@@ -223,47 +231,49 @@ isis_adj_print (struct isis_adjacency *adj)
   struct isis_dynhn *dyn;
   struct listnode *node;
   struct in_addr *ipv4_addr;
-#ifdef HAVE_IPV6 
+#ifdef HAVE_IPV6
   struct in6_addr *ipv6_addr;
-  u_char ip6 [INET6_ADDRSTRLEN];
+  u_char ip6[INET6_ADDRSTRLEN];
 #endif /* HAVE_IPV6 */
-  
-  if(!adj)
+
+  if (!adj)
     return;
   dyn = dynhn_find_by_id (adj->sysid);
   if (dyn)
     zlog_info ("%s", dyn->name.name);
-  
+
   zlog_info ("SystemId %20s SNPA %s, level %d\nHolding Time %d",
-             adj->sysid ? sysid_print (adj->sysid) : "unknown" , 
-             snpa_print (adj->snpa),
-             adj->level, adj->hold_time);
-  if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0) {
-    zlog_info ("IPv4 Addresses:");
-    
-    for (node = listhead (adj->ipv4_addrs); node; nextnode (node)) {
-      ipv4_addr = getdata (node);
-      zlog_info ("%s", inet_ntoa(*ipv4_addr));
+	     adj->sysid ? sysid_print (adj->sysid) : "unknown",
+	     snpa_print (adj->snpa), adj->level, adj->hold_time);
+  if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0)
+    {
+      zlog_info ("IPv4 Addresses:");
+
+      for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
+	{
+	  ipv4_addr = getdata (node);
+	  zlog_info ("%s", inet_ntoa (*ipv4_addr));
+	}
     }
-  }
-
-#ifdef HAVE_IPV6  
-  if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0) {
-    zlog_info ("IPv6 Addresses:");
-    for (node = listhead (adj->ipv6_addrs); node; nextnode (node)) {
-      ipv6_addr = getdata (node);
-      inet_ntop (AF_INET6, ipv6_addr, ip6, INET6_ADDRSTRLEN); 
-      zlog_info ("%s", ip6);
+
+#ifdef HAVE_IPV6
+  if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
+    {
+      zlog_info ("IPv6 Addresses:");
+      for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+	{
+	  ipv6_addr = getdata (node);
+	  inet_ntop (AF_INET6, ipv6_addr, ip6, INET6_ADDRSTRLEN);
+	  zlog_info ("%s", ip6);
+	}
     }
-  }
 #endif /* HAVE_IPV6 */
-  zlog_info ("Speaks: %s", nlpid2string(&adj->nlpids));
-  
+  zlog_info ("Speaks: %s", nlpid2string (&adj->nlpids));
 
   return;
 }
 
-int 
+int
 isis_adj_expire (struct thread *thread)
 {
   struct isis_adjacency *adj;
@@ -286,19 +296,20 @@ isis_adj_expire (struct thread *thread)
 const char *
 adj_state2string (int state)
 {
-  
-  switch (state) {
-  case ISIS_ADJ_INITIALIZING:
-    return "Initializing";
-  case ISIS_ADJ_UP:
-    return "Up";
-  case ISIS_ADJ_DOWN:
-    return "Down";
-  default:
-    return "Unknown";
-  }
-  
-  return NULL; /* not reached */
+
+  switch (state)
+    {
+    case ISIS_ADJ_INITIALIZING:
+      return "Initializing";
+    case ISIS_ADJ_UP:
+      return "Up";
+    case ISIS_ADJ_DOWN:
+      return "Down";
+    default:
+      return "Unknown";
+    }
+
+  return NULL;			/* not reached */
 }
 
 /*
@@ -310,7 +321,7 @@ isis_adj_print_vty2 (struct isis_adjacency *adj, struct vty *vty, char detail)
 
 #ifdef HAVE_IPV6
   struct in6_addr *ipv6_addr;
-  u_char ip6 [INET6_ADDRSTRLEN];
+  u_char ip6[INET6_ADDRSTRLEN];
 #endif /* HAVE_IPV6 */
   struct in_addr *ip_addr;
   time_t now;
@@ -321,111 +332,112 @@ isis_adj_print_vty2 (struct isis_adjacency *adj, struct vty *vty, char detail)
   dyn = dynhn_find_by_id (adj->sysid);
   if (dyn)
     vty_out (vty, "  %-20s", dyn->name.name);
-  else if (adj->sysid){
-    vty_out (vty, "  %-20s", sysid_print (adj->sysid));
-  } else {
-    vty_out (vty, "  unknown ");
-  }
-
-  if (detail == ISIS_UI_LEVEL_BRIEF) {
-    if (adj->circuit)
-      vty_out (vty, "%-12s",adj->circuit->interface->name); 
-    else
-      vty_out (vty, "NULL circuit!");
-    vty_out (vty, "%-3u", adj->level); /* level */
-    vty_out (vty, "%-13s", adj_state2string (adj->adj_state));
-    now = time (NULL);
-    if (adj->last_upd)
-      vty_out (vty, "%-9lu", adj->last_upd + adj->hold_time - now);
-    else
-      vty_out (vty, "-        ");
-    vty_out (vty, "%-10s", snpa_print (adj->snpa)); 
-    vty_out (vty, "%s", VTY_NEWLINE);
-  }
-
-  if (detail == ISIS_UI_LEVEL_DETAIL) {
-    level = adj->level;
-    if (adj->circuit)
-      vty_out (vty, "%s    Interface: %s",
-               VTY_NEWLINE,
-               adj->circuit->interface->name); /* interface name */
-    else
-      vty_out (vty, "NULL circuit!%s", VTY_NEWLINE);
-    vty_out (vty, ", Level: %u", adj->level); /* level */
-    vty_out (vty, ", State: %s", adj_state2string (adj->adj_state));
-    now = time (NULL);
-    if (adj->last_upd)
-      vty_out (vty, ", Expires in %s", 
-               time2string (adj->last_upd + adj->hold_time - now));
-    else
-      vty_out (vty, ", Expires in %s", 
-               time2string (adj->hold_time));
-    vty_out (vty, "%s    Adjacency flaps: %u",
-	     VTY_NEWLINE,
-	     adj->flaps);
-    vty_out (vty, ", Last: %s ago", time2string(now - adj->last_flap));
-    vty_out (vty, "%s    Circuit type: %s",
-	     VTY_NEWLINE,
-	     circuit_t2string(adj->circuit_t));
-    vty_out (vty, ", Speaks: %s", nlpid2string(&adj->nlpids));
-    vty_out (vty, "%s    SNPA: %s",
-	     VTY_NEWLINE,
-	     snpa_print (adj->snpa));   
-    dyn = dynhn_find_by_id (adj->lanid);
-    if (dyn)
-      vty_out (vty, ", LAN id: %s.%02x",
-	       dyn->name.name,
-	       adj->lanid[ISIS_SYS_ID_LEN]);
-    else 
-      vty_out (vty, ", LAN id: %s.%02x",
-	       sysid_print (adj->lanid),
-	       adj->lanid[ISIS_SYS_ID_LEN]);
-    
-    vty_out (vty, "%s    Priority: %u",
-	     VTY_NEWLINE,
-	     adj->prio[adj->level-1]);
-
-    vty_out (vty, ", %s, DIS flaps: %u, Last: %s ago%s",
-	     isis_disflag2string(adj->dis_record[ISIS_LEVELS+level-1].dis),
-	     adj->dischanges[level-1],
-	     time2string (now - 
-                   (adj->dis_record[ISIS_LEVELS + level - 1].last_dis_change)),
-	     VTY_NEWLINE);    
-             	
-    if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0) {
-      vty_out (vty, "    IPv4 Addresses:%s", VTY_NEWLINE);
-      for (node = listhead (adj->ipv4_addrs);node; nextnode (node)) {
-        ip_addr = getdata (node);
-        vty_out (vty, "      %s%s", inet_ntoa(*ip_addr), VTY_NEWLINE);
-      }
+  else if (adj->sysid)
+    {
+      vty_out (vty, "  %-20s", sysid_print (adj->sysid));
     }
-#ifdef HAVE_IPV6  
-    if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0) {
-      vty_out (vty, "    IPv6 Addresses:%s", VTY_NEWLINE);
-      for (node = listhead (adj->ipv6_addrs); node; nextnode (node)) {
-        ipv6_addr = getdata (node);
-        inet_ntop (AF_INET6, ipv6_addr, ip6, INET6_ADDRSTRLEN); 
-        vty_out (vty, "      %s%s", ip6, VTY_NEWLINE);
-      }
+  else
+    {
+      vty_out (vty, "  unknown ");
     }
+
+  if (detail == ISIS_UI_LEVEL_BRIEF)
+    {
+      if (adj->circuit)
+	vty_out (vty, "%-12s", adj->circuit->interface->name);
+      else
+	vty_out (vty, "NULL circuit!");
+      vty_out (vty, "%-3u", adj->level);	/* level */
+      vty_out (vty, "%-13s", adj_state2string (adj->adj_state));
+      now = time (NULL);
+      if (adj->last_upd)
+	vty_out (vty, "%-9lu", adj->last_upd + adj->hold_time - now);
+      else
+	vty_out (vty, "-        ");
+      vty_out (vty, "%-10s", snpa_print (adj->snpa));
+      vty_out (vty, "%s", VTY_NEWLINE);
+    }
+
+  if (detail == ISIS_UI_LEVEL_DETAIL)
+    {
+      level = adj->level;
+      if (adj->circuit)
+	vty_out (vty, "%s    Interface: %s", VTY_NEWLINE, adj->circuit->interface->name);	/* interface name */
+      else
+	vty_out (vty, "NULL circuit!%s", VTY_NEWLINE);
+      vty_out (vty, ", Level: %u", adj->level);	/* level */
+      vty_out (vty, ", State: %s", adj_state2string (adj->adj_state));
+      now = time (NULL);
+      if (adj->last_upd)
+	vty_out (vty, ", Expires in %s",
+		 time2string (adj->last_upd + adj->hold_time - now));
+      else
+	vty_out (vty, ", Expires in %s", time2string (adj->hold_time));
+      vty_out (vty, "%s    Adjacency flaps: %u", VTY_NEWLINE, adj->flaps);
+      vty_out (vty, ", Last: %s ago", time2string (now - adj->last_flap));
+      vty_out (vty, "%s    Circuit type: %s",
+	       VTY_NEWLINE, circuit_t2string (adj->circuit_t));
+      vty_out (vty, ", Speaks: %s", nlpid2string (&adj->nlpids));
+      vty_out (vty, "%s    SNPA: %s", VTY_NEWLINE, snpa_print (adj->snpa));
+      dyn = dynhn_find_by_id (adj->lanid);
+      if (dyn)
+	vty_out (vty, ", LAN id: %s.%02x",
+		 dyn->name.name, adj->lanid[ISIS_SYS_ID_LEN]);
+      else
+	vty_out (vty, ", LAN id: %s.%02x",
+		 sysid_print (adj->lanid), adj->lanid[ISIS_SYS_ID_LEN]);
+
+      vty_out (vty, "%s    Priority: %u",
+	       VTY_NEWLINE, adj->prio[adj->level - 1]);
+
+      vty_out (vty, ", %s, DIS flaps: %u, Last: %s ago%s",
+	       isis_disflag2string (adj->dis_record[ISIS_LEVELS + level - 1].
+				    dis), adj->dischanges[level - 1],
+	       time2string (now -
+			    (adj->dis_record[ISIS_LEVELS + level - 1].
+			     last_dis_change)), VTY_NEWLINE);
+
+      if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0)
+	{
+	  vty_out (vty, "    IPv4 Addresses:%s", VTY_NEWLINE);
+	  for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
+	    {
+	      ip_addr = getdata (node);
+	      vty_out (vty, "      %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE);
+	    }
+	}
+#ifdef HAVE_IPV6
+      if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
+	{
+	  vty_out (vty, "    IPv6 Addresses:%s", VTY_NEWLINE);
+	  for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+	    {
+	      ipv6_addr = getdata (node);
+	      inet_ntop (AF_INET6, ipv6_addr, ip6, INET6_ADDRSTRLEN);
+	      vty_out (vty, "      %s%s", ip6, VTY_NEWLINE);
+	    }
+	}
 #endif /* HAVE_IPV6 */
-    vty_out (vty, "%s", VTY_NEWLINE);
-  }
+      vty_out (vty, "%s", VTY_NEWLINE);
+    }
   return;
 }
 
 void
-isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty) {
+isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty)
+{
   isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_BRIEF);
 }
 
 void
-isis_adj_print_vty_detail (struct isis_adjacency *adj, struct vty *vty) {
+isis_adj_print_vty_detail (struct isis_adjacency *adj, struct vty *vty)
+{
   isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_DETAIL);
 }
 
 void
-isis_adj_print_vty_extensive (struct isis_adjacency *adj, struct vty *vty) {
+isis_adj_print_vty_extensive (struct isis_adjacency *adj, struct vty *vty)
+{
   isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_EXTENSIVE);
 }
 
@@ -435,54 +447,56 @@ isis_adj_p2p_print_vty (struct isis_adjacency *adj, struct vty *vty)
   isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_BRIEF);
 }
 
-void 
-isis_adj_p2p_print_vty_detail (struct isis_adjacency *adj, struct vty *vty) 
+void
+isis_adj_p2p_print_vty_detail (struct isis_adjacency *adj, struct vty *vty)
 {
   isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_DETAIL);
 }
 
-void 
+void
 isis_adj_p2p_print_vty_extensive (struct isis_adjacency *adj, struct vty *vty)
 {
   isis_adj_print_vty2 (adj, vty, ISIS_UI_LEVEL_EXTENSIVE);
 }
 
 void
-isis_adjdb_iterate (struct list *adjdb, void (*func)(struct isis_adjacency*, 
-                                                 void *), void *arg)
+isis_adjdb_iterate (struct list *adjdb, void (*func) (struct isis_adjacency *,
+						      void *), void *arg)
 {
   struct listnode *node;
   struct isis_adjacency *adj;
-  for (node = listhead (adjdb); node; nextnode (node)) {
-    adj = getdata (node);
-    (*func)(adj, arg);
-  }
+  for (node = listhead (adjdb); node; nextnode (node))
+    {
+      adj = getdata (node);
+      (*func) (adj, arg);
+    }
 }
 
 void
 isis_adj_build_neigh_list (struct list *adjdb, struct list *list)
-
 {
   struct isis_adjacency *adj;
   struct listnode *node;
-  
-  
-  if (!list) {
-    zlog_warn ("isis_adj_build_neigh_list(): NULL list");
-    return;
-  }
-  
-  for (node = listhead (adjdb); node; nextnode (node)) {
-    adj = getdata (node);
-    if (!adj) {
-      zlog_warn ("isis_adj_build_neigh_list(): NULL adj");
+
+  if (!list)
+    {
+      zlog_warn ("isis_adj_build_neigh_list(): NULL list");
       return;
     }
-  
-    if ((adj->adj_state == ISIS_ADJ_UP || 
-       adj->adj_state == ISIS_ADJ_INITIALIZING))
-      listnode_add (list, adj->snpa);
-  }
+
+  for (node = listhead (adjdb); node; nextnode (node))
+    {
+      adj = getdata (node);
+      if (!adj)
+	{
+	  zlog_warn ("isis_adj_build_neigh_list(): NULL adj");
+	  return;
+	}
+
+      if ((adj->adj_state == ISIS_ADJ_UP ||
+	   adj->adj_state == ISIS_ADJ_INITIALIZING))
+	listnode_add (list, adj->snpa);
+    }
   return;
 }
 
@@ -492,23 +506,25 @@ isis_adj_build_up_list (struct list *adjdb, struct list *list)
   struct isis_adjacency *adj;
   struct listnode *node;
 
-  if (!list) {
-    zlog_warn ("isis_adj_build_up_list(): NULL list");
-    return;
-  }
-
-  for (node = listhead (adjdb); node; nextnode (node)) {
-    adj = getdata (node);
-    
-    if (!adj) {
-      zlog_warn ("isis_adj_build_up_list(): NULL adj");
+  if (!list)
+    {
+      zlog_warn ("isis_adj_build_up_list(): NULL list");
       return;
     }
 
-    if (adj->adj_state == ISIS_ADJ_UP)
-      listnode_add (list, adj);
-  }
-  
+  for (node = listhead (adjdb); node; nextnode (node))
+    {
+      adj = getdata (node);
+
+      if (!adj)
+	{
+	  zlog_warn ("isis_adj_build_up_list(): NULL adj");
+	  return;
+	}
+
+      if (adj->adj_state == ISIS_ADJ_UP)
+	listnode_add (list, adj);
+    }
+
   return;
 }
-

+ 46 - 45
isisd/isis_adjacency.h

@@ -33,7 +33,7 @@ enum isis_adj_usage
   ISIS_ADJ_LEVEL1AND2
 };
 
-enum isis_system_type 
+enum isis_system_type
 {
   ISIS_SYSTYPE_UNKNOWN,
   ISIS_SYSTYPE_ES,
@@ -42,7 +42,7 @@ enum isis_system_type
   ISIS_SYSTYPE_L2_IS
 };
 
-enum isis_adj_state 
+enum isis_adj_state
 {
   ISIS_ADJ_INITIALIZING,
   ISIS_ADJ_UP,
@@ -62,65 +62,66 @@ enum isis_adj_updown_reason
   ISIS_ADJ_REASON_CHECKSUM_FAILED
 };
 
-#define DIS_RECORDS 8 /* keep the last 8 DIS state changes on record */
+#define DIS_RECORDS 8	/* keep the last 8 DIS state changes on record */
 
-struct isis_dis_record {
-  int                              dis; /* is our neighbor the DIS ? */          time_t               last_dis_change; /* timestamp for last dis change */
+struct isis_dis_record
+{
+  int dis;			/* is our neighbor the DIS ? */
+  time_t last_dis_change;	/* timestamp for last dis change */
 };
 
-struct isis_adjacency{
-  u_char snpa[ETH_ALEN];           /* NeighbourSNPAAddress */ 
-  u_char sysid[ISIS_SYS_ID_LEN];   /* neighbourSystemIdentifier */
-  u_char lanid[ISIS_SYS_ID_LEN+1]; /* LAN id on bcast circuits */
-  int dischanges[ISIS_LEVELS];     /* how many DIS changes ?*/ 
+struct isis_adjacency
+{
+  u_char snpa[ETH_ALEN];		/* NeighbourSNPAAddress */
+  u_char sysid[ISIS_SYS_ID_LEN];	/* neighbourSystemIdentifier */
+  u_char lanid[ISIS_SYS_ID_LEN + 1];	/* LAN id on bcast circuits */
+  int dischanges[ISIS_LEVELS];		/* how many DIS changes ? */
   /* an array of N levels for M records */
-  struct isis_dis_record  dis_record[DIS_RECORDS * ISIS_LEVELS]; 
-  enum isis_adj_state adj_state;  /* adjacencyState */
-  enum isis_adj_usage adj_usage;  /* adjacencyUsage */
-  struct list *area_addrs;        /* areaAdressesOfNeighbour */
-  struct nlpids nlpids;           /* protocols spoken ... */
+  struct isis_dis_record dis_record[DIS_RECORDS * ISIS_LEVELS];
+  enum isis_adj_state adj_state;	/* adjacencyState */
+  enum isis_adj_usage adj_usage;	/* adjacencyUsage */
+  struct list *area_addrs;		/* areaAdressesOfNeighbour */
+  struct nlpids nlpids;			/* protocols spoken ... */
   struct list *ipv4_addrs;
 #ifdef HAVE_IPV6
   struct list *ipv6_addrs;
-#endif /* HAVE_IPV6 */
-  u_char prio[ISIS_LEVELS];        /* priorityOfNeighbour for DIS*/
-  int circuit_t;                   /* from hello PDU hdr */
-  int level;                       /* level (1 or 2) */
-  enum  isis_system_type sys_type; /* neighbourSystemType */
-  u_int16_t hold_time;             /* entryRemainingTime */
+#endif				/* HAVE_IPV6 */
+  u_char prio[ISIS_LEVELS];	/* priorityOfNeighbour for DIS */
+  int circuit_t;		/* from hello PDU hdr */
+  int level;			/* level (1 or 2) */
+  enum isis_system_type sys_type;	/* neighbourSystemType */
+  u_int16_t hold_time;		/* entryRemainingTime */
   u_int32_t last_upd;
-  u_int32_t last_flap;             /* last time the adj flapped */
-  int flaps;                       /* number of adjacency flaps  */
-  struct thread *t_expire;         /* expire after hold_time  */
-  struct isis_circuit *circuit;    /* back pointer */     
+  u_int32_t last_flap;		/* last time the adj flapped */
+  int flaps;			/* number of adjacency flaps  */
+  struct thread *t_expire;	/* expire after hold_time  */
+  struct isis_circuit *circuit;	/* back pointer */
 };
 
-
-struct isis_adjacency *isis_adj_lookup (u_char *sysid, struct list *adjdb);
-struct isis_adjacency *isis_adj_lookup_snpa (u_char *ssnpa, 
+struct isis_adjacency *isis_adj_lookup (u_char * sysid, struct list *adjdb);
+struct isis_adjacency *isis_adj_lookup_snpa (u_char * ssnpa,
 					     struct list *adjdb);
-struct isis_adjacency *isis_new_adj (u_char *id, u_char *snpa, int level, 
-                                     struct isis_circuit *circuit); 
-void isis_delete_adj (struct isis_adjacency *adj, struct list *adjdb); 
-void isis_adj_state_change (struct isis_adjacency *adj, 
-                            enum isis_adj_state state, char *reason); 
-void isis_adj_print (struct isis_adjacency *adj); 
-int  isis_adj_expire (struct thread *thread);
+struct isis_adjacency *isis_new_adj (u_char * id, u_char * snpa, int level,
+				     struct isis_circuit *circuit);
+void isis_delete_adj (struct isis_adjacency *adj, struct list *adjdb);
+void isis_adj_state_change (struct isis_adjacency *adj,
+			    enum isis_adj_state state, char *reason);
+void isis_adj_print (struct isis_adjacency *adj);
+int isis_adj_expire (struct thread *thread);
 void isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty);
 void isis_adj_print_vty_detail (struct isis_adjacency *adj, struct vty *vty);
-void isis_adj_print_vty_extensive (struct isis_adjacency *adj, 
-                                   struct vty *vty);
+void isis_adj_print_vty_extensive (struct isis_adjacency *adj,
+				   struct vty *vty);
 void isis_adj_p2p_print_vty (struct isis_adjacency *adj, struct vty *vty);
-void isis_adj_p2p_print_vty_detail (struct isis_adjacency *adj, 
-                                    struct vty *vty);
-void isis_adj_p2p_print_vty_extensive (struct isis_adjacency *adj, 
-                                       struct vty *vty);
+void isis_adj_p2p_print_vty_detail (struct isis_adjacency *adj,
+				    struct vty *vty);
+void isis_adj_p2p_print_vty_extensive (struct isis_adjacency *adj,
+				       struct vty *vty);
 
 void isis_adj_build_neigh_list (struct list *adjdb, struct list *list);
 void isis_adj_build_up_list (struct list *adjdb, struct list *list);
-void isis_adjdb_iterate (struct list *adjdb, 
-                         void (*func)(struct isis_adjacency*, 
-                                      void *), void *arg);
+void isis_adjdb_iterate (struct list *adjdb,
+			 void (*func) (struct isis_adjacency *,
+				       void *), void *arg);
 
 #endif /* ISIS_ADJACENCY_H */
-

File diff suppressed because it is too large
+ 982 - 856
isisd/isis_circuit.c


+ 90 - 85
isisd/isis_circuit.h

@@ -25,134 +25,139 @@
 
 #define CIRCUIT_MAX 255
 
-struct password {
+struct password
+{
   struct password *next;
-  int               len;
-  u_char          *pass;
+  int len;
+  u_char *pass;
 };
 
-struct metric {
+struct metric
+{
   u_char metric_default;
   u_char metric_error;
   u_char metric_expense;
   u_char metric_delay;
 };
 
-struct isis_bcast_info {
-  u_char snpa [ETH_ALEN];                  /* SNPA of this circuit */
-  char run_dr_elect[2];                    /* Should we run dr election ? */
-  struct thread *t_run_dr[2];              /* DR election thread */
-  struct thread *t_send_lan_hello[2];      /* send LAN IIHs in this thread */
-  struct list *adjdb[2];                   /* adjacency dbs */
-  struct list *lan_neighs[2];              /* list of lx neigh snpa */
-  char is_dr[2];                           /* Are we level x DR ? */
-  u_char l1_desig_is[ISIS_SYS_ID_LEN + 1]; /* level-1 DR */
-  u_char l2_desig_is[ISIS_SYS_ID_LEN + 1]; /* level-2 DR */
-  struct thread *t_refresh_pseudo_lsp[2];  /* refresh pseudo-node LSPs */
-  int pad_hellos;                          /* add padding to Hello PDUs ? */
-  u_char priority[2];                      /* l1/2 IS Priority */
+struct isis_bcast_info
+{
+  u_char snpa[ETH_ALEN];	/* SNPA of this circuit */
+  char run_dr_elect[2];		/* Should we run dr election ? */
+  struct thread *t_run_dr[2];	/* DR election thread */
+  struct thread *t_send_lan_hello[2];	/* send LAN IIHs in this thread */
+  struct list *adjdb[2];	/* adjacency dbs */
+  struct list *lan_neighs[2];	/* list of lx neigh snpa */
+  char is_dr[2];		/* Are we level x DR ? */
+  u_char l1_desig_is[ISIS_SYS_ID_LEN + 1];	/* level-1 DR */
+  u_char l2_desig_is[ISIS_SYS_ID_LEN + 1];	/* level-2 DR */
+  struct thread *t_refresh_pseudo_lsp[2];	/* refresh pseudo-node LSPs */
+  int pad_hellos;		/* add padding to Hello PDUs ? */
+  u_char priority[2];		/* l1/2 IS Priority */
 };
 
-struct isis_p2p_info {
-  struct isis_adjacency    *neighbor;
-  struct thread *t_send_p2p_hello;         /* send P2P IIHs in this thread  */
+struct isis_p2p_info
+{
+  struct isis_adjacency *neighbor;
+  struct thread *t_send_p2p_hello;	/* send P2P IIHs in this thread  */
 };
 
-struct isis_circuit {
+struct isis_circuit
+{
   int state;
-  u_char circuit_id;             /* l1/l2 p2p/bcast CircuitID */
-  struct isis_area *area;        /* back pointer to the area */
-  struct interface *interface;   /* interface info from z */
-  int fd;                        /* IS-IS l1/2 socket */
-  struct nlpids nlpids;    
+  u_char circuit_id;		/* l1/l2 p2p/bcast CircuitID */
+  struct isis_area *area;	/* back pointer to the area */
+  struct interface *interface;	/* interface info from z */
+  int fd;			/* IS-IS l1/2 socket */
+  struct nlpids nlpids;
   /*
    * Threads
    */
   struct thread *t_read;
   struct thread *t_send_csnp[2];
   struct thread *t_send_psnp[2];
-  struct list *lsp_queue;        /* LSPs to be txed (both levels) */
+  struct list *lsp_queue;	/* LSPs to be txed (both levels) */
   /* there is no real point in two streams, just for programming kicker */
-  int (* rx) (struct isis_circuit *circuit, u_char *ssnpa);
-  struct stream *rcv_stream;     /* Stream for receiving */
-  int (* tx) (struct isis_circuit *circuit, int level);
-  struct stream *snd_stream;     /* Stream for sending */
-  int idx;                       /* idx in S[RM|SN] flags */
-#define CIRCUIT_T_BROADCAST  0 
+  int (*rx) (struct isis_circuit * circuit, u_char * ssnpa);
+  struct stream *rcv_stream;	/* Stream for receiving */
+  int (*tx) (struct isis_circuit * circuit, int level);
+  struct stream *snd_stream;	/* Stream for sending */
+  int idx;			/* idx in S[RM|SN] flags */
+#define CIRCUIT_T_BROADCAST  0
 #define CIRCUIT_T_P2P        1
 #define CIRCUIT_T_STATIC_IN  2
 #define CIRCUIT_T_STATIC_OUT 3
 #define CIRCUIT_T_DA         4
-  int        circ_type;          /* type of the physical interface */
-  union {
+  int circ_type;		/* type of the physical interface */
+  union
+  {
     struct isis_bcast_info bc;
     struct isis_p2p_info p2p;
   } u;
-  char ext_domain;               /* externalDomain   (boolean) */
+  char ext_domain;		/* externalDomain   (boolean) */
   /* 
    * Configurables 
    */
-  struct isis_passwd passwd;      /* Circuit rx/tx password */
-  long lsp_interval;            
-  int manual_l2_only;             /* manualL2OnlyMode (boolean) */
-  int circuit_is_type;            /* circuit is type == level of circuit
-                                   * diffrenciated from circuit type (media) */
-  u_int32_t hello_interval[2];    /* l1HelloInterval in msecs */
-  u_int16_t hello_multiplier[2];  /* l1HelloMultiplier */
-  u_int16_t csnp_interval[2];     /* level-1 csnp-interval in seconds */
-  u_int16_t psnp_interval[2];     /* level-1 psnp-interval in seconds */
-  struct metric metrics[2];       /* l1XxxMetric */
-  struct password *c_rx_passwds;  /* circuitReceivePasswords */
-  struct password *c_tc_passwd;   /* circuitTransmitPassword */
-  int ip_router;                  /* Route IP ? */
-  struct list *ip_addrs;          /* our IP addresses */
+  struct isis_passwd passwd;	/* Circuit rx/tx password */
+  long lsp_interval;
+  int manual_l2_only;		/* manualL2OnlyMode (boolean) */
+  int circuit_is_type;		/* circuit is type == level of circuit
+				 * diffrenciated from circuit type (media) */
+  u_int32_t hello_interval[2];	/* l1HelloInterval in msecs */
+  u_int16_t hello_multiplier[2];	/* l1HelloMultiplier */
+  u_int16_t csnp_interval[2];	/* level-1 csnp-interval in seconds */
+  u_int16_t psnp_interval[2];	/* level-1 psnp-interval in seconds */
+  struct metric metrics[2];	/* l1XxxMetric */
+  struct password *c_rx_passwds;	/* circuitReceivePasswords */
+  struct password *c_tc_passwd;	/* circuitTransmitPassword */
+  int ip_router;		/* Route IP ? */
+  struct list *ip_addrs;	/* our IP addresses */
 #ifdef HAVE_IPV6
-  int ipv6_router;                /* Route IPv6 ? */
-  struct list *ipv6_link;         /* our link local IPv6 addresses */
-  struct list *ipv6_non_link;     /* our non-link local IPv6 addresses */
-#endif /* HAVE_IPV6 */
+  int ipv6_router;		/* Route IPv6 ? */
+  struct list *ipv6_link;	/* our link local IPv6 addresses */
+  struct list *ipv6_non_link;	/* our non-link local IPv6 addresses */
+#endif				/* HAVE_IPV6 */
   /* 
    * RFC 2973 IS-IS Mesh Groups 
    */
 #define MESH_INACTIVE 0
 #define MESH_BLOCKED  1
 #define MESH_SET      2
-  int mesh_enabled;               /* meshGroupEnabled */
-  u_int16_t mesh_group;           /* meshGroup */
+  int mesh_enabled;		/* meshGroupEnabled */
+  u_int16_t mesh_group;		/* meshGroup */
   u_int16_t upadjcount[2];
   /*
    * Counters as in 10589--11.2.5.9
    */
-  u_int32_t adj_state_changes;    /* changesInAdjacencyState */
-  u_int32_t init_failures;        /* intialisationFailures */
-  u_int32_t ctrl_pdus_rxed;       /* controlPDUsReceived */
-  u_int32_t ctrl_pdus_txed;       /* controlPDUsSent */
-  u_int32_t desig_changes[2];     /* lanLxDesignatedIntermediateSystemChanges*/
-  u_int32_t rej_adjacencies;      /* rejectedAdjacencies */
+  u_int32_t adj_state_changes;	/* changesInAdjacencyState */
+  u_int32_t init_failures;	/* intialisationFailures */
+  u_int32_t ctrl_pdus_rxed;	/* controlPDUsReceived */
+  u_int32_t ctrl_pdus_txed;	/* controlPDUsSent */
+  u_int32_t desig_changes[2];	/* lanLxDesignatedIntermediateSystemChanges */
+  u_int32_t rej_adjacencies;	/* rejectedAdjacencies */
 };
 
+void isis_circuit_init (void);
+struct isis_circuit *isis_circuit_new (void);
+struct isis_circuit *circuit_lookup_by_ifp (struct interface *ifp,
+					    struct list *list);
+struct isis_circuit *circuit_scan_by_ifp (struct interface *ifp);
+void isis_circuit_del (struct isis_circuit *circuit);
+void isis_circuit_configure (struct isis_circuit *circuit,
+			     struct isis_area *area);
+void isis_circuit_up (struct isis_circuit *circuit);
+void isis_circuit_deconfigure (struct isis_circuit *circuit,
+			       struct isis_area *area);
 
-void                 isis_circuit_init        (void);
-struct isis_circuit *isis_circuit_new         (void);
-struct isis_circuit *circuit_lookup_by_ifp    (struct interface *ifp, 
-                                               struct list *list);
-struct isis_circuit *circuit_scan_by_ifp      (struct interface *ifp);
-void                 isis_circuit_del         (struct isis_circuit *circuit);
-void                 isis_circuit_configure   (struct isis_circuit *circuit, 
-                                               struct isis_area *area);
-void                 isis_circuit_up          (struct isis_circuit *circuit);
-void                 isis_circuit_deconfigure (struct isis_circuit *circuit, 
-                                               struct isis_area *area);
-
-int                  isis_circuit_destroy     (struct isis_circuit *circuit);
-void                 isis_circuit_if_add      (struct isis_circuit *circuit,
-                                               struct interface *ifp);
-void                 isis_circuit_if_del      (struct isis_circuit *circuit);
-void                 circuit_update_nlpids    (struct isis_circuit *circuit);
-void                 isis_circuit_update_params (struct isis_circuit *circuit,
-                                                 struct interface *ifp);
-void                 isis_circuit_add_addr (struct isis_circuit *circuit, 
-                                            struct connected *conn);
-void                 isis_circuit_del_addr (struct isis_circuit *circuit, 
-                                            struct connected *conn);
+int isis_circuit_destroy (struct isis_circuit *circuit);
+void isis_circuit_if_add (struct isis_circuit *circuit,
+			  struct interface *ifp);
+void isis_circuit_if_del (struct isis_circuit *circuit);
+void circuit_update_nlpids (struct isis_circuit *circuit);
+void isis_circuit_update_params (struct isis_circuit *circuit,
+				 struct interface *ifp);
+void isis_circuit_add_addr (struct isis_circuit *circuit,
+			    struct connected *conn);
+void isis_circuit_del_addr (struct isis_circuit *circuit,
+			    struct connected *conn);
 #endif /* _ZEBRA_ISIS_CIRCUIT_H */

+ 15 - 10
isisd/isis_common.h

@@ -23,13 +23,15 @@
 
 /*
  * Area Address
- */ 
-struct area_addr {
-  u_char             addr_len;
-  u_char             area_addr[20];
+ */
+struct area_addr
+{
+  u_char addr_len;
+  u_char area_addr[20];
 };
 
-struct isis_passwd {
+struct isis_passwd
+{
   u_char len;
 #define ISIS_PASSWD_TYPE_UNUSED   0
 #define ISIS_PASSWD_TYPE_CLEARTXT 1
@@ -43,7 +45,8 @@ struct isis_passwd {
  * one struct for cache list
  * one struct for LSP TLV
  */
-struct hostname {
+struct hostname
+{
   u_char namelen;
   u_char name[255];
 };
@@ -51,15 +54,17 @@ struct hostname {
 /*
  * Supported Protocol IDs
  */
-struct nlpids {
+struct nlpids
+{
   u_char count;
-  u_char nlpids[4]; /* FIXME: enough ? */ 
+  u_char nlpids[4];		/* FIXME: enough ? */
 };
 
 /*
  * Flags structure for SSN and SRM flags
- */ 
-struct flags {
+ */
+struct flags
+{
   int maxindex;
   struct list *free_idcs;
 };

+ 12 - 20
isisd/isis_constants.h

@@ -25,9 +25,9 @@
 
 /*
  * Architectural constant values from p. 35 of ISO/IEC 10589
- */ 
+ */
 
-#define MAX_LINK_METRIC               63 
+#define MAX_LINK_METRIC               63
 #define MAX_PATH_METRIC               1023
 #define ISO_SAP                       0xFE
 #define INTRADOMAIN_ROUTEING_SELECTOR 0
@@ -38,11 +38,11 @@
  * implementation specific jitter values
  */
 
-#define IIH_JITTER                    25  /* % */
-#define MAX_AGE_JITTER                 5  /* % */
-#define MAX_LSP_GEN_JITTER             5  /* % */
-#define CSNP_JITTER                   10  /* % */
-#define PSNP_JITTER                   10  /* % */
+#define IIH_JITTER                    25	/* % */
+#define MAX_AGE_JITTER                 5	/* % */
+#define MAX_LSP_GEN_JITTER             5	/* % */
+#define CSNP_JITTER                   10	/* % */
+#define PSNP_JITTER                   10	/* % */
 
 #define RANDOM_SPREAD           100000.0
 
@@ -70,12 +70,12 @@
 #define HELLO_MULTIPLIER              3
 #define DEFAULT_PRIORITY              64
 /* different vendors implement different values 5-10 on average */
-#define LSP_GEN_INTERVAL_DEFAULT      10 
-#define LSP_INTERVAL                  33  /* msecs */
+#define LSP_GEN_INTERVAL_DEFAULT      10
+#define LSP_INTERVAL                  33	/* msecs */
 #define DEFAULT_CIRCUIT_METRICS 10
 #define METRICS_UNSUPPORTED 0x80
-#define PERIODIC_SPF_INTERVAL         60 /* at the top of my head */
-#define MINIMUM_SPF_INTERVAL           5 /* .. same here          */ 
+#define PERIODIC_SPF_INTERVAL         60	/* at the top of my head */
+#define MINIMUM_SPF_INTERVAL           5	/* .. same here          */
 
 /*
  * NLPID values
@@ -143,12 +143,4 @@
 #define ETH_ALEN 6
 #endif
 
-#endif  /* ISIS_CONSTANTS_H */
-
-
-
-
-
-
-
-
+#endif /* ISIS_CONSTANTS_H */

+ 100 - 102
isisd/isis_csm.c

@@ -52,8 +52,7 @@
 
 extern struct isis *isis;
 
-static char *csm_statestr[] = 
-{
+static char *csm_statestr[] = {
   "C_STATE_NA",
   "C_STATE_INIT",
   "C_STATE_CONF",
@@ -62,8 +61,7 @@ static char *csm_statestr[] =
 
 #define STATE2STR(S) csm_statestr[S]
 
-static char *csm_eventstr[] =
-{
+static char *csm_eventstr[] = {
   "NO_STATE",
   "ISIS_ENABLE",
   "IF_UP_FROM_Z",
@@ -73,113 +71,113 @@ static char *csm_eventstr[] =
 
 #define EVENT2STR(E) csm_eventstr[E]
 
-
-struct isis_circuit*
-isis_csm_state_change (int event, struct isis_circuit *circuit, 
-                       void *arg)
+struct isis_circuit *
+isis_csm_state_change (int event, struct isis_circuit *circuit, void *arg)
 {
   int old_state;
 
   old_state = circuit ? circuit->state : C_STATE_NA;
-  
-  zlog_info ("CSM_EVENT: %s", EVENT2STR(event));
-  
-  switch (old_state) {
-  case C_STATE_NA:
-    if (circuit)
-      zlog_warn ("Non-null circuit while state C_STATE_NA");
-    switch (event) {
-    case ISIS_ENABLE:
-      circuit = isis_circuit_new ();
-      isis_circuit_configure (circuit, (struct isis_area *)arg);
-      circuit->state = C_STATE_CONF;
-      break;
-    case IF_UP_FROM_Z:
-      circuit = isis_circuit_new ();
-      isis_circuit_if_add (circuit, (struct interface *)arg);
-      listnode_add (isis->init_circ_list, circuit);
-      circuit->state = C_STATE_INIT;
-      break;
-    case ISIS_DISABLE:
-      zlog_warn ("circuit already disabled");
-    case IF_DOWN_FROM_Z:
-      zlog_warn ("circuit already disconnected");
-      break;
-    }
-    break;
-  case C_STATE_INIT:
-    switch (event) {
-    case ISIS_ENABLE:
-      isis_circuit_configure (circuit, (struct isis_area *)arg);
-      isis_circuit_up (circuit);
-      circuit->state = C_STATE_UP;
-      isis_event_circuit_state_change (circuit, 1);
-      listnode_delete (isis->init_circ_list, circuit);
-      break;
-    case IF_UP_FROM_Z:
-      zlog_warn ("circuit already connected");
-      break;
-    case ISIS_DISABLE:
-      zlog_warn ("circuit already disabled");
-      break;
-    case IF_DOWN_FROM_Z:
-      isis_circuit_if_del (circuit);
-      listnode_delete (isis->init_circ_list, circuit);
-      isis_circuit_del (circuit);
-      break;
-    }
-    break;
-  case C_STATE_CONF:
-    switch (event) {
-    case ISIS_ENABLE:
-      zlog_warn ("circuit already enabled");
-      break;
-    case IF_UP_FROM_Z:
-      isis_circuit_if_add (circuit, (struct interface *)arg);
-      isis_circuit_up (circuit);
-      circuit->state = C_STATE_UP;
-      isis_event_circuit_state_change (circuit, 1);
-      break;
-    case ISIS_DISABLE:
-      isis_circuit_deconfigure (circuit, (struct isis_area *)arg);
-      isis_circuit_del (circuit);
-      break;
-    case IF_DOWN_FROM_Z:
-      zlog_warn ("circuit already disconnected");
-      break;
-    }
-    break;
-  case C_STATE_UP:
-    switch (event) {
-    case ISIS_ENABLE:
-      zlog_warn ("circuit already configured");
+
+  zlog_info ("CSM_EVENT: %s", EVENT2STR (event));
+
+  switch (old_state)
+    {
+    case C_STATE_NA:
+      if (circuit)
+	zlog_warn ("Non-null circuit while state C_STATE_NA");
+      switch (event)
+	{
+	case ISIS_ENABLE:
+	  circuit = isis_circuit_new ();
+	  isis_circuit_configure (circuit, (struct isis_area *) arg);
+	  circuit->state = C_STATE_CONF;
+	  break;
+	case IF_UP_FROM_Z:
+	  circuit = isis_circuit_new ();
+	  isis_circuit_if_add (circuit, (struct interface *) arg);
+	  listnode_add (isis->init_circ_list, circuit);
+	  circuit->state = C_STATE_INIT;
+	  break;
+	case ISIS_DISABLE:
+	  zlog_warn ("circuit already disabled");
+	case IF_DOWN_FROM_Z:
+	  zlog_warn ("circuit already disconnected");
+	  break;
+	}
       break;
-    case IF_UP_FROM_Z:
-      zlog_warn ("circuit already connected");
+    case C_STATE_INIT:
+      switch (event)
+	{
+	case ISIS_ENABLE:
+	  isis_circuit_configure (circuit, (struct isis_area *) arg);
+	  isis_circuit_up (circuit);
+	  circuit->state = C_STATE_UP;
+	  isis_event_circuit_state_change (circuit, 1);
+	  listnode_delete (isis->init_circ_list, circuit);
+	  break;
+	case IF_UP_FROM_Z:
+	  zlog_warn ("circuit already connected");
+	  break;
+	case ISIS_DISABLE:
+	  zlog_warn ("circuit already disabled");
+	  break;
+	case IF_DOWN_FROM_Z:
+	  isis_circuit_if_del (circuit);
+	  listnode_delete (isis->init_circ_list, circuit);
+	  isis_circuit_del (circuit);
+	  break;
+	}
       break;
-    case ISIS_DISABLE:
-      isis_circuit_deconfigure (circuit, (struct isis_area *)arg);
-      listnode_add (isis->init_circ_list, circuit);
-      circuit->state = C_STATE_INIT;
-      isis_event_circuit_state_change (circuit, 0);
+    case C_STATE_CONF:
+      switch (event)
+	{
+	case ISIS_ENABLE:
+	  zlog_warn ("circuit already enabled");
+	  break;
+	case IF_UP_FROM_Z:
+	  isis_circuit_if_add (circuit, (struct interface *) arg);
+	  isis_circuit_up (circuit);
+	  circuit->state = C_STATE_UP;
+	  isis_event_circuit_state_change (circuit, 1);
+	  break;
+	case ISIS_DISABLE:
+	  isis_circuit_deconfigure (circuit, (struct isis_area *) arg);
+	  isis_circuit_del (circuit);
+	  break;
+	case IF_DOWN_FROM_Z:
+	  zlog_warn ("circuit already disconnected");
+	  break;
+	}
       break;
-    case IF_DOWN_FROM_Z:
-      isis_circuit_if_del (circuit);
-      circuit->state = C_STATE_CONF;
-      isis_event_circuit_state_change (circuit, 0);
+    case C_STATE_UP:
+      switch (event)
+	{
+	case ISIS_ENABLE:
+	  zlog_warn ("circuit already configured");
+	  break;
+	case IF_UP_FROM_Z:
+	  zlog_warn ("circuit already connected");
+	  break;
+	case ISIS_DISABLE:
+	  isis_circuit_deconfigure (circuit, (struct isis_area *) arg);
+	  listnode_add (isis->init_circ_list, circuit);
+	  circuit->state = C_STATE_INIT;
+	  isis_event_circuit_state_change (circuit, 0);
+	  break;
+	case IF_DOWN_FROM_Z:
+	  isis_circuit_if_del (circuit);
+	  circuit->state = C_STATE_CONF;
+	  isis_event_circuit_state_change (circuit, 0);
+	  break;
+	}
       break;
+
+    default:
+      zlog_warn ("Invalid circuit state %d", old_state);
     }
-    break;
-    
-  default:
-    zlog_warn ("Invalid circuit state %d", old_state);
-  }
-  
-  zlog_info ("CSM_STATE_CHANGE: %s -> %s ", STATE2STR (old_state), 
-             circuit ? STATE2STR (circuit->state) : STATE2STR (C_STATE_NA));
+
+  zlog_info ("CSM_STATE_CHANGE: %s -> %s ", STATE2STR (old_state),
+	     circuit ? STATE2STR (circuit->state) : STATE2STR (C_STATE_NA));
 
   return circuit;
 }
-
-
-

+ 6 - 6
isisd/isis_csm.h

@@ -28,9 +28,9 @@
  * Circuit states
  */
 #define C_STATE_NA   0
-#define C_STATE_INIT 1 /* Connected to interface */
-#define C_STATE_CONF 2 /* Configured for ISIS    */
-#define C_STATE_UP   3 /* CONN | CONF            */ 
+#define C_STATE_INIT 1		/* Connected to interface */
+#define C_STATE_CONF 2		/* Configured for ISIS    */
+#define C_STATE_UP   3		/* CONN | CONF            */
 
 /*
  * Circuit events
@@ -40,8 +40,8 @@
 #define ISIS_DISABLE   3
 #define IF_DOWN_FROM_Z 4
 
-struct isis_circuit *isis_csm_state_change (int event, 
-                                            struct isis_circuit *circuit, 
-                                            void *arg);
+struct isis_circuit *isis_csm_state_change (int event,
+					    struct isis_circuit *circuit,
+					    void *arg);
 
 #endif /* _ZEBRA_ISIS_CSM_H */

+ 209 - 179
isisd/isis_dr.c

@@ -51,37 +51,37 @@ extern struct isis *isis;
 extern struct thread_master *master;
 
 char *
-isis_disflag2string (int disflag) {
+isis_disflag2string (int disflag)
+{
 
-  switch (disflag) {
+  switch (disflag)
+    {
     case ISIS_IS_NOT_DIS:
       return "is not DIS";
     case ISIS_IS_DIS:
       return "is DIS";
     case ISIS_WAS_DIS:
       return "was DIS";
-  default:
-    return "unknown DIS state";
-  }
-  return NULL; /* not reached */
+    default:
+      return "unknown DIS state";
+    }
+  return NULL;			/* not reached */
 }
 
-
-
 int
 isis_run_dr_l1 (struct thread *thread)
 {
   struct isis_circuit *circuit;
-  
+
   circuit = THREAD_ARG (thread);
   assert (circuit);
 
   if (circuit->u.bc.run_dr_elect[0])
     zlog_warn ("isis_run_dr(): run_dr_elect already set for l1");
-  
+
   circuit->u.bc.t_run_dr[0] = NULL;
   circuit->u.bc.run_dr_elect[0] = 1;
-    
+
   return ISIS_OK;
 }
 
@@ -89,17 +89,17 @@ int
 isis_run_dr_l2 (struct thread *thread)
 {
   struct isis_circuit *circuit;
-  
+
   circuit = THREAD_ARG (thread);
   assert (circuit);
 
   if (circuit->u.bc.run_dr_elect[1])
     zlog_warn ("isis_run_dr(): run_dr_elect already set for l2");
-  
-  
-  circuit->u.bc.t_run_dr[1] = NULL; 
+
+
+  circuit->u.bc.t_run_dr[1] = NULL;
   circuit->u.bc.run_dr_elect[1] = 1;
-    
+
   return ISIS_OK;
 }
 
@@ -108,24 +108,25 @@ isis_check_dr_change (struct isis_adjacency *adj, int level)
 {
   int i;
 
-  if ( adj->dis_record[level-1].dis != 
-       adj->dis_record[(1*ISIS_LEVELS) + level - 1].dis) 
-    /* was there a DIS state transition ? */ 
+  if (adj->dis_record[level - 1].dis !=
+      adj->dis_record[(1 * ISIS_LEVELS) + level - 1].dis)
+    /* was there a DIS state transition ? */
     {
-      adj->dischanges[level-1]++;
+      adj->dischanges[level - 1]++;
       /* ok rotate the history list through */
-      for (i = DIS_RECORDS - 1; i > 0; i--) 
+      for (i = DIS_RECORDS - 1; i > 0; i--)
 	{
-	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].dis = 
-            adj->dis_record[((i-1) * ISIS_LEVELS) + level - 1].dis;
-	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].last_dis_change = 
-            adj->dis_record[((i-1) * ISIS_LEVELS) + level - 1].last_dis_change;
+	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].dis =
+	    adj->dis_record[((i - 1) * ISIS_LEVELS) + level - 1].dis;
+	  adj->dis_record[(i * ISIS_LEVELS) + level - 1].last_dis_change =
+	    adj->dis_record[((i - 1) * ISIS_LEVELS) + level -
+			    1].last_dis_change;
 	}
     }
   return ISIS_OK;
 }
 
-int 
+int
 isis_dr_elect (struct isis_circuit *circuit, int level)
 {
   struct list *adjdb;
@@ -135,213 +136,242 @@ isis_dr_elect (struct isis_circuit *circuit, int level)
   u_char own_prio;
   int biggest_prio = -1;
   int cmp_res, retval = ISIS_OK;
-  
+
   own_prio = circuit->u.bc.priority[level - 1];
   adjdb = circuit->u.bc.adjdb[level - 1];
 
-  if (!adjdb) {
-    zlog_warn ("isis_dr_elect() adjdb == NULL");
-    retval = ISIS_WARNING;
-    list_delete (list);
-    goto out;
-  }
+  if (!adjdb)
+    {
+      zlog_warn ("isis_dr_elect() adjdb == NULL");
+      retval = ISIS_WARNING;
+      list_delete (list);
+      goto out;
+    }
   isis_adj_build_up_list (adjdb, list);
 
   /*
    * Loop the adjacencies and find the one with the biggest priority
    */
-  for (node = listhead (list); node; nextnode (node)) {
-    adj = getdata (node);
-    /* clear flag for show output */
-    adj->dis_record[level-1].dis = ISIS_IS_NOT_DIS;  
-    adj->dis_record[level-1].last_dis_change = time (NULL);
-
-    if (adj->prio[level-1] > biggest_prio) {
-      biggest_prio = adj->prio[level-1];
-      adj_dr = adj;
-    } else if (adj->prio[level-1] == biggest_prio) {
+  for (node = listhead (list); node; nextnode (node))
+    {
+      adj = getdata (node);
+      /* clear flag for show output */
+      adj->dis_record[level - 1].dis = ISIS_IS_NOT_DIS;
+      adj->dis_record[level - 1].last_dis_change = time (NULL);
+
+      if (adj->prio[level - 1] > biggest_prio)
+	{
+	  biggest_prio = adj->prio[level - 1];
+	  adj_dr = adj;
+	}
+      else if (adj->prio[level - 1] == biggest_prio)
+	{
+	  /*
+	   * Comparison of MACs breaks a tie
+	   */
+	  if (adj_dr)
+	    {
+	      cmp_res = memcmp (adj_dr->snpa, adj->snpa, ETH_ALEN);
+	      if (cmp_res < 0)
+		{
+		  adj_dr = adj;
+		}
+	      if (cmp_res == 0)
+		zlog_warn
+		  ("isis_dr_elect(): multiple adjacencies with same SNPA");
+	    }
+	  else
+	    {
+	      adj_dr = adj;
+	    }
+	}
+    }
+
+  if (!adj_dr)
+    {
       /*
-       * Comparison of MACs breaks a tie
+       * Could not find the DR - means we are alone and thus the DR
        */
-      if (adj_dr) {
-        cmp_res = memcmp (adj_dr->snpa, adj->snpa, ETH_ALEN);
-        if (cmp_res < 0) {
-          adj_dr = adj;
+      if (!circuit->u.bc.is_dr[level - 1])
+	{
+	  list_delete (list);
+	  list = NULL;
+	  return isis_dr_commence (circuit, level);
 	}
-        if (cmp_res == 0)
-          zlog_warn ("isis_dr_elect(): multiple adjacencies with same SNPA"); 
-      } else {
-        adj_dr = adj;
-      }
-    }
-  }
-  
-  if (!adj_dr) {
-    /*
-     * Could not find the DR - means we are alone and thus the DR
-     */
-    if ( !circuit->u.bc.is_dr[level - 1]) {
-      list_delete (list);
-      list = NULL;
-      return isis_dr_commence (circuit, level);
+      goto out;
     }
-    goto out;
-  }
 
   /*
    * Now we have the DR adjacency, compare it to self
    */
-  if (adj_dr->prio[level-1] < own_prio || (adj_dr->prio[level-1] == own_prio &&
-                                  memcmp (adj_dr->snpa, circuit->u.bc.snpa, 
-                                          ETH_ALEN) < 0)) {
-    if (!circuit->u.bc.is_dr[level - 1]) {
-      /*
-       * We are the DR -> commence
-       */
-      list_delete (list);
-      return isis_dr_commence (circuit, level);
+  if (adj_dr->prio[level - 1] < own_prio
+      || (adj_dr->prio[level - 1] == own_prio
+	  && memcmp (adj_dr->snpa, circuit->u.bc.snpa, ETH_ALEN) < 0))
+    {
+      if (!circuit->u.bc.is_dr[level - 1])
+	{
+	  /*
+	   * We are the DR -> commence
+	   */
+	  list_delete (list);
+	  return isis_dr_commence (circuit, level);
+	}
     }
-  } else {
+  else
+    {
 
-    /* ok we have found the DIS - lets mark the adjacency */
-    /* set flag for show output */
-    adj_dr->dis_record[level - 1].dis = ISIS_IS_DIS; 
-    adj_dr->dis_record[level - 1].last_dis_change = time(NULL);
+      /* ok we have found the DIS - lets mark the adjacency */
+      /* set flag for show output */
+      adj_dr->dis_record[level - 1].dis = ISIS_IS_DIS;
+      adj_dr->dis_record[level - 1].last_dis_change = time (NULL);
 
-    /* now loop through a second time to check if there has been a DIS change
-     * if yes rotate the history log
-     */
+      /* now loop through a second time to check if there has been a DIS change
+       * if yes rotate the history log
+       */
 
-    for (node = listhead (list); node; nextnode (node)) {
-      adj = getdata (node);
-      isis_check_dr_change(adj, level);
-    }
+      for (node = listhead (list); node; nextnode (node))
+	{
+	  adj = getdata (node);
+	  isis_check_dr_change (adj, level);
+	}
 
-    /*
-     * We are not DR - if we were -> resign
-     */
+      /*
+       * We are not DR - if we were -> resign
+       */
 
-    if (circuit->u.bc.is_dr[level - 1]) {
-      list_delete (list);
-      return isis_dr_resign (circuit, level);
+      if (circuit->u.bc.is_dr[level - 1])
+	{
+	  list_delete (list);
+	  return isis_dr_resign (circuit, level);
+	}
     }
-  }
- out:
+out:
   if (list)
     list_delete (list);
   return retval;
 }
 
-int 
+int
 isis_dr_resign (struct isis_circuit *circuit, int level)
 {
   u_char id[ISIS_SYS_ID_LEN + 2];
-      
+
   zlog_info ("isis_dr_resign l%d", level);
 
   circuit->u.bc.is_dr[level - 1] = 0;
-  circuit->u.bc.run_dr_elect[level - 1] = 0; 
-  THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[level - 1]);
-  THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
-  
+  circuit->u.bc.run_dr_elect[level - 1] = 0;
+  THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[level - 1]);
+  THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[level - 1]);
+
   memcpy (id, isis->sysid, ISIS_SYS_ID_LEN);
-  LSP_PSEUDO_ID(id) = circuit->circuit_id;
-  LSP_FRAGMENT(id) = 0;
+  LSP_PSEUDO_ID (id) = circuit->circuit_id;
+  LSP_FRAGMENT (id) = 0;
   lsp_purge_dr (id, circuit, level);
 
-  if (level == 1) {
-    memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1);
-    
-    THREAD_TIMER_OFF(circuit->t_send_csnp[0]);
-    
-    THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-        circuit, 2 * circuit->hello_interval[1]);
-    
-    THREAD_TIMER_ON(master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
-        isis_jitter (circuit->psnp_interval[level - 1], PSNP_JITTER));
-  } else {
-    memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1);
-
-    THREAD_TIMER_OFF(circuit->t_send_csnp[1]);
-
-    THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-        circuit, 2 * circuit->hello_interval[1]);
-    
-    THREAD_TIMER_ON(master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
-        isis_jitter (circuit->psnp_interval[level - 1], PSNP_JITTER));
-  }
-  
+  if (level == 1)
+    {
+      memset (circuit->u.bc.l1_desig_is, 0, ISIS_SYS_ID_LEN + 1);
+
+      THREAD_TIMER_OFF (circuit->t_send_csnp[0]);
+
+      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
+		       circuit, 2 * circuit->hello_interval[1]);
+
+      THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
+		       isis_jitter (circuit->psnp_interval[level - 1],
+				    PSNP_JITTER));
+    }
+  else
+    {
+      memset (circuit->u.bc.l2_desig_is, 0, ISIS_SYS_ID_LEN + 1);
+
+      THREAD_TIMER_OFF (circuit->t_send_csnp[1]);
+
+      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
+		       circuit, 2 * circuit->hello_interval[1]);
+
+      THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
+		       isis_jitter (circuit->psnp_interval[level - 1],
+				    PSNP_JITTER));
+    }
+
   thread_add_event (master, isis_event_dis_status_change, circuit, 0);
 
   return ISIS_OK;
 }
 
-int 
+int
 isis_dr_commence (struct isis_circuit *circuit, int level)
 {
   u_char old_dr[ISIS_SYS_ID_LEN + 2];
-  
+
   zlog_info ("isis_dr_commence l%d", level);
 
   /* Lets keep a pause in DR election */
   circuit->u.bc.run_dr_elect[level - 1] = 0;
-  if (level == 1) 
-    THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-        circuit, 2 * circuit->hello_multiplier[0] * 
-			circuit->hello_interval[0]); 
-  else 
-    THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-        circuit, 2 * circuit->hello_multiplier[1] *
-			circuit->hello_interval[1]);	      	
+  if (level == 1)
+    THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
+		     circuit, 2 * circuit->hello_multiplier[0] *
+		     circuit->hello_interval[0]);
+  else
+    THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
+		     circuit, 2 * circuit->hello_multiplier[1] *
+		     circuit->hello_interval[1]);
   circuit->u.bc.is_dr[level - 1] = 1;
 
-  if (level == 1) {
-    memcpy (old_dr, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
-    LSP_FRAGMENT (old_dr) = 0;
-    if (LSP_PSEUDO_ID(old_dr)) {
-      /* there was a dr elected, purge its LSPs from the db */
-      lsp_purge_dr (old_dr, circuit, level);
+  if (level == 1)
+    {
+      memcpy (old_dr, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
+      LSP_FRAGMENT (old_dr) = 0;
+      if (LSP_PSEUDO_ID (old_dr))
+	{
+	  /* there was a dr elected, purge its LSPs from the db */
+	  lsp_purge_dr (old_dr, circuit, level);
+	}
+      memcpy (circuit->u.bc.l1_desig_is, isis->sysid, ISIS_SYS_ID_LEN);
+      *(circuit->u.bc.l1_desig_is + ISIS_SYS_ID_LEN) = circuit->circuit_id;
+
+      assert (circuit->circuit_id);	/* must be non-zero */
+      /*    if (circuit->t_send_l1_psnp)
+         thread_cancel (circuit->t_send_l1_psnp); */
+      lsp_l1_pseudo_generate (circuit);
+
+      THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[0]);
+      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
+		       circuit, 2 * circuit->hello_interval[0]);
+
+      THREAD_TIMER_ON (master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
+		       isis_jitter (circuit->csnp_interval[level - 1],
+				    CSNP_JITTER));
+
     }
-    memcpy (circuit->u.bc.l1_desig_is, isis->sysid, ISIS_SYS_ID_LEN);
-    *(circuit->u.bc.l1_desig_is + ISIS_SYS_ID_LEN) = circuit->circuit_id;
-    
-    assert (circuit->circuit_id); /* must be non-zero */
-    /*    if (circuit->t_send_l1_psnp)
-          thread_cancel (circuit->t_send_l1_psnp); */
-    lsp_l1_pseudo_generate (circuit);
-
-    THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[0]); 
-    THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-        circuit, 2 * circuit->hello_interval[0]);
-    
-    THREAD_TIMER_ON(master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
-        isis_jitter(circuit->csnp_interval[level-1], CSNP_JITTER));
-    
-  } else {
-    memcpy (old_dr, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
-    LSP_FRAGMENT (old_dr) = 0;
-    if (LSP_PSEUDO_ID(old_dr)) {
-      /* there was a dr elected, purge its LSPs from the db */
-      lsp_purge_dr (old_dr, circuit, level);
+  else
+    {
+      memcpy (old_dr, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
+      LSP_FRAGMENT (old_dr) = 0;
+      if (LSP_PSEUDO_ID (old_dr))
+	{
+	  /* there was a dr elected, purge its LSPs from the db */
+	  lsp_purge_dr (old_dr, circuit, level);
+	}
+      memcpy (circuit->u.bc.l2_desig_is, isis->sysid, ISIS_SYS_ID_LEN);
+      *(circuit->u.bc.l2_desig_is + ISIS_SYS_ID_LEN) = circuit->circuit_id;
+
+      assert (circuit->circuit_id);	/* must be non-zero */
+      /*    if (circuit->t_send_l1_psnp)
+         thread_cancel (circuit->t_send_l1_psnp); */
+      lsp_l2_pseudo_generate (circuit);
+
+      THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[1]);
+      THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
+		       circuit, 2 * circuit->hello_interval[1]);
+
+      THREAD_TIMER_ON (master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
+		       isis_jitter (circuit->csnp_interval[level - 1],
+				    CSNP_JITTER));
     }
-    memcpy (circuit->u.bc.l2_desig_is, isis->sysid, ISIS_SYS_ID_LEN);
-    *(circuit->u.bc.l2_desig_is + ISIS_SYS_ID_LEN) = circuit->circuit_id;
-    
-    assert (circuit->circuit_id); /* must be non-zero */
-    /*    if (circuit->t_send_l1_psnp)
-          thread_cancel (circuit->t_send_l1_psnp); */
-    lsp_l2_pseudo_generate (circuit);
-
-    THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[1]);
-    THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-        circuit, 2 * circuit->hello_interval[1]);
-        
-    THREAD_TIMER_ON(master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
-        isis_jitter (circuit->csnp_interval[level-1], CSNP_JITTER));
-  } 
 
   thread_add_event (master, isis_event_dis_status_change, circuit, 0);
-  
+
   return ISIS_OK;
 }
-

+ 2 - 2
isisd/isis_dr.h

@@ -31,7 +31,8 @@ int isis_dr_resign (struct isis_circuit *circuit, int level);
 int isis_dr_commence (struct isis_circuit *circuit, int level);
 char *isis_disflag2string (int disflag);
 
-enum isis_dis_state {     
+enum isis_dis_state
+{
   ISIS_IS_NOT_DIS,
   ISIS_IS_DIS,
   ISIS_WAS_DIS,
@@ -39,4 +40,3 @@ enum isis_dis_state {
 };
 
 #endif /* _ZEBRA_ISIS_DR_H */
-

+ 37 - 32
isisd/isis_dynhn.c

@@ -50,48 +50,52 @@ void
 dyn_cache_init (void)
 {
   dyn_cache = list_new ();
-  
+
   return;
 }
 
-struct isis_dynhn *dynhn_find_by_id (u_char * id)
+struct isis_dynhn *
+dynhn_find_by_id (u_char * id)
 {
   struct listnode *node = NULL;
   struct isis_dynhn *dyn = NULL;
 
-  for (node = listhead (dyn_cache); node; nextnode (node)) {
-    dyn = getdata (node);
-    if (memcmp (dyn->id, id, ISIS_SYS_ID_LEN) == 0)
-      return dyn;
-  }
-  
+  for (node = listhead (dyn_cache); node; nextnode (node))
+    {
+      dyn = getdata (node);
+      if (memcmp (dyn->id, id, ISIS_SYS_ID_LEN) == 0)
+	return dyn;
+    }
+
   return NULL;
 }
 
 void
-isis_dynhn_insert (u_char *id, struct hostname *hostname, int level)
+isis_dynhn_insert (u_char * id, struct hostname *hostname, int level)
 {
   struct isis_dynhn *dyn;
 
   dyn = dynhn_find_by_id (id);
-  if (dyn) {
-    memcpy (&dyn->name, hostname, hostname->namelen + 1);
-    memcpy (dyn->id, id, ISIS_SYS_ID_LEN);
-    dyn->refresh = time (NULL);
-    return;
-  }
+  if (dyn)
+    {
+      memcpy (&dyn->name, hostname, hostname->namelen + 1);
+      memcpy (dyn->id, id, ISIS_SYS_ID_LEN);
+      dyn->refresh = time (NULL);
+      return;
+    }
   dyn = XMALLOC (MTYPE_ISIS_DYNHN, sizeof (struct isis_dynhn));
-  if (!dyn) {
-    zlog_warn ("isis_dynhn_insert(): out of memory!");
-    return;
-  }
-  memset (dyn,0,sizeof(struct isis_dynhn));
+  if (!dyn)
+    {
+      zlog_warn ("isis_dynhn_insert(): out of memory!");
+      return;
+    }
+  memset (dyn, 0, sizeof (struct isis_dynhn));
   /* we also copy the length */
-  memcpy (&dyn->name, hostname, hostname->namelen + 1); 
+  memcpy (&dyn->name, hostname, hostname->namelen + 1);
   memcpy (dyn->id, id, ISIS_SYS_ID_LEN);
   dyn->refresh = time (NULL);
   dyn->level = level;
-  
+
   listnode_add (dyn_cache, dyn);
 
   return;
@@ -103,21 +107,22 @@ isis_dynhn_insert (u_char *id, struct hostname *hostname, int level)
  *  2     0000.0000.0002 bar-gw
  *      * 0000.0000.0004 this-gw
  */
-void  dynhn_print_all (struct vty *vty) 
+void
+dynhn_print_all (struct vty *vty)
 {
   struct listnode *node;
   struct isis_dynhn *dyn;
 
   vty_out (vty, "Level  System ID      Dynamic Hostname%s", VTY_NEWLINE);
-  for (node = listhead (dyn_cache); node; nextnode (node)) {
-    dyn = getdata (node);
-    vty_out (vty, "%-7d", dyn->level);
-    vty_out (vty, "%-15s%-15s%s", sysid_print (dyn->id), dyn->name.name, 
-	     VTY_NEWLINE);
-  }
-  
-  vty_out (vty,  "     * %s %s%s", sysid_print (isis->sysid), unix_hostname(), 
+  for (node = listhead (dyn_cache); node; nextnode (node))
+    {
+      dyn = getdata (node);
+      vty_out (vty, "%-7d", dyn->level);
+      vty_out (vty, "%-15s%-15s%s", sysid_print (dyn->id), dyn->name.name,
+	       VTY_NEWLINE);
+    }
+
+  vty_out (vty, "     * %s %s%s", sysid_print (isis->sysid), unix_hostname (),
 	   VTY_NEWLINE);
   return;
 }
-

+ 4 - 7
isisd/isis_dynhn.h

@@ -23,7 +23,8 @@
 #ifndef _ZEBRA_ISIS_DYNHN_H
 #define _ZEBRA_ISIS_DYNHN_H
 
-struct isis_dynhn {
+struct isis_dynhn
+{
   u_char id[ISIS_SYS_ID_LEN];
   struct hostname name;
   time_t refresh;
@@ -31,12 +32,8 @@ struct isis_dynhn {
 };
 
 void dyn_cache_init (void);
-void isis_dynhn_insert (u_char *id, struct hostname *hostname, int level);
+void isis_dynhn_insert (u_char * id, struct hostname *hostname, int level);
 struct isis_dynhn *dynhn_find_by_id (u_char * id);
-void  dynhn_print_all (struct vty *vty);
+void dynhn_print_all (struct vty *vty);
 
 #endif /* _ZEBRA_ISIS_DYNHN_H */
-
-
-
-

+ 153 - 139
isisd/isis_events.c

@@ -64,19 +64,19 @@ extern struct isis *isis;
  4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844
 */
 
-void 
+void
 isis_event_circuit_state_change (struct isis_circuit *circuit, int up)
 {
   struct isis_area *area;
-  
+
   area = circuit->area;
   assert (area);
   area->circuit_state_changes++;
-  
-  if (isis->debugs & DEBUG_EVENTS) 
-    zlog_info ("ISIS-Evt (%s) circuit %s", circuit->area->area_tag, 
+
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_info ("ISIS-Evt (%s) circuit %s", circuit->area->area_tag,
 	       up ? "up" : "down");
-  
+
   /*
    * Regenerate LSPs this affects
    */
@@ -85,47 +85,51 @@ isis_event_circuit_state_change (struct isis_circuit *circuit, int up)
   return;
 }
 
-void 
+void
 isis_event_system_type_change (struct isis_area *area, int newtype)
 {
   struct listnode *node;
   struct isis_circuit *circuit;
 
-  if (isis->debugs & DEBUG_EVENTS) 
-    zlog_info ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag, 
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_info ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag,
 	       circuit_t2string (area->is_type), circuit_t2string (newtype));
-  
+
   if (area->is_type == newtype)
-    return; /* No change */
-  
-  switch (area->is_type) {
-  case IS_LEVEL_1:
-    if (area->lspdb[1] == NULL)
-      area->lspdb[1] = lsp_db_init (); 
-    lsp_l2_generate (area);
-    break;
-  case IS_LEVEL_1_AND_2:
-    if (newtype == IS_LEVEL_1) {
-      lsp_db_destroy (area->lspdb[1]);
-    } 
-    else {
-      lsp_db_destroy (area->lspdb[0]);
-    } 
-    break;
-  case IS_LEVEL_2:
-    if (area->lspdb[0] == NULL)
-      area->lspdb[0] = lsp_db_init (); 
-    lsp_l1_generate (area);
-    break;
-  default:
-    break;
-  }
-  
+    return;			/* No change */
+
+  switch (area->is_type)
+    {
+    case IS_LEVEL_1:
+      if (area->lspdb[1] == NULL)
+	area->lspdb[1] = lsp_db_init ();
+      lsp_l2_generate (area);
+      break;
+    case IS_LEVEL_1_AND_2:
+      if (newtype == IS_LEVEL_1)
+	{
+	  lsp_db_destroy (area->lspdb[1]);
+	}
+      else
+	{
+	  lsp_db_destroy (area->lspdb[0]);
+	}
+      break;
+    case IS_LEVEL_2:
+      if (area->lspdb[0] == NULL)
+	area->lspdb[0] = lsp_db_init ();
+      lsp_l1_generate (area);
+      break;
+    default:
+      break;
+    }
+
   area->is_type = newtype;
-  for (node = listhead (area->circuit_list); node; nextnode (node)) {
-    circuit = getdata (node);
-    isis_event_circuit_type_change (circuit, newtype);
-  }
+  for (node = listhead (area->circuit_list); node; nextnode (node))
+    {
+      circuit = getdata (node);
+      isis_event_circuit_type_change (circuit, newtype);
+    }
 
   spftree_area_init (area);
   lsp_regenerate_schedule (area);
@@ -133,9 +137,7 @@ isis_event_system_type_change (struct isis_area *area, int newtype)
   return;
 }
 
-
-
-void 
+void
 isis_event_area_addr_change (struct isis_area *area)
 {
 
@@ -146,40 +148,49 @@ circuit_commence_level (struct isis_circuit *circuit, int level)
 {
   uint32_t interval;
 
-  if (level == 1) {
-    THREAD_TIMER_ON(master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
-        isis_jitter(circuit->psnp_interval[0], PSNP_JITTER));
-
-    if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
-      interval = circuit->hello_multiplier[0] * (circuit->hello_interval[0]); 
-      
-      THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
-						     circuit, interval);
-      
-      THREAD_TIMER_ON(master, circuit->u.bc.t_send_lan_hello[0],
-          send_lan_l1_hello, circuit,
-          isis_jitter(circuit->hello_interval[0], IIH_JITTER));
-      
-      circuit->u.bc.lan_neighs[0] = list_new ();
+  if (level == 1)
+    {
+      THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
+		       isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
+
+      if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+	{
+	  interval =
+	    circuit->hello_multiplier[0] * (circuit->hello_interval[0]);
+
+	  THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
+			   circuit, interval);
+
+	  THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
+			   send_lan_l1_hello, circuit,
+			   isis_jitter (circuit->hello_interval[0],
+					IIH_JITTER));
+
+	  circuit->u.bc.lan_neighs[0] = list_new ();
+	}
     }
-  } else {
-    THREAD_TIMER_ON(master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
-        isis_jitter(circuit->psnp_interval[1], PSNP_JITTER));
-
-    if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
-      interval = circuit->hello_multiplier[1] * (circuit->hello_interval[1]); 
-      
-      THREAD_TIMER_ON(master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
-						     circuit, interval);
-      
-      THREAD_TIMER_ON(master, circuit->u.bc.t_send_lan_hello[1],
-          send_lan_l2_hello, circuit,
-          isis_jitter(circuit->hello_interval[1], IIH_JITTER));
-      
-      circuit->u.bc.lan_neighs[1] = list_new ();
+  else
+    {
+      THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
+		       isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+
+      if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+	{
+	  interval =
+	    circuit->hello_multiplier[1] * (circuit->hello_interval[1]);
+
+	  THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
+			   circuit, interval);
+
+	  THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
+			   send_lan_l2_hello, circuit,
+			   isis_jitter (circuit->hello_interval[1],
+					IIH_JITTER));
+
+	  circuit->u.bc.lan_neighs[1] = list_new ();
+	}
     }
-  }
-  
+
   return;
 }
 
@@ -187,61 +198,64 @@ void
 circuit_resign_level (struct isis_circuit *circuit, int level)
 {
   int idx = level - 1;
- 
-  THREAD_TIMER_OFF(circuit->t_send_csnp[idx]);
-  THREAD_TIMER_OFF(circuit->t_send_psnp[idx]);
-
-  if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
-    THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[idx]);
-    THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[idx]);
-    circuit->u.bc.run_dr_elect[idx] = 0;
-  }
-  
+
+  THREAD_TIMER_OFF (circuit->t_send_csnp[idx]);
+  THREAD_TIMER_OFF (circuit->t_send_psnp[idx]);
+
+  if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+    {
+      THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[idx]);
+      THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[idx]);
+      circuit->u.bc.run_dr_elect[idx] = 0;
+    }
+
   return;
 }
 
-void 
-isis_event_circuit_type_change (struct isis_circuit *circuit, int newtype) 
+void
+isis_event_circuit_type_change (struct isis_circuit *circuit, int newtype)
 {
-  
-  if (isis->debugs & DEBUG_EVENTS) 
-    zlog_info ("ISIS-Evt (%s) circuit type change %s -> %s", 
-	       circuit->area->area_tag, 
-	       circuit_t2string (circuit->circuit_is_type), 
+
+  if (isis->debugs & DEBUG_EVENTS)
+    zlog_info ("ISIS-Evt (%s) circuit type change %s -> %s",
+	       circuit->area->area_tag,
+	       circuit_t2string (circuit->circuit_is_type),
 	       circuit_t2string (newtype));
 
   if (circuit->circuit_is_type == newtype)
-    return; /* No change */
+    return;			/* No change */
+
+  if (!(newtype & circuit->area->is_type))
+    {
+      zlog_err ("ISIS-Evt (%s) circuit type change - invalid level %s because"
+		" area is %s", circuit->area->area_tag,
+		circuit_t2string (newtype),
+		circuit_t2string (circuit->area->is_type));
+      return;
+    }
+
+  switch (circuit->circuit_is_type)
+    {
+    case IS_LEVEL_1:
+      if (newtype == IS_LEVEL_2)
+	circuit_resign_level (circuit, 1);
+      circuit_commence_level (circuit, 2);
+      break;
+    case IS_LEVEL_1_AND_2:
+      if (newtype == IS_LEVEL_1)
+	circuit_resign_level (circuit, 2);
+      else
+	circuit_resign_level (circuit, 1);
+      break;
+    case IS_LEVEL_2:
+      if (newtype == IS_LEVEL_1)
+	circuit_resign_level (circuit, 2);
+      circuit_commence_level (circuit, 1);
+      break;
+    default:
+      break;
+    }
 
-  if (!(newtype & circuit->area->is_type)) {
-    zlog_err ("ISIS-Evt (%s) circuit type change - invalid level %s because"
-	      " area is %s", circuit->area->area_tag, 
-	      circuit_t2string (newtype), 
-	      circuit_t2string (circuit->area->is_type));
-    return;
-  }
-    
-  switch (circuit->circuit_is_type) {
-  case IS_LEVEL_1:
-    if (newtype == IS_LEVEL_2)
-      circuit_resign_level (circuit, 1);
-    circuit_commence_level (circuit, 2);
-    break;
-  case IS_LEVEL_1_AND_2:
-    if (newtype == IS_LEVEL_1)
-      circuit_resign_level (circuit, 2);
-    else 
-      circuit_resign_level (circuit, 1);
-    break;
-  case IS_LEVEL_2:
-    if (newtype == IS_LEVEL_1)
-      circuit_resign_level (circuit, 2);
-    circuit_commence_level (circuit, 1);
-    break;
-  default:
-    break;
-  }
-  
   circuit->circuit_is_type = newtype;
   lsp_regenerate_schedule (circuit->area);
 
@@ -270,18 +284,19 @@ isis_event_circuit_type_change (struct isis_circuit *circuit, int newtype)
   *
   * ***********************************************************************/
 
-void 
+void
 isis_event_adjacency_state_change (struct isis_adjacency *adj, int newstate)
 {
   /* adjacency state change event. 
    * - the only proto-type was supported */
-  
-  /* invalid arguments */ 
-  if ( !adj || !adj->circuit || !adj->circuit->area ) return;     
-  
-  zlog_info ("ISIS-Evt (%s) Adjacency State change", 
-	     adj->circuit->area->area_tag );
-  
+
+  /* invalid arguments */
+  if (!adj || !adj->circuit || !adj->circuit->area)
+    return;
+
+  zlog_info ("ISIS-Evt (%s) Adjacency State change",
+	     adj->circuit->area->area_tag);
+
   /* LSP generation again */
   lsp_regenerate_schedule (adj->circuit->area);
 
@@ -294,27 +309,26 @@ int
 isis_event_dis_status_change (struct thread *thread)
 {
   struct isis_circuit *circuit;
-  
+
   circuit = THREAD_ARG (thread);
-  
+
   /* invalid arguments */
-  if (!circuit || !circuit->area) return 0;
-  
+  if (!circuit || !circuit->area)
+    return 0;
+
   zlog_info ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag);
 
   /* LSP generation again */
   lsp_regenerate_schedule (circuit->area);
-  
+
   return 0;
 }
 
-
-void 
-isis_event_auth_failure (char *area_tag, char *error_string, char *sysid) 
+void
+isis_event_auth_failure (char *area_tag, char *error_string, char *sysid)
 {
   zlog_info ("ISIS-Evt (%s) Authentication failure %s from %s",
 	     area_tag, error_string, sysid_print (sysid));
-  
+
   return;
 }
-

+ 8 - 7
isisd/isis_events.h

@@ -31,14 +31,15 @@ void isis_event_area_addr_change (struct isis_area *area);
 /*
  * Events related to circuit
  */
-void isis_event_circuit_state_change (struct isis_circuit *circuit, int state);
-void isis_event_circuit_type_change (struct isis_circuit *circuit, 
-                                     int newtype);
+void isis_event_circuit_state_change (struct isis_circuit *circuit,
+				      int state);
+void isis_event_circuit_type_change (struct isis_circuit *circuit,
+				     int newtype);
 /*
  * Events related to adjacencies
  */
-void isis_event_adjacency_state_change(struct isis_adjacency *adj, 
-                                       int newstate);
+void isis_event_adjacency_state_change (struct isis_adjacency *adj,
+					int newstate);
 
 int isis_event_dis_status_change (struct thread *thread);
 
@@ -48,7 +49,7 @@ int isis_event_dis_status_change (struct thread *thread);
 #define AUTH_ERROR_TYPE_LSP   3
 #define AUTH_ERROR_TYPE_SNP   2
 #define AUTH_ERROR_TYPE_HELLO 1
-void isis_event_auth_failure (char *area_tag, char *error_string, char *sysid);
+void isis_event_auth_failure (char *area_tag, char *error_string,
+			      char *sysid);
 
 #endif /* _ZEBRA_ISIS_EVENTS_H */
-

+ 27 - 25
isisd/isis_flags.c

@@ -21,7 +21,6 @@
  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-
 #include <zebra.h>
 #include "log.h"
 #include "linklist.h"
@@ -31,41 +30,44 @@
 #include "isisd/isis_flags.h"
 
 int
-flags_get_index (struct flags *flags) 
+flags_get_index (struct flags *flags)
 {
   struct listnode *node;
   int index;
 
-  if (flags->free_idcs == NULL || flags->free_idcs->count == 0) {
-    flags->maxindex++;
-    index = flags->maxindex;
-  } else {
-    node = listhead (flags->free_idcs);
-    index = (int) getdata (node);
-    listnode_delete (flags->free_idcs, (void *)index);
-  }
-  
+  if (flags->free_idcs == NULL || flags->free_idcs->count == 0)
+    {
+      flags->maxindex++;
+      index = flags->maxindex;
+    }
+  else
+    {
+      node = listhead (flags->free_idcs);
+      index = (int) getdata (node);
+      listnode_delete (flags->free_idcs, (void *) index);
+    }
+
   return index;
 }
 
-void 
-flags_free_index (struct flags *flags, int index) 
+void
+flags_free_index (struct flags *flags, int index)
 {
-  if (flags->free_idcs == NULL) {
-    flags->free_idcs = list_new ();
-  }
-  
-  listnode_add (flags->free_idcs, (void *)index);
-  
+  if (flags->free_idcs == NULL)
+    {
+      flags->free_idcs = list_new ();
+    }
+
+  listnode_add (flags->free_idcs, (void *) index);
+
   return;
 }
 
-int  
-flags_any_set (u_int32_t *flags)
+int
+flags_any_set (u_int32_t * flags)
 {
+  u_int32_t zero[ISIS_MAX_CIRCUITS];
+  memset (zero, 0x00, ISIS_MAX_CIRCUITS * 4);
 
-  u_int32_t zero[ISIS_MAX_CIRCUITS]; 
-  memset (zero, 0x00, ISIS_MAX_CIRCUITS*4); 
-
-  return bcmp(flags, zero, ISIS_MAX_CIRCUITS*4);
+  return bcmp (flags, zero, ISIS_MAX_CIRCUITS * 4);
 }

+ 5 - 11
isisd/isis_flags.h

@@ -26,13 +26,13 @@
 
 /* The grand plan is to support 1024 circuits so we have 32*32 bit flags
  * the support will be achived using the newest drafts */
-#define ISIS_MAX_CIRCUITS 32 /* = 1024 */ /*FIXME:defined in lsp.h as well*/
+#define ISIS_MAX_CIRCUITS 32 /* = 1024 */	/*FIXME:defined in lsp.h as well */
 
-struct flags *new_flags        (int size);
-int           flags_get_index  (struct flags *flags);
-void          flags_free_index (struct flags *flags, int index);
+struct flags *new_flags (int size);
+int flags_get_index (struct flags *flags);
+void flags_free_index (struct flags *flags, int index);
 
-int