]> git.puffer.fish Git - mirror/frr.git/commitdiff
* isis_tlv.[ch]: Two new functions - tlv_add_te_is_neighs() and
authorhasso <hasso>
Mon, 26 Sep 2005 17:11:12 +0000 (17:11 +0000)
committerhasso <hasso>
Mon, 26 Sep 2005 17:11:12 +0000 (17:11 +0000)
  tlv_add_te_ipv4_reachs() to handle TLV's with new metric. None of
  them handle sub TLVs though for now.

isisd/ChangeLog
isisd/isis_tlv.c
isisd/isis_tlv.h

index 04f048a4650ae7c809c87362d7ec3c801f045fa7..99421504ea0c1e1b02f42061d6891652141a168b 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-26 Hasso Tepper <hasso at quagga.net>
+
+       * isis_tlv.[ch]: Two new functions - tlv_add_te_is_neighs() and
+         tlv_add_te_ipv4_reachs() to handle TLV's with new metric. None of
+         them handle sub TLVs though for now.
+
 2005-09-26 Hasso Tepper <hasso at quagga.net>
 
        * isis_circuit.[ch]: Some preliminary support for specifying wide
index 1850e15db49aebbb019324f95b6ef08a9da50b5b..f43072466601e59da27976eef875d69af094a5b9 100644 (file)
@@ -804,6 +804,38 @@ tlv_add_is_neighs (struct list *is_neighs, struct stream *stream)
   return add_tlv (IS_NEIGHBOURS, pos - value, value, stream);
 }
 
+int
+tlv_add_te_is_neighs (struct list *te_is_neighs, struct stream *stream)
+{
+  struct listnode *node, *nnode;
+  struct te_is_neigh *te_is_neigh;
+  u_char value[255];
+  u_char *pos = value;
+  int retval;
+
+  for (ALL_LIST_ELEMENTS (te_is_neighs, node, nnode, te_is_neigh))
+    {
+      /* FIXME: This will be wrong if we are going to add TE sub TLVs. */
+      if (pos - value + IS_NEIGHBOURS_LEN > 255)
+        {
+          retval = add_tlv (TE_IS_NEIGHBOURS, pos - value, value, stream);
+          if (retval != ISIS_OK)
+            return retval;
+          pos = value;
+        }
+      
+      memcpy (pos, te_is_neigh->neigh_id, ISIS_SYS_ID_LEN + 1);
+      pos += ISIS_SYS_ID_LEN + 1;
+      memcpy (pos, te_is_neigh->te_metric, 3);
+      pos += 3;
+      /* Sub TLVs length. */
+      *pos = 0;
+      pos++;
+    }
+
+  return add_tlv (TE_IS_NEIGHBOURS, pos - value, value, stream);
+}
+
 int
 tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream)
 {
@@ -970,6 +1002,39 @@ tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream)
   return add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream);
 }
 
+int
+tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream)
+{
+  struct listnode *node, *nnode;
+  struct te_ipv4_reachability *te_reach;
+  u_char value[255];
+  u_char *pos = value;
+  u_char prefix_size;
+  int retval;
+
+  for (ALL_LIST_ELEMENTS (te_ipv4_reachs, node, nnode, te_reach))
+    {
+      prefix_size = ((((te_reach->control & 0x3F) - 1) >> 3) + 1);
+
+      if (pos - value + (5 + prefix_size) > 255)
+       {
+         retval =
+           add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream);
+         if (retval != ISIS_OK)
+           return retval;
+         pos = value;
+       }
+      *(u_int32_t *) pos = te_reach->te_metric;
+      pos += 4;
+      *pos = te_reach->control;
+      pos++;
+      memcpy (pos, &te_reach->prefix_start, prefix_size);
+      pos += prefix_size;
+    }
+
+  return add_tlv (TE_IPV4_REACHABILITY, pos - value, value, stream);
+}
+
 #ifdef HAVE_IPV6
 int
 tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream)
index 035bb636925549fca7172be28271cc2009943965..1dc030e00706c51167b95694f171ea6d2b26079b 100644 (file)
@@ -279,6 +279,7 @@ void free_tlv (void *val);
 int add_tlv (u_char, u_char, u_char *, struct stream *);
 int tlv_add_area_addrs (struct list *area_addrs, struct stream *stream);
 int tlv_add_is_neighs (struct list *is_neighs, struct stream *stream);
+int tlv_add_te_is_neighs (struct list *te_is_neighs, struct stream *stream);
 int tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream);
 int tlv_add_nlpid (struct nlpids *nlpids, struct stream *stream);
 int tlv_add_checksum (struct checksum *checksum, struct stream *stream);
@@ -289,6 +290,7 @@ int tlv_add_dynamic_hostname (struct hostname *hostname,
                              struct stream *stream);
 int tlv_add_lsp_entries (struct list *lsps, struct stream *stream);
 int tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream);
+int tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream);
 #ifdef HAVE_IPV6
 int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream);
 int tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream);