summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorhasso <hasso>2004-09-10 22:48:21 +0200
committerhasso <hasso>2004-09-10 22:48:21 +0200
commitf390d2c7839c04100e4de8246215ce10ea96b653 (patch)
tree9910d250bfb6605d44e7104ef786ba0c84ddb01a /isisd
parentAdd IS-IS info into array. (diff)
downloadfrr-f390d2c7839c04100e4de8246215ce10ea96b653.tar.xz
frr-f390d2c7839c04100e4de8246215ce10ea96b653.zip
Indentation only. No any functional changes.
Diffstat (limited to 'isisd')
-rw-r--r--isisd/dict.c2090
-rw-r--r--isisd/dict.h128
-rw-r--r--isisd/isis_adjacency.c552
-rw-r--r--isisd/isis_adjacency.h91
-rw-r--r--isisd/isis_circuit.c1838
-rw-r--r--isisd/isis_circuit.h175
-rw-r--r--isisd/isis_common.h25
-rw-r--r--isisd/isis_constants.h32
-rw-r--r--isisd/isis_csm.c202
-rw-r--r--isisd/isis_csm.h12
-rw-r--r--isisd/isis_dr.c388
-rw-r--r--isisd/isis_dr.h4
-rw-r--r--isisd/isis_dynhn.c69
-rw-r--r--isisd/isis_dynhn.h11
-rw-r--r--isisd/isis_events.c292
-rw-r--r--isisd/isis_events.h15
-rw-r--r--isisd/isis_flags.c52
-rw-r--r--isisd/isis_flags.h16
-rw-r--r--isisd/isis_lsp.c2689
-rw-r--r--isisd/isis_lsp.h83
-rw-r--r--isisd/isis_main.c185
-rw-r--r--isisd/isis_misc.c465
-rw-r--r--isisd/isis_misc.h32
-rw-r--r--isisd/isis_network.c566
-rw-r--r--isisd/isis_network.h4
-rw-r--r--isisd/isis_pdu.c2910
-rw-r--r--isisd/isis_pdu.h92
-rw-r--r--isisd/isis_route.c568
-rw-r--r--isisd/isis_route.h21
-rw-r--r--isisd/isis_routemap.c39
-rw-r--r--isisd/isis_spf.c1631
-rw-r--r--isisd/isis_spf.h43
-rw-r--r--isisd/isis_tlv.c1565
-rw-r--r--isisd/isis_tlv.h168
-rw-r--r--isisd/isis_zebra.c468
-rw-r--r--isisd/isis_zebra.h4
-rw-r--r--isisd/isisd.c1339
-rw-r--r--isisd/isisd.h95
-rw-r--r--isisd/iso_checksum.c72
-rw-r--r--isisd/iso_checksum.h4
40 files changed, 10011 insertions, 9024 deletions
diff --git a/isisd/dict.c b/isisd/dict.c
index 4c787ac58..86206a3b7 100644
--- a/isisd/dict.c
+++ b/isisd/dict.c
@@ -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.c,v 1.1 2003/12/23 08:09:47 jardin Exp $
+ * $Id: dict.c,v 1.2 2004/09/10 20:48:21 hasso Exp $
* $Name: $
*/
@@ -25,7 +25,8 @@
#include "dict.h"
#ifdef KAZLIB_RCSID
-static const char rcsid[] = "$Id: dict.c,v 1.1 2003/12/23 08:09:47 jardin Exp $";
+static const char rcsid[] =
+ "$Id: dict.c,v 1.2 2004/09/10 20:48:21 hasso Exp $";
#endif
/*
@@ -62,8 +63,8 @@ static const char rcsid[] = "$Id: dict.c,v 1.1 2003/12/23 08:09:47 jardin Exp $"
#define dict_nil(D) (&(D)->nilnode)
#define DICT_DEPTH_MAX 64
-static dnode_t *dnode_alloc(void *context);
-static void dnode_free(dnode_t *node, void *context);
+static dnode_t *dnode_alloc (void *context);
+static void dnode_free (dnode_t * node, void *context);
/*
* Perform a ``left rotation'' adjustment on the tree. The given node P and
@@ -72,28 +73,32 @@ static void dnode_free(dnode_t *node, void *context);
* for P. The ordering of the keys within the tree is thus preserved.
*/
-static void rotate_left(dnode_t *upper)
+static void
+rotate_left (dnode_t * upper)
{
- dnode_t *lower, *lowleft, *upparent;
+ dnode_t *lower, *lowleft, *upparent;
- lower = upper->right;
- upper->right = lowleft = lower->left;
- lowleft->parent = upper;
+ lower = upper->right;
+ upper->right = lowleft = lower->left;
+ lowleft->parent = upper;
- lower->parent = upparent = upper->parent;
+ lower->parent = upparent = upper->parent;
- /* don't need to check for root node here because root->parent is
- the sentinel nil node, and root->parent->left points back to root */
+ /* don't need to check for root node here because root->parent is
+ the sentinel nil node, and root->parent->left points back to root */
- if (upper == upparent->left) {
- upparent->left = lower;
- } else {
- assert (upper == upparent->right);
- upparent->right = lower;
+ if (upper == upparent->left)
+ {
+ upparent->left = lower;
+ }
+ else
+ {
+ assert (upper == upparent->right);
+ upparent->right = lower;
}
- lower->left = upper;
- upper->parent = lower;
+ lower->left = upper;
+ upper->parent = lower;
}
/*
@@ -101,25 +106,29 @@ static void rotate_left(dnode_t *upper)
* the same procedure, but with left and right interchanged.
*/
-static void rotate_right(dnode_t *upper)
+static void
+rotate_right (dnode_t * upper)
{
- dnode_t *lower, *lowright, *upparent;
+ dnode_t *lower, *lowright, *upparent;
- lower = upper->left;
- upper->left = lowright = lower->right;
- lowright->parent = upper;
+ lower = upper->left;
+ upper->left = lowright = lower->right;
+ lowright->parent = upper;
- lower->parent = upparent = upper->parent;
+ lower->parent = upparent = upper->parent;
- if (upper == upparent->right) {
- upparent->right = lower;
- } else {
- assert (upper == upparent->left);
- upparent->left = lower;
+ if (upper == upparent->right)
+ {
+ upparent->right = lower;
+ }
+ else
+ {
+ assert (upper == upparent->left);
+ upparent->left = lower;
}
- lower->right = upper;
- upper->parent = lower;
+ lower->right = upper;
+ upper->parent = lower;
}
/*
@@ -127,13 +136,14 @@ static void rotate_right(dnode_t *upper)
* node and free everything under it. Used by dict_free().
*/
-static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
+static void
+free_nodes (dict_t * dict, dnode_t * node, dnode_t * nil)
{
- if (node == nil)
- return;
- free_nodes(dict, node->left, nil);
- free_nodes(dict, node->right, nil);
- dict->freenode(node, dict->context);
+ if (node == nil)
+ return;
+ free_nodes (dict, node->left, nil);
+ free_nodes (dict, node->right, nil);
+ dict->freenode (node, dict->context);
}
/*
@@ -145,26 +155,32 @@ static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
* debugging purposes.
*/
-static int verify_bintree(dict_t *dict)
+static int
+verify_bintree (dict_t * dict)
{
- dnode_t *first, *next;
+ dnode_t *first, *next;
- first = dict_first(dict);
+ first = dict_first (dict);
- if (dict->dupes) {
- while (first && (next = dict_next(dict, first))) {
- if (dict->compare(first->key, next->key) > 0)
- return 0;
- first = next;
+ if (dict->dupes)
+ {
+ while (first && (next = dict_next (dict, first)))
+ {
+ if (dict->compare (first->key, next->key) > 0)
+ return 0;
+ first = next;
}
- } else {
- while (first && (next = dict_next(dict, first))) {
- if (dict->compare(first->key, next->key) >= 0)
- return 0;
- first = next;
+ }
+ else
+ {
+ while (first && (next = dict_next (dict, first)))
+ {
+ if (dict->compare (first->key, next->key) >= 0)
+ return 0;
+ first = next;
}
}
- return 1;
+ return 1;
}
@@ -181,29 +197,32 @@ static int verify_bintree(dict_t *dict)
* subtree is not red-black.
*/
-static unsigned int verify_redblack(dnode_t *nil, dnode_t *root)
+static unsigned int
+verify_redblack (dnode_t * nil, dnode_t * root)
{
- unsigned height_left, height_right;
+ unsigned height_left, height_right;
- if (root != nil) {
- height_left = verify_redblack(nil, root->left);
- height_right = verify_redblack(nil, root->right);
- if (height_left == 0 || height_right == 0)
+ if (root != nil)
+ {
+ height_left = verify_redblack (nil, root->left);
+ height_right = verify_redblack (nil, root->right);
+ if (height_left == 0 || height_right == 0)
+ return 0;
+ if (height_left != height_right)
+ return 0;
+ if (root->color == dnode_red)
+ {
+ if (root->left->color != dnode_black)
return 0;
- if (height_left != height_right)
+ if (root->right->color != dnode_black)
return 0;
- if (root->color == dnode_red) {
- if (root->left->color != dnode_black)
- return 0;
- if (root->right->color != dnode_black)
- return 0;
- return height_left;
+ return height_left;
}
- if (root->color != dnode_black)
- return 0;
- return height_left + 1;
- }
- return 1;
+ if (root->color != dnode_black)
+ return 0;
+ return height_left + 1;
+ }
+ return 1;
}
/*
@@ -212,13 +231,14 @@ static unsigned int verify_redblack(dnode_t *nil, dnode_t *root)
* detect a mismatch.
*/
-static dictcount_t verify_node_count(dnode_t *nil, dnode_t *root)
+static dictcount_t
+verify_node_count (dnode_t * nil, dnode_t * root)
{
- if (root == nil)
- return 0;
- else
- return 1 + verify_node_count(nil, root->left)
- + verify_node_count(nil, root->right);
+ if (root == nil)
+ return 0;
+ else
+ return 1 + verify_node_count (nil, root->left)
+ + verify_node_count (nil, root->right);
}
/*
@@ -228,54 +248,58 @@ static dictcount_t verify_node_count(dnode_t *nil, dnode_t *root)
* returns zero. It is intended for debugging purposes.
*/
-static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node)
+static int
+verify_dict_has_node (dnode_t * nil, dnode_t * root, dnode_t * node)
{
- if (root != nil) {
- return root == node
- || verify_dict_has_node(nil, root->left, node)
- || verify_dict_has_node(nil, root->right, node);
+ if (root != nil)
+ {
+ return root == node
+ || verify_dict_has_node (nil, root->left, node)
+ || verify_dict_has_node (nil, root->right, node);
}
- return 0;
+ return 0;
}
-
/*
* Dynamically allocate and initialize a dictionary object.
*/
-dict_t *dict_create(dictcount_t maxcount, dict_comp_t comp)
+dict_t *
+dict_create (dictcount_t maxcount, dict_comp_t comp)
{
- dict_t *new = malloc(sizeof *new);
-
- if (new) {
- new->compare = comp;
- new->allocnode = dnode_alloc;
- new->freenode = dnode_free;
- new->context = NULL;
- new->nodecount = 0;
- new->maxcount = maxcount;
- new->nilnode.left = &new->nilnode;
- new->nilnode.right = &new->nilnode;
- new->nilnode.parent = &new->nilnode;
- new->nilnode.color = dnode_black;
- new->dupes = 0;
+ dict_t *new = malloc (sizeof *new);
+
+ if (new)
+ {
+ new->compare = comp;
+ new->allocnode = dnode_alloc;
+ new->freenode = dnode_free;
+ new->context = NULL;
+ new->nodecount = 0;
+ new->maxcount = maxcount;
+ new->nilnode.left = &new->nilnode;
+ new->nilnode.right = &new->nilnode;
+ new->nilnode.parent = &new->nilnode;
+ new->nilnode.color = dnode_black;
+ new->dupes = 0;
}
- return new;
+ return new;
}
/*
* Select a different set of node allocator routines.
*/
-void dict_set_allocator(dict_t *dict, dnode_alloc_t al,
- dnode_free_t fr, void *context)
+void
+dict_set_allocator (dict_t * dict, dnode_alloc_t al,
+ dnode_free_t fr, void *context)
{
- assert (dict_count(dict) == 0);
- assert ((al == NULL && fr == NULL) || (al != NULL && fr != NULL));
+ assert (dict_count (dict) == 0);
+ assert ((al == NULL && fr == NULL) || (al != NULL && fr != NULL));
- dict->allocnode = al ? al : dnode_alloc;
- dict->freenode = fr ? fr : dnode_free;
- dict->context = context;
+ dict->allocnode = al ? al : dnode_alloc;
+ dict->freenode = fr ? fr : dnode_free;
+ dict->context = context;
}
/*
@@ -283,10 +307,11 @@ void dict_set_allocator(dict_t *dict, dnode_alloc_t al,
* from the tree before deleting it is required.
*/
-void dict_destroy(dict_t *dict)
+void
+dict_destroy (dict_t * dict)
{
- assert (dict_isempty(dict));
- free(dict);
+ assert (dict_isempty (dict));
+ free (dict);
}
/*
@@ -294,112 +319,117 @@ void dict_destroy(dict_t *dict)
* installed free routine. The dictionary is emptied.
*/
-void dict_free_nodes(dict_t *dict)
+void
+dict_free_nodes (dict_t * dict)
{
- dnode_t *nil = dict_nil(dict), *root = dict_root(dict);
- free_nodes(dict, root, nil);
- dict->nodecount = 0;
- dict->nilnode.left = &dict->nilnode;
- dict->nilnode.right = &dict->nilnode;
+ dnode_t *nil = dict_nil (dict), *root = dict_root (dict);
+ free_nodes (dict, root, nil);
+ dict->nodecount = 0;
+ dict->nilnode.left = &dict->nilnode;
+ dict->nilnode.right = &dict->nilnode;
}
/*
* Obsolescent function, equivalent to dict_free_nodes
*/
-void dict_free(dict_t *dict)
+void
+dict_free (dict_t * dict)
{
#ifdef KAZLIB_OBSOLESCENT_DEBUG
- assert ("call to obsolescent function dict_free()" && 0);
+ assert ("call to obsolescent function dict_free()" && 0);
#endif
- dict_free_nodes(dict);
+ dict_free_nodes (dict);
}
/*
* Initialize a user-supplied dictionary object.
*/
-dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp)
+dict_t *
+dict_init (dict_t * dict, dictcount_t maxcount, dict_comp_t comp)
{
- dict->compare = comp;
- dict->allocnode = dnode_alloc;
- dict->freenode = dnode_free;
- dict->context = NULL;
- dict->nodecount = 0;
- dict->maxcount = maxcount;
- dict->nilnode.left = &dict->nilnode;
- dict->nilnode.right = &dict->nilnode;
- dict->nilnode.parent = &dict->nilnode;
- dict->nilnode.color = dnode_black;
- dict->dupes = 0;
- return dict;
+ dict->compare = comp;
+ dict->allocnode = dnode_alloc;
+ dict->freenode = dnode_free;
+ dict->context = NULL;
+ dict->nodecount = 0;
+ dict->maxcount = maxcount;
+ dict->nilnode.left = &dict->nilnode;
+ dict->nilnode.right = &dict->nilnode;
+ dict->nilnode.parent = &dict->nilnode;
+ dict->nilnode.color = dnode_black;
+ dict->dupes = 0;
+ return dict;
}
/*
* Initialize a dictionary in the likeness of another dictionary
*/
-void dict_init_like(dict_t *dict, const dict_t *template)
+void
+dict_init_like (dict_t * dict, const dict_t * template)
{
- dict->compare = template->compare;
- dict->allocnode = template->allocnode;
- dict->freenode = template->freenode;
- dict->context = template->context;
- dict->nodecount = 0;
- dict->maxcount = template->maxcount;
- dict->nilnode.left = &dict->nilnode;
- dict->nilnode.right = &dict->nilnode;
- dict->nilnode.parent = &dict->nilnode;
- dict->nilnode.color = dnode_black;
- dict->dupes = template->dupes;
-
- assert (dict_similar(dict, template));
+ dict->compare = template->compare;
+ dict->allocnode = template->allocnode;
+ dict->freenode = template->freenode;
+ dict->context = template->context;
+ dict->nodecount = 0;
+ dict->maxcount = template->maxcount;
+ dict->nilnode.left = &dict->nilnode;
+ dict->nilnode.right = &dict->nilnode;
+ dict->nilnode.parent = &dict->nilnode;
+ dict->nilnode.color = dnode_black;
+ dict->dupes = template->dupes;
+
+ assert (dict_similar (dict, template));
}
/*
* Remove all nodes from the dictionary (without freeing them in any way).
*/
-static void dict_clear(dict_t *dict)
+static void
+dict_clear (dict_t * dict)
{
- dict->nodecount = 0;
- dict->nilnode.left = &dict->nilnode;
- dict->nilnode.right = &dict->nilnode;
- dict->nilnode.parent = &dict->nilnode;
- assert (dict->nilnode.color == dnode_black);
+ dict->nodecount = 0;
+ dict->nilnode.left = &dict->nilnode;
+ dict->nilnode.right = &dict->nilnode;
+ dict->nilnode.parent = &dict->nilnode;
+ assert (dict->nilnode.color == dnode_black);
}
-
/*
* Verify the integrity of the dictionary structure. This is provided for
* debugging purposes, and should be placed in assert statements. Just because
* this function succeeds doesn't mean that the tree is not corrupt. Certain
* corruptions in the tree may simply cause undefined behavior.
- */
+ */
-int dict_verify(dict_t *dict)
+int
+dict_verify (dict_t * dict)
{
- dnode_t *nil = dict_nil(dict), *root = dict_root(dict);
+ dnode_t *nil = dict_nil (dict), *root = dict_root (dict);
- /* check that the sentinel node and root node are black */
- if (root->color != dnode_black)
- return 0;
- if (nil->color != dnode_black)
- return 0;
- if (nil->right != nil)
- return 0;
- /* nil->left is the root node; check that its parent pointer is nil */
- if (nil->left->parent != nil)
- return 0;
- /* perform a weak test that the tree is a binary search tree */
- if (!verify_bintree(dict))
- return 0;
- /* verify that the tree is a red-black tree */
- if (!verify_redblack(nil, root))
- return 0;
- if (verify_node_count(nil, root) != dict_count(dict))
- return 0;
- return 1;
+ /* check that the sentinel node and root node are black */
+ if (root->color != dnode_black)
+ return 0;
+ if (nil->color != dnode_black)
+ return 0;
+ if (nil->right != nil)
+ return 0;
+ /* nil->left is the root node; check that its parent pointer is nil */
+ if (nil->left->parent != nil)
+ return 0;
+ /* perform a weak test that the tree is a binary search tree */
+ if (!verify_bintree (dict))
+ return 0;
+ /* verify that the tree is a red-black tree */
+ if (!verify_redblack (nil, root))
+ return 0;
+ if (verify_node_count (nil, root) != dict_count (dict))
+ return 0;
+ return 1;
}
/*
@@ -407,24 +437,25 @@ int dict_verify(dict_t *dict)
* allocator functions, and same status as to whether duplicates are allowed.
*/
-int dict_similar(const dict_t *left, const dict_t *right)
+int
+dict_similar (const dict_t * left, const dict_t * right)
{
- if (left->compare != right->compare)
- return 0;
+ if (left->compare != right->compare)
+ return 0;
- if (left->allocnode != right->allocnode)
- return 0;
+ if (left->allocnode != right->allocnode)
+ return 0;
- if (left->freenode != right->freenode)
- return 0;
+ if (left->freenode != right->freenode)
+ return 0;
- if (left->context != right->context)
- return 0;
+ if (left->context != right->context)
+ return 0;
- if (left->dupes != right->dupes)
- return 0;
+ if (left->dupes != right->dupes)
+ return 0;
- return 1;
+ return 1;
}
/*
@@ -434,37 +465,45 @@ int dict_similar(const dict_t *left, const dict_t *right)
* located node is returned.
*/
-dnode_t *dict_lookup(dict_t *dict, const void *key)
+dnode_t *
+dict_lookup (dict_t * dict, const void *key)
{
- dnode_t *root = dict_root(dict);
- dnode_t *nil = dict_nil(dict);
- dnode_t *saved;
- int result;
-
- /* simple binary search adapted for trees that contain duplicate keys */
-
- while (root != nil) {
- result = dict->compare(key, root->key);
- if (result < 0)
- root = root->left;
- else if (result > 0)
- root = root->right;
- else {
- if (!dict->dupes) { /* no duplicates, return match */
- return root;
- } else { /* could be dupes, find leftmost one */
- do {
- saved = root;
- root = root->left;
- while (root != nil && dict->compare(key, root->key))
- root = root->right;
- } while (root != nil);
- return saved;
+ dnode_t *root = dict_root (dict);
+ dnode_t *nil = dict_nil (dict);
+ dnode_t *saved;
+ int result;
+
+ /* simple binary search adapted for trees that contain duplicate keys */
+
+ while (root != nil)
+ {
+ result = dict->compare (key, root->key);
+ if (result < 0)
+ root = root->left;
+ else if (result > 0)
+ root = root->right;
+ else
+ {
+ if (!dict->dupes)
+ { /* no duplicates, return match */
+ return root;
+ }
+ else
+ { /* could be dupes, find leftmost one */
+ do
+ {
+ saved = root;
+ root = root->left;
+ while (root != nil && dict->compare (key, root->key))
+ root = root->right;
+ }
+ while (root != nil);
+ return saved;
}
}
}
- return NULL;
+ return NULL;
}
/*
@@ -472,31 +511,41 @@ dnode_t *dict_lookup(dict_t *dict, const void *key)
* greater than the given key. If there is no such node, return null.
*/
-dnode_t *dict_lower_bound(dict_t *dict, const void *key)
+dnode_t *
+dict_lower_bound (dict_t * dict, const void *key)
{
- dnode_t *root = dict_root(dict);
- dnode_t *nil = dict_nil(dict);
- dnode_t *tentative = 0;
-
- while (root != nil) {
- int result = dict->compare(key, root->key);
-
- if (result > 0) {
- root = root->right;
- } else if (result < 0) {
- tentative = root;
- root = root->left;
- } else {
- if (!dict->dupes) {
- return root;
- } else {
- tentative = root;
- root = root->left;
+ dnode_t *root = dict_root (dict);
+ dnode_t *nil = dict_nil (dict);
+ dnode_t *tentative = 0;
+
+ while (root != nil)
+ {
+ int result = dict->compare (key, root->key);
+
+ if (result > 0)
+ {
+ root = root->right;
+ }
+ else if (result < 0)
+ {
+ tentative = root;
+ root = root->left;
+ }
+ else
+ {
+ if (!dict->dupes)
+ {
+ return root;
}
- }
+ else
+ {
+ tentative = root;
+ root = root->left;
+ }
+ }
}
-
- return tentative;
+
+ return tentative;
}
/*
@@ -504,31 +553,41 @@ dnode_t *dict_lower_bound(dict_t *dict, const void *key)
* lower than the given key. If there is no such node, return null.
*/
-dnode_t *dict_upper_bound(dict_t *dict, const void *key)
+dnode_t *
+dict_upper_bound (dict_t * dict, const void *key)
{
- dnode_t *root = dict_root(dict);
- dnode_t *nil = dict_nil(dict);
- dnode_t *tentative = 0;
-
- while (root != nil) {
- int result = dict->compare(key, root->key);
-
- if (result < 0) {
- root = root->left;
- } else if (result > 0) {
- tentative = root;
- root = root->right;
- } else {
- if (!dict->dupes) {
- return root;
- } else {
- tentative = root;
- root = root->right;
+ dnode_t *root = dict_root (dict);
+ dnode_t *nil = dict_nil (dict);
+ dnode_t *tentative = 0;
+
+ while (root != nil)
+ {
+ int result = dict->compare (key, root->key);
+
+ if (result < 0)
+ {
+ root = root->left;
+ }
+ else if (result > 0)
+ {
+ tentative = root;
+ root = root->right;
+ }
+ else
+ {
+ if (!dict->dupes)
+ {
+ return root;
+ }
+ else
+ {
+ tentative = root;
+ root = root->right;
}
- }
+ }
}
-
- return tentative;
+
+ return tentative;
}
/*
@@ -539,95 +598,109 @@ dnode_t *dict_upper_bound(dict_t *dict, const void *key)
* function returns true).
*/
-void dict_insert(dict_t *dict, dnode_t *node, const void *key)
+void
+dict_insert (dict_t * dict, dnode_t * node, const void *key)
{
- dnode_t *where = dict_root(dict), *nil = dict_nil(dict);
- dnode_t *parent = nil, *uncle, *grandpa;
- int result = -1;
-
- node->key = key;
-
- assert (!dict_isfull(dict));
- assert (!dict_contains(dict, node));
- assert (!dnode_is_in_a_dict(node));
-
- /* basic binary tree insert */
-
- while (where != nil) {
- parent = where;
- result = dict->compare(key, where->key);
- /* trap attempts at duplicate key insertion unless it's explicitly allowed */
- assert (dict->dupes || result != 0);
- if (result < 0)
- where = where->left;
- else
- where = where->right;
+ dnode_t *where = dict_root (dict), *nil = dict_nil (dict);
+ dnode_t *parent = nil, *uncle, *grandpa;
+ int result = -1;
+
+ node->key = key;
+
+ assert (!dict_isfull (dict));
+ assert (!dict_contains (dict, node));
+ assert (!dnode_is_in_a_dict (node));
+
+ /* basic binary tree insert */
+
+ while (where != nil)
+ {
+ parent = where;
+ result = dict->compare (key, where->key);
+ /* trap attempts at duplicate key insertion unless it's explicitly allowed */
+ assert (dict->dupes || result != 0);
+ if (result < 0)
+ where = where->left;
+ else
+ where = where->right;
}
- assert (where == nil);
-
- if (result < 0)
- parent->left = node;
- else
- parent->right = node;
-
- node->parent = parent;
- node->left = nil;
- node->right = nil;
-
- dict->nodecount++;
-
- /* red black adjustments */
-
- node->color = dnode_red;
-
- while (parent->color == dnode_red) {
- grandpa = parent->parent;
- if (parent == grandpa->left) {
- uncle = grandpa->right;
- if (uncle->color == dnode_red) { /* red parent, red uncle */
- parent->color = dnode_black;
- uncle->color = dnode_black;
- grandpa->color = dnode_red;
- node = grandpa;
- parent = grandpa->parent;
- } else { /* red parent, black uncle */
- if (node == parent->right) {
- rotate_left(parent);
- parent = node;
- assert (grandpa == parent->parent);
- /* rotation between parent and child preserves grandpa */
+ assert (where == nil);
+
+ if (result < 0)
+ parent->left = node;
+ else
+ parent->right = node;
+
+ node->parent = parent;
+ node->left = nil;
+ node->right = nil;
+
+ dict->nodecount++;
+
+ /* red black adjustments */
+
+ node->color = dnode_red;
+
+ while (parent->color == dnode_red)
+ {
+ grandpa = parent->parent;
+ if (parent == grandpa->left)
+ {
+ uncle = grandpa->right;
+ if (uncle->color == dnode_red)
+ { /* red parent, red uncle */
+ parent->color = dnode_black;
+ uncle->color = dnode_black;
+ grandpa->color = dnode_red;
+ node = grandpa;
+ parent = grandpa->parent;
+ }
+ else
+ { /* red parent, black uncle */
+ if (node == parent->right)
+ {
+ rotate_left (parent);
+ parent = node;
+ assert (grandpa == parent->parent);
+ /* rotation between parent and child preserves grandpa */
}
- parent->color = dnode_black;
- grandpa->color = dnode_red;
- rotate_right(grandpa);
- break;
+ parent->color = dnode_black;
+ grandpa->color = dnode_red;
+ rotate_right (grandpa);
+ break;
+ }
+ }
+ else
+ { /* symmetric cases: parent == parent->parent->right */
+ uncle = grandpa->left;
+ if (uncle->color == dnode_red)
+ {
+ parent->color = dnode_black;
+ uncle->color = dnode_black;
+ grandpa->color = dnode_red;
+ node = grandpa;
+ parent = grandpa->parent;
}
- } else { /* symmetric cases: parent == parent->parent->right */
- uncle = grandpa->left;
- if (uncle->color == dnode_red) {
- parent->color = dnode_black;
- uncle->color = dnode_black;
- grandpa->color = dnode_red;
- node = grandpa;
- parent = grandpa->parent;
- } else {
- if (node == parent->left) {
- rotate_right(parent);
- parent = node;
- assert (grandpa == parent->parent);
+ else
+ {
+ if (node == parent->left)
+ {
+ rotate_right (parent);
+ parent = node;
+ assert (grandpa == parent->parent);
}
- parent->color = dnode_black;
- grandpa->color = dnode_red;
- rotate_left(grandpa);
- break;
+ parent->color = dnode_black;
+ grandpa->color = dnode_red;
+ rotate_left (grandpa);
+ break;
}
}
}
- dict_root(dict)->color = dnode_black;
+ dict_root (dict)->color = dnode_black;
- assert (dict_verify(dict));
+ assert (dict_verify (dict));
}
/*
@@ -636,173 +709,201 @@ void dict_insert(dict_t *dict, dnode_t *node, const void *key)
* deleted node is returned.
*/
-dnode_t *dict_delete(dict_t *dict, dnode_t *delete)
+dnode_t *
+dict_delete (dict_t * dict, dnode_t * delete)
{
- dnode_t *nil = dict_nil(dict), *child, *delparent = delete->parent;
-
- /* basic deletion */
-
- assert (!dict_isempty(dict));
- assert (dict_contains(dict, delete));
-
- /*
- * If the node being deleted has two children, then we replace it with its
- * successor (i.e. the leftmost node in the right subtree.) By doing this,
- * we avoid the traditional algorithm under which the successor's key and
- * value *only* move to the deleted node and the successor is spliced out
- * from the tree. We cannot use this approach because the user may hold
- * pointers to the successor, or nodes may be inextricably tied to some
- * other structures by way of embedding, etc. So we must splice out the
- * node we are given, not some other node, and must not move contents from
- * one node to another behind the user's back.
- */
-
- if (delete->left != nil && delete->right != nil) {
- dnode_t *next = dict_next(dict, delete);
- dnode_t *nextparent = next->parent;
- dnode_color_t nextcolor = next->color;
-
- assert (next != nil);
- assert (next->parent != nil);
- assert (next->left == nil);
-
- /*
- * First, splice out the successor from the tree completely, by
- * moving up its right child into its place.
- */
-
- child = next->right;
- child->parent = nextparent;
-
- if (nextparent->left == next) {
- nextparent->left = child;
- } else {
- assert (nextparent->right == next);
- nextparent->right = child;
+ dnode_t *nil = dict_nil (dict), *child, *delparent = delete->parent;
+
+ /* basic deletion */
+
+ assert (!dict_isempty (dict));
+ assert (dict_contains (dict, delete));
+
+ /*
+ * If the node being deleted has two children, then we replace it with its
+ * successor (i.e. the leftmost node in the right subtree.) By doing this,
+ * we avoid the traditional algorithm under which the successor's key and
+ * value *only* move to the deleted node and the successor is spliced out
+ * from the tree. We cannot use this approach because the user may hold
+ * pointers to the successor, or nodes may be inextricably tied to some
+ * other structures by way of embedding, etc. So we must splice out the
+ * node we are given, not some other node, and must not move contents from
+ * one node to another behind the user's back.
+ */
+
+ if (delete->left != nil && delete->right != nil)
+ {
+ dnode_t *next = dict_next (dict, delete);
+ dnode_t *nextparent = next->parent;
+ dnode_color_t nextcolor = next->color;
+
+ assert (next != nil);
+ assert (next->parent != nil);
+ assert (next->left == nil);
+
+ /*
+ * First, splice out the successor from the tree completely, by
+ * moving up its right child into its place.
+ */
+
+ child = next->right;
+ child->parent = nextparent;
+
+ if (nextparent->left == next)
+ {
+ nextparent->left = child;
}
+ else
+ {
+ assert (nextparent->right == next);
+ nextparent->right = child;
+ }
+
+ /*
+ * Now that the successor has been extricated from the tree, install it
+ * in place of the node that we want deleted.
+ */
- /*
- * Now that the successor has been extricated from the tree, install it
- * in place of the node that we want deleted.
- */
-
- next->parent = delparent;
- next->left = delete->left;
- next->right = delete->right;
- next->left->parent = next;
- next->right->parent = next;
- next->color = delete->color;
- delete->color = nextcolor;
-
- if (delparent->left == delete) {
- delparent->left = next;
- } else {
- assert (delparent->right == delete);
- delparent->right = next;
+ next->parent = delparent;
+ next->left = delete->left;
+ next->right = delete->right;
+ next->left->parent = next;
+ next->right->parent = next;
+ next->color = delete->color;
+ delete->color = nextcolor;
+
+ if (delparent->left == delete)
+ {
+ delparent->left = next;
+ }
+ else
+ {
+ assert (delparent->right == delete);
+ delparent->right = next;
}
- } else {
- assert (delete != nil);
- assert (delete->left == nil || delete->right == nil);
+ }
+ else
+ {
+ assert (delete != nil);
+ assert (delete->left == nil || delete->right == nil);
- child = (delete->left != nil) ? delete->left : delete->right;
+ child = (delete->left != nil) ? delete->left : delete->right;
- child->parent = delparent = delete->parent;
+ child->parent = delparent = delete->parent;
- if (delete == delparent->left) {
- delparent->left = child;
- } else {
- assert (delete == delparent->right);
- delparent->right = child;
+ if (delete == delparent->left)
+ {
+ delparent->left = child;
+ }
+ else
+ {
+ assert (delete == delparent->right);
+ delparent->right = child;
}
}
- delete->parent = NULL;
- delete->right = NULL;
- delete->left = NULL;
+ delete->parent = NULL;
+ delete->right = NULL;
+ delete->left = NULL;
- dict->nodecount--;
+ dict->nodecount--;
- assert (verify_bintree(dict));
+ assert (verify_bintree (dict));
- /* red-black adjustments */
+ /* red-black adjustments */
- if (delete->color == dnode_black) {
- dnode_t *parent, *sister;
+ if (delete->color == dnode_black)
+ {
+ dnode_t *parent, *sister;
- dict_root(dict)->color = dnode_red;
+ dict_root (dict)->color = dnode_red;
- while (child->color == dnode_black) {
- parent = child->parent;
- if (child == parent->left) {
- sister = parent->right;
- assert (sister != nil);
- if (sister->color == dnode_red) {
- sister->color = dnode_black;
- parent->color = dnode_red;
- rotate_left(parent);
- sister = parent->right;
- assert (sister != nil);
+ while (child->color == dnode_black)
+ {
+ parent = child->parent;
+ if (child == parent->left)
+ {
+ sister = parent->right;
+ assert (sister != nil);
+ if (sister->color == dnode_red)
+ {
+ sister->color = dnode_black;
+ parent->color = dnode_red;
+ rotate_left (parent);
+ sister = parent->right;
+ assert (sister != nil);
+ }
+ if (sister->left->color == dnode_black
+ && sister->right->color == dnode_black)
+ {
+ sister->color = dnode_red;
+ child = parent;
}
- if (sister->left->color == dnode_black
- && sister->right->color == dnode_black) {
- sister->color = dnode_red;
- child = parent;
- } else {
- if (sister->right->color == dnode_black) {
- assert (sister->left->color == dnode_red);
- sister->left->color = dnode_black;
- sister->color = dnode_red;
- rotate_right(sister);
- sister = parent->right;
- assert (sister != nil);
+ else
+ {
+ if (sister->right->color == dnode_black)
+ {
+ assert (sister->left->color == dnode_red);
+ sister->left->color = dnode_black;
+ sister->color = dnode_red;
+ rotate_right (sister);
+ sister = parent->right;
+ assert (sister != nil);
}
- sister->color = parent->color;
- sister->right->color = dnode_black;
- parent->color = dnode_black;
- rotate_left(parent);
- break;
+ sister->color = parent->color;
+ sister->right->color = dnode_black;
+ parent->color = dnode_black;
+ rotate_left (parent);
+ break;
}
- } else { /* symmetric case: child == child->parent->right */
- assert (child == parent->right);
- sister = parent->left;
- assert (sister != nil);
- if (sister->color == dnode_red) {
- sister->color = dnode_black;
- parent->color = dnode_red;
- rotate_right(parent);
- sister = parent->left;
- assert (sister != nil);
+ }
+ else
+ { /* symmetric case: child == child->parent->right */
+ assert (child == parent->right);
+ sister = parent->left;
+ assert (sister != nil);
+ if (sister->color == dnode_red)
+ {
+ sister->color = dnode_black;
+ parent->color = dnode_red;
+ rotate_right (parent);
+ sister = parent->left;
+ assert (sister != nil);
+ }
+ if (sister->right->color == dnode_black
+ && sister->left->color == dnode_black)
+ {
+ sister->color = dnode_red;
+ child = parent;
}
- if (sister->right->color == dnode_black
- && sister->left->color == dnode_black) {
- sister->color = dnode_red;
- child = parent;
- } else {
- if (sister->left->color == dnode_black) {
- assert (sister->right->color == dnode_red);
- sister->right->color = dnode_black;
- sister->color = dnode_red;
- rotate_left(sister);
- sister = parent->left;
- assert (sister != nil);
+ else
+ {
+ if (sister->left->color == dnode_black)
+ {
+ assert (sister->right->color == dnode_red);
+ sister->right->color = dnode_black;
+ sister->color = dnode_red;
+ rotate_left (sister);
+ sister = parent->left;
+ assert (sister != nil);
}
- sister->color = parent->color;
- sister->left->color = dnode_black;
- parent->color = dnode_black;
- rotate_right(parent);
- break;
+ sister->color = parent->color;
+ sister->left->color = dnode_black;
+ parent->color = dnode_black;
+ rotate_right (parent);
+ break;
}
}
}
- child->color = dnode_black;
- dict_root(dict)->color = dnode_black;
+ child->color = dnode_black;
+ dict_root (dict)->color = dnode_black;
}
- assert (dict_verify(dict));
+ assert (dict_verify (dict));
- return delete;
+ return delete;
}
/*
@@ -810,22 +911,25 @@ dnode_t *dict_delete(dict_t *dict, dnode_t *delete)
* the data item.
*/
-int dict_alloc_insert(dict_t *dict, const void *key, void *data)
+int
+dict_alloc_insert (dict_t * dict, const void *key, void *data)
{
- dnode_t *node = dict->allocnode(dict->context);
+ dnode_t *node = dict->allocnode (dict->context);
- if (node) {
- dnode_init(node, data);
- dict_insert(dict, node, key);
- return 1;
+ if (node)
+ {
+ dnode_init (node, data);
+ dict_insert (dict, node, key);
+ return 1;
}
- return 0;
+ return 0;
}
-void dict_delete_free(dict_t *dict, dnode_t *node)
+void
+dict_delete_free (dict_t * dict, dnode_t * node)
{
- dict_delete(dict, node);
- dict->freenode(node, dict->context);
+ dict_delete (dict, node);
+ dict->freenode (node, dict->context);
}
/*
@@ -833,15 +937,16 @@ void dict_delete_free(dict_t *dict, dnode_t *node)
* (that is, dict_isempty(dict) returns 1) a null pointer is returned.
*/
-dnode_t *dict_first(dict_t *dict)
+dnode_t *
+dict_first (dict_t * dict)
{
- dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left;
+ dnode_t *nil = dict_nil (dict), *root = dict_root (dict), *left;
- if (root != nil)
- while ((left = root->left) != nil)
- root = left;
+ if (root != nil)
+ while ((left = root->left) != nil)
+ root = left;
- return (root == nil) ? NULL : root;
+ return (root == nil) ? NULL : root;
}
/*
@@ -849,15 +954,16 @@ dnode_t *dict_first(dict_t *dict)
* (that is, dict_isempty(dict) returns 1) a null pointer is returned.
*/
-dnode_t *dict_last(dict_t *dict)
+dnode_t *
+dict_last (dict_t * dict)
{
- dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *right;
+ dnode_t *nil = dict_nil (dict), *root = dict_root (dict), *right;
- if (root != nil)
- while ((right = root->right) != nil)
- root = right;
+ if (root != nil)
+ while ((right = root->right) != nil)
+ root = right;
- return (root == nil) ? NULL : root;
+ return (root == nil) ? NULL : root;
}
/*
@@ -867,25 +973,28 @@ dnode_t *dict_last(dict_t *dict)
* the nil node.
*/
-dnode_t *dict_next(dict_t *dict, dnode_t *curr)
+dnode_t *
+dict_next (dict_t * dict, dnode_t * curr)
{
- dnode_t *nil = dict_nil(dict), *parent, *left;
-
- if (curr->right != nil) {
- curr = curr->right;
- while ((left = curr->left) != nil)
- curr = left;
- return curr;
+ dnode_t *nil = dict_nil (dict), *parent, *left;
+
+ if (curr->right != nil)
+ {
+ curr = curr->right;
+ while ((left = curr->left) != nil)
+ curr = left;
+ return curr;
}
- parent = curr->parent;
+ parent = curr->parent;
- while (parent != nil && curr == parent->right) {
- curr = parent;
- parent = curr->parent;
+ while (parent != nil && curr == parent->right)
+ {
+ curr = parent;
+ parent = curr->parent;
}
- return (parent == nil) ? NULL : parent;
+ return (parent == nil) ? NULL : parent;
}
/*
@@ -893,30 +1002,34 @@ dnode_t *dict_next(dict_t *dict, dnode_t *curr)
* The nil sentinel node is returned if there is no predecessor.
*/
-dnode_t *dict_prev(dict_t *dict, dnode_t *curr)
+dnode_t *
+dict_prev (dict_t * dict, dnode_t * curr)
{
- dnode_t *nil = dict_nil(dict), *parent, *right;
-
- if (curr->left != nil) {
- curr = curr->left;
- while ((right = curr->right) != nil)
- curr = right;
- return curr;
+ dnode_t *nil = dict_nil (dict), *parent, *right;
+
+ if (curr->left != nil)
+ {
+ curr = curr->left;
+ while ((right = curr->right) != nil)
+ curr = right;
+ return curr;
}
- parent = curr->parent;
+ parent = curr->parent;
- while (parent != nil && curr == parent->left) {
- curr = parent;
- parent = curr->parent;
+ while (parent != nil && curr == parent->left)
+ {
+ curr = parent;
+ parent = curr->parent;
}
- return (parent == nil) ? NULL : parent;
+ return (parent == nil) ? NULL : parent;
}
-void dict_allow_dupes(dict_t *dict)
+void
+dict_allow_dupes (dict_t * dict)
{
- dict->dupes = 1;
+ dict->dupes = 1;
}
#undef dict_count
@@ -926,268 +1039,308 @@ void dict_allow_dupes(dict_t *dict)
#undef dnode_put
#undef dnode_getkey
-dictcount_t dict_count(dict_t *dict)
+dictcount_t
+dict_count (dict_t * dict)
{
- return dict->nodecount;
+ return dict->nodecount;
}
-int dict_isempty(dict_t *dict)
+int
+dict_isempty (dict_t * dict)
{
- return dict->nodecount == 0;
+ return dict->nodecount == 0;
}
-int dict_isfull(dict_t *dict)
+int
+dict_isfull (dict_t * dict)
{
- return dict->nodecount == dict->maxcount;
+ return dict->nodecount == dict->maxcount;
}
-int dict_contains(dict_t *dict, dnode_t *node)
+int
+dict_contains (dict_t * dict, dnode_t * node)
{
- return verify_dict_has_node(dict_nil(dict), dict_root(dict), node);
+ return verify_dict_has_node (dict_nil (dict), dict_root (dict), node);
}
-static dnode_t *dnode_alloc(void *context)
+static dnode_t *
+dnode_alloc (void *context)
{
- return malloc(sizeof *dnode_alloc(NULL));
+ return malloc (sizeof *dnode_alloc (NULL));
}
-static void dnode_free(dnode_t *node, void *context)
+static void
+dnode_free (dnode_t * node, void *context)
{
- free(node);
+ free (node);
}
-dnode_t *dnode_create(void *data)
+dnode_t *
+dnode_create (void *data)
{
- dnode_t *new = malloc(sizeof *new);
- if (new) {
- new->data = data;
- new->parent = NULL;
- new->left = NULL;
- new->right = NULL;
+ dnode_t *new = malloc (sizeof *new);
+ if (new)
+ {
+ new->data = data;
+ new->parent = NULL;
+ new->left = NULL;
+ new->right = NULL;
}
- return new;
+ return new;
}
-dnode_t *dnode_init(dnode_t *dnode, void *data)
+dnode_t *
+dnode_init (dnode_t * dnode, void *data)
{
- dnode->data = data;
- dnode->parent = NULL;
- dnode->left = NULL;
- dnode->right = NULL;
- return dnode;
+ dnode->data = data;
+ dnode->parent = NULL;
+ dnode->left = NULL;
+ dnode->right = NULL;
+ return dnode;
}
-void dnode_destroy(dnode_t *dnode)
+void
+dnode_destroy (dnode_t * dnode)
{
- assert (!dnode_is_in_a_dict(dnode));
- free(dnode);
+ assert (!dnode_is_in_a_dict (dnode));
+ free (dnode);
}
-void *dnode_get(dnode_t *dnode)
+void *
+dnode_get (dnode_t * dnode)
{
- return dnode->data;
+ return dnode->data;
}
-const void *dnode_getkey(dnode_t *dnode)
+const void *
+dnode_getkey (dnode_t * dnode)
{
- return dnode->key;
+ return dnode->key;
}
-void dnode_put(dnode_t *dnode, void *data)
+void
+dnode_put (dnode_t * dnode, void *data)
{
- dnode->data = data;
+ dnode->data = data;
}
-int dnode_is_in_a_dict(dnode_t *dnode)
+int
+dnode_is_in_a_dict (dnode_t * dnode)
{
- return (dnode->parent && dnode->left && dnode->right);
+ return (dnode->parent && dnode->left && dnode->right);
}
-void dict_process(dict_t *dict, void *context, dnode_process_t function)
+void
+dict_process (dict_t * dict, void *context, dnode_process_t function)
{
- dnode_t *node = dict_first(dict), *next;
-
- while (node != NULL) {
- /* check for callback function deleting */
- /* the next node from under us */
- assert (dict_contains(dict, node));
- next = dict_next(dict, node);
- function(dict, node, context);
- node = next;
+ dnode_t *node = dict_first (dict), *next;
+
+ while (node != NULL)
+ {
+ /* check for callback function deleting */
+ /* the next node from under us */
+ assert (dict_contains (dict, node));
+ next = dict_next (dict, node);
+ function (dict, node, context);
+ node = next;
}
}
-static void load_begin_internal(dict_load_t *load, dict_t *dict)
+static void
+load_begin_internal (dict_load_t * load, dict_t * dict)
{
- load->dictptr = dict;
- load->nilnode.left = &load->nilnode;
- load->nilnode.right = &load->nilnode;
+ load->dictptr = dict;
+ load->nilnode.left = &load->nilnode;
+ load->nilnode.right = &load->nilnode;
}
-void dict_load_begin(dict_load_t *load, dict_t *dict)
+void
+dict_load_begin (dict_load_t * load, dict_t * dict)
{
- assert (dict_isempty(dict));
- load_begin_internal(load, dict);
+ assert (dict_isempty (dict));
+ load_begin_internal (load, dict);
}
-void dict_load_next(dict_load_t *load, dnode_t *newnode, const void *key)
+void
+dict_load_next (dict_load_t * load, dnode_t * newnode, const void *key)
{
- dict_t *dict = load->dictptr;
- dnode_t *nil = &load->nilnode;
-
- assert (!dnode_is_in_a_dict(newnode));
- assert (dict->nodecount < dict->maxcount);
-
- #ifndef NDEBUG
- if (dict->nodecount > 0) {
- if (dict->dupes)
- assert (dict->compare(nil->left->key, key) <= 0);
- else
- assert (dict->compare(nil->left->key, key) < 0);
+ dict_t *dict = load->dictptr;
+ dnode_t *nil = &load->nilnode;
+
+ assert (!dnode_is_in_a_dict (newnode));
+ assert (dict->nodecount < dict->maxcount);
+
+#ifndef NDEBUG
+ if (dict->nodecount > 0)
+ {
+ if (dict->dupes)
+ assert (dict->compare (nil->left->key, key) <= 0);
+ else
+ assert (dict->compare (nil->left->key, key) < 0);
}
- #endif
+#endif
- newnode->key = key;
- nil->right->left = newnode;
- nil->right = newnode;
- newnode->left = nil;
- dict->nodecount++;
+ newnode->key = key;
+ nil->right->left = newnode;
+ nil->right = newnode;
+ newnode->left = nil;
+ dict->nodecount++;
}
-void dict_load_end(dict_load_t *load)
+void
+dict_load_end (dict_load_t * load)
{
- dict_t *dict = load->dictptr;
- dnode_t *tree[DICT_DEPTH_MAX] = { 0 };
- dnode_t *curr, *dictnil = dict_nil(dict), *loadnil = &load->nilnode, *next;
- dnode_t *complete = 0;
- dictcount_t fullcount = DICTCOUNT_T_MAX, nodecount = dict->nodecount;
- dictcount_t botrowcount;
- unsigned baselevel = 0, level = 0, i;
-
- assert (dnode_red == 0 && dnode_black == 1);
-
- while (fullcount >= nodecount && fullcount)
- fullcount >>= 1;
-
- botrowcount = nodecount - fullcount;
-
- for (curr = loadnil->left; curr != loadnil; curr = next) {
- next = curr->left;
-
- if (complete == NULL && botrowcount-- == 0) {
- assert (baselevel == 0);
- assert (level == 0);
- baselevel = level = 1;
- complete = tree[0];
-
- if (complete != 0) {
- tree[0] = 0;
- complete->right = dictnil;
- while (tree[level] != 0) {
- tree[level]->right = complete;
- complete->parent = tree[level];
- complete = tree[level];
- tree[level++] = 0;
+ dict_t *dict = load->dictptr;
+ dnode_t *tree[DICT_DEPTH_MAX] = { 0 };
+ dnode_t *curr, *dictnil = dict_nil (dict), *loadnil = &load->nilnode, *next;
+ dnode_t *complete = 0;
+ dictcount_t fullcount = DICTCOUNT_T_MAX, nodecount = dict->nodecount;
+ dictcount_t botrowcount;
+ unsigned baselevel = 0, level = 0, i;
+
+ assert (dnode_red == 0 && dnode_black == 1);
+
+ while (fullcount >= nodecount && fullcount)
+ fullcount >>= 1;
+
+ botrowcount = nodecount - fullcount;
+
+ for (curr = loadnil->left; curr != loadnil; curr = next)
+ {
+ next = curr->left;
+
+ if (complete == NULL && botrowcount-- == 0)
+ {
+ assert (baselevel == 0);
+ assert (level == 0);
+ baselevel = level = 1;
+ complete = tree[0];
+
+ if (complete != 0)
+ {
+ tree[0] = 0;
+ complete->right = dictnil;
+ while (tree[level] != 0)
+ {
+ tree[level]->right = complete;
+ complete->parent = tree[level];
+ complete = tree[level];
+ tree[level++] = 0;
}
}
}
- if (complete == NULL) {
- curr->left = dictnil;
- curr->right = dictnil;
- curr->color = level % 2;
- complete = curr;
-
- assert (level == baselevel);
- while (tree[level] != 0) {
- tree[level]->right = complete;
- complete->parent = tree[level];
- complete = tree[level];
- tree[level++] = 0;
+ if (complete == NULL)
+ {
+ curr->left = dictnil;
+ curr->right = dictnil;
+ curr->color = level % 2;
+ complete = curr;
+
+ assert (level == baselevel);
+ while (tree[level] != 0)
+ {
+ tree[level]->right = complete;
+ complete->parent = tree[level];
+ complete = tree[level];
+ tree[level++] = 0;
}
- } else {
- curr->left = complete;
- curr->color = (level + 1) % 2;
- complete->parent = curr;
- tree[level] = curr;
- complete = 0;
- level = baselevel;
+ }
+ else
+ {
+ curr->left = complete;
+ curr->color = (level + 1) % 2;
+ complete->parent = curr;
+ tree[level] = curr;
+ complete = 0;
+ level = baselevel;
}
}
- if (complete == NULL)
- complete = dictnil;
+ if (complete == NULL)
+ complete = dictnil;
- for (i = 0; i < DICT_DEPTH_MAX; i++) {
- if (tree[i] != 0) {
- tree[i]->right = complete;
- complete->parent = tree[i];
- complete = tree[i];
+ for (i = 0; i < DICT_DEPTH_MAX; i++)
+ {
+ if (tree[i] != 0)
+ {
+ tree[i]->right = complete;
+ complete->parent = tree[i];
+ complete = tree[i];
}
}
- dictnil->color = dnode_black;
- dictnil->right = dictnil;
- complete->parent = dictnil;
- complete->color = dnode_black;
- dict_root(dict) = complete;
+ dictnil->color = dnode_black;
+ dictnil->right = dictnil;
+ complete->parent = dictnil;
+ complete->color = dnode_black;
+ dict_root (dict) = complete;
- assert (dict_verify(dict));
+ assert (dict_verify (dict));
}
-void dict_merge(dict_t *dest, dict_t *source)
+void
+dict_merge (dict_t * dest, dict_t * source)
{
- dict_load_t load;
- dnode_t *leftnode = dict_first(dest), *rightnode = dict_first(source);
+ dict_load_t load;
+ dnode_t *leftnode = dict_first (dest), *rightnode = dict_first (source);
- assert (dict_similar(dest, source));
+ assert (dict_similar (dest, source));
- if (source == dest)
- return;
+ if (source == dest)
+ return;
- dest->nodecount = 0;
- load_begin_internal(&load, dest);
+ dest->nodecount = 0;
+ load_begin_internal (&load, dest);
- for (;;) {
- if (leftnode != NULL && rightnode != NULL) {
- if (dest->compare(leftnode->key, rightnode->key) < 0)
- goto copyleft;
- else
- goto copyright;
- } else if (leftnode != NULL) {
+ for (;;)
+ {
+ if (leftnode != NULL && rightnode != NULL)
+ {
+ if (dest->compare (leftnode->key, rightnode->key) < 0)
goto copyleft;
- } else if (rightnode != NULL) {
+ else
goto copyright;
- } else {
- assert (leftnode == NULL && rightnode == NULL);
- break;
}
-
- copyleft:
+ else if (leftnode != NULL)
{
- dnode_t *next = dict_next(dest, leftnode);
- #ifndef NDEBUG
- leftnode->left = NULL; /* suppress assertion in dict_load_next */
- #endif
- dict_load_next(&load, leftnode, leftnode->key);
- leftnode = next;
- continue;
+ goto copyleft;
}
-
- copyright:
+ else if (rightnode != NULL)
+ {
+ goto copyright;
+ }
+ else
{
- dnode_t *next = dict_next(source, rightnode);
- #ifndef NDEBUG
- rightnode->left = NULL;
- #endif
- dict_load_next(&load, rightnode, rightnode->key);
- rightnode = next;
- continue;
+ assert (leftnode == NULL && rightnode == NULL);
+ break;
}
+
+ copyleft:
+ {
+ dnode_t *next = dict_next (dest, leftnode);
+#ifndef NDEBUG
+ leftnode->left = NULL; /* suppress assertion in dict_load_next */
+#endif
+ dict_load_next (&load, leftnode, leftnode->key);
+ leftnode = next;
+ continue;
+ }
+
+ copyright:
+ {
+ dnode_t *next = dict_next (source, rightnode);
+#ifndef NDEBUG
+ rightnode->left = NULL;
+#endif
+ dict_load_next (&load, rightnode, rightnode->key);
+ rightnode = next;
+ continue;
+ }
}
- dict_clear(source);
- dict_load_end(&load);
+ dict_clear (source);
+ dict_load_end (&load);
}
#ifdef KAZLIB_TEST_MAIN
@@ -1199,298 +1352,329 @@ void dict_merge(dict_t *dest, dict_t *source)
typedef char input_t[256];
-static int tokenize(char *string, ...)
+static int
+tokenize (char *string, ...)
{
- char **tokptr;
- va_list arglist;
- int tokcount = 0;
-
- va_start(arglist, string);
- tokptr = va_arg(arglist, char **);
- while (tokptr) {
- while (*string && isspace((unsigned char) *string))
- string++;
- if (!*string)
- break;
- *tokptr = string;
- while (*string && !isspace((unsigned char) *string))
- string++;
- tokptr = va_arg(arglist, char **);
- tokcount++;
- if (!*string)
- break;
- *string++ = 0;
+ char **tokptr;
+ va_list arglist;
+ int tokcount = 0;
+
+ va_start (arglist, string);
+ tokptr = va_arg (arglist, char **);
+ while (tokptr)
+ {
+ while (*string && isspace ((unsigned char) *string))
+ string++;
+ if (!*string)
+ break;
+ *tokptr = string;
+ while (*string && !isspace ((unsigned char) *string))
+ string++;
+ tokptr = va_arg (arglist, char **);
+ tokcount++;
+ if (!*string)
+ break;
+ *string++ = 0;
}
- va_end(arglist);
+ va_end (arglist);
- return tokcount;
+ return tokcount;
}
-static int comparef(const void *key1, const void *key2)
+static int
+comparef (const void *key1, const void *key2)
{
- return strcmp(key1, key2);
+ return strcmp (key1, key2);
}
-static char *dupstring(char *str)
+static char *
+dupstring (char *str)
{
- int sz = strlen(str) + 1;
- char *new = malloc(sz);
- if (new)
- memcpy(new, str, sz);
- return new;
+ int sz = strlen (str) + 1;
+ char *new = malloc (sz);
+ if (new)
+ memcpy (new, str, sz);
+ return new;
}
-static dnode_t *new_node(void *c)
+static dnode_t *
+new_node (void *c)
{
- static dnode_t few[5];
- static int count;
+ static dnode_t few[5];
+ static int count;
- if (count < 5)
- return few + count++;
+ if (count < 5)
+ return few + count++;
- return NULL;
+ return NULL;
}
-static void del_node(dnode_t *n, void *c)
+static void
+del_node (dnode_t * n, void *c)
{
}
static int prompt = 0;
-static void construct(dict_t *d)
+static void
+construct (dict_t * d)
{
- input_t in;
- int done = 0;
- dict_load_t dl;
- dnode_t *dn;
- char *tok1, *tok2, *val;
- const char *key;
- char *help =
- "p turn prompt on\n"
- "q finish construction\n"
- "a <key> <val> add new entry\n";
-
- if (!dict_isempty(d))
- puts("warning: dictionary not empty!");
-
- dict_load_begin(&dl, d);
-
- while (!done) {
- if (prompt)
- putchar('>');
- fflush(stdout);
-
- if (!fgets(in, sizeof(input_t), stdin))
- break;
-
- switch (in[0]) {
- case '?':
- puts(help);
- break;
- case 'p':
- prompt = 1;
- break;
- case 'q':
- done = 1;
- break;
- case 'a':
- if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) {
- puts("what?");
- break;
- }
- key = dupstring(tok1);
- val = dupstring(tok2);
- dn = dnode_create(val);
-
- if (!key || !val || !dn) {
- puts("out of memory");
- free((void *) key);
- free(val);
- if (dn)
- dnode_destroy(dn);
- }
+ input_t in;
+ int done = 0;
+ dict_load_t dl;
+ dnode_t *dn;
+ char *tok1, *tok2, *val;
+ const char *key;
+ char *help =
+ "p turn prompt on\n"
+ "q finish construction\n"
+ "a <key> <val> add new entry\n";
+
+ if (!dict_isempty (d))
+ puts ("warning: dictionary not empty!");
+
+ dict_load_begin (&dl, d);
+
+ while (!done)
+ {
+ if (prompt)
+ putchar ('>');
+ fflush (stdout);
+
+ if (!fgets (in, sizeof (input_t), stdin))
+ break;
+
+ switch (in[0])
+ {
+ case '?':
+ puts (help);
+ break;
+ case 'p':
+ prompt = 1;
+ break;
+ case 'q':
+ done = 1;
+ break;
+ case 'a':
+ if (tokenize (in + 1, &tok1, &tok2, (char **) 0) != 2)
+ {
+ puts ("what?");
+ break;
+ }
+ key = dupstring (tok1);
+ val = dupstring (tok2);
+ dn = dnode_create (val);
+
+ if (!key || !val || !dn)
+ {
+ puts ("out of memory");
+ free ((void *) key);
+ free (val);
+ if (dn)
+ dnode_destroy (dn);
+ }
- dict_load_next(&dl, dn, key);
- break;
- default:
- putchar('?');
- putchar('\n');
- break;
+ dict_load_next (&dl, dn, key);
+ break;
+ default:
+ putchar ('?');
+ putchar ('\n');
+ break;
}
}
- dict_load_end(&dl);
+ dict_load_end (&dl);
}
-int main(void)
+int
+main (void)
{
- input_t in;
- dict_t darray[10];
- dict_t *d = &darray[0];
- dnode_t *dn;
- int i;
- char *tok1, *tok2, *val;
- const char *key;
-
- char *help =
- "a <key> <val> add value to dictionary\n"
- "d <key> delete value from dictionary\n"
- "l <key> lookup value in dictionary\n"
- "( <key> lookup lower bound\n"
- ") <key> lookup upper bound\n"
- "# <num> switch to alternate dictionary (0-9)\n"
- "j <num> <num> merge two dictionaries\n"
- "f free the whole dictionary\n"
- "k allow duplicate keys\n"
- "c show number of entries\n"
- "t dump whole dictionary in sort order\n"
- "m make dictionary out of sorted items\n"
- "p turn prompt on\n"
- "s switch to non-functioning allocator\n"
- "q quit";
-
- for (i = 0; i < sizeof darray / sizeof *darray; i++)
- dict_init(&darray[i], DICTCOUNT_T_MAX, comparef);
-
- for (;;) {
- if (prompt)
- putchar('>');
- fflush(stdout);
-
- if (!fgets(in, sizeof(input_t), stdin))
- break;
-
- switch(in[0]) {
- case '?':
- puts(help);
- break;
- case 'a':
- if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) {
- puts("what?");
- break;
- }
- key = dupstring(tok1);
- val = dupstring(tok2);
-
- if (!key || !val) {
- puts("out of memory");
- free((void *) key);
- free(val);
- }
+ input_t in;
+ dict_t darray[10];
+ dict_t *d = &darray[0];
+ dnode_t *dn;
+ int i;
+ char *tok1, *tok2, *val;
+ const char *key;
+
+ char *help =
+ "a <key> <val> add value to dictionary\n"
+ "d <key> delete value from dictionary\n"
+ "l <key> lookup value in dictionary\n"
+ "( <key> lookup lower bound\n"
+ ") <key> lookup upper bound\n"
+ "# <num> switch to alternate dictionary (0-9)\n"
+ "j <num> <num> merge two dictionaries\n"
+ "f free the whole dictionary\n"
+ "k allow duplicate keys\n"
+ "c show number of entries\n"
+ "t dump whole dictionary in sort order\n"
+ "m make dictionary out of sorted items\n"
+ "p turn prompt on\n"
+ "s switch to non-functioning allocator\n"
+ "q quit";
+
+ for (i = 0; i < sizeof darray / sizeof *darray; i++)
+ dict_init (&darray[i], DICTCOUNT_T_MAX, comparef);
+
+ for (;;)
+ {
+ if (prompt)
+ putchar ('>');
+ fflush (stdout);
+
+ if (!fgets (in, sizeof (input_t), stdin))
+ break;
+
+ switch (in[0])
+ {
+ case '?':
+ puts (help);
+ break;
+ case 'a':
+ if (tokenize (in + 1, &tok1, &tok2, (char **) 0) != 2)
+ {
+ puts ("what?");
+ break;
+ }
+ key = dupstring (tok1);
+ val = dupstring (tok2);
+
+ if (!key || !val)
+ {
+ puts ("out of memory");
+ free ((void *) key);
+ free (val);
+ }
- if (!dict_alloc_insert(d, key, val)) {
- puts("dict_alloc_insert failed");
- free((void *) key);
- free(val);
- break;
- }
- break;
- case 'd':
- if (tokenize(in+1, &tok1, (char **) 0) != 1) {
- puts("what?");
- break;
- }
- dn = dict_lookup(d, tok1);
- if (!dn) {
- puts("dict_lookup failed");
- break;
- }
- val = dnode_get(dn);
- key = dnode_getkey(dn);
- dict_delete_free(d, dn);
-
- free(val);
- free((void *) key);
- break;
- case 'f':
- dict_free(d);
- break;
+ if (!dict_alloc_insert (d, key, val))
+ {
+ puts ("dict_alloc_insert failed");
+ free ((void *) key);
+ free (val);
+ break;
+ }
+ break;
+ case 'd':
+ if (tokenize (in + 1, &tok1, (char **) 0) != 1)
+ {
+ puts ("what?");
+ break;
+ }
+ dn = dict_lookup (d, tok1);
+ if (!dn)
+ {
+ puts ("dict_lookup failed");
+ break;
+ }
+ val = dnode_get (dn);
+ key = dnode_getkey (dn);
+ dict_delete_free (d, dn);
+
+ free (val);
+ free ((void *) key);
+ break;
+ case 'f':
+ dict_free (d);
+ break;
+ case 'l':
+ case '(':
+ case ')':
+ if (tokenize (in + 1, &tok1, (char **) 0) != 1)
+ {
+ puts ("what?");
+ break;
+ }
+ dn = 0;
+ switch (in[0])
+ {
case 'l':
+ dn = dict_lookup (d, tok1);
+ break;
case '(':
+ dn = dict_lower_bound (d, tok1);
+ break;
case ')':
- if (tokenize(in+1, &tok1, (char **) 0) != 1) {
- puts("what?");
- break;
- }
- dn = 0;
- switch (in[0]) {
- case 'l':
- dn = dict_lookup(d, tok1);
- break;
- case '(':
- dn = dict_lower_bound(d, tok1);
- break;
- case ')':
- dn = dict_upper_bound(d, tok1);
- break;
- }
- if (!dn) {
- puts("lookup failed");
- break;
- }
- val = dnode_get(dn);
- puts(val);
- break;
- case 'm':
- construct(d);
- break;
- case 'k':
- dict_allow_dupes(d);
- break;
- case 'c':
- printf("%lu\n", (unsigned long) dict_count(d));
- break;
- case 't':
- for (dn = dict_first(d); dn; dn = dict_next(d, dn)) {
- printf("%s\t%s\n", (char *) dnode_getkey(dn),
- (char *) dnode_get(dn));
- }
- break;
- case 'q':
- exit(0);
- break;
- case '\0':
- break;
- case 'p':
- prompt = 1;
- break;
- case 's':
- dict_set_allocator(d, new_node, del_node, NULL);
- break;
- case '#':
- if (tokenize(in+1, &tok1, (char **) 0) != 1) {
- puts("what?");
- break;
- } else {
- int dictnum = atoi(tok1);
- if (dictnum < 0 || dictnum > 9) {
- puts("invalid number");
- break;
- }
- d = &darray[dictnum];
+ dn = dict_upper_bound (d, tok1);
+ break;
+ }
+ if (!dn)
+ {
+ puts ("lookup failed");
+ break;
+ }
+ val = dnode_get (dn);
+ puts (val);
+ break;
+ case 'm':
+ construct (d);
+ break;
+ case 'k':
+ dict_allow_dupes (d);
+ break;
+ case 'c':
+ printf ("%lu\n", (unsigned long) dict_count (d));
+ break;
+ case 't':
+ for (dn = dict_first (d); dn; dn = dict_next (d, dn))
+ {
+ printf ("%s\t%s\n", (char *) dnode_getkey (dn),
+ (char *) dnode_get (dn));
+ }
+ break;
+ case 'q':
+ exit (0);
+ break;
+ case '\0':
+ break;
+ case 'p':
+ prompt = 1;
+ break;
+ case 's':
+ dict_set_allocator (d, new_node, del_node, NULL);
+ break;
+ case '#':
+ if (tokenize (in + 1, &tok1, (char **) 0) != 1)
+ {
+ puts ("what?");
+ break;
+ }
+ else
+ {
+ int dictnum = atoi (tok1);
+ if (dictnum < 0 || dictnum > 9)
+ {
+ puts ("invalid number");
+ break;
}
- break;
- case 'j':
- if (tokenize(in+1, &tok1, &tok2, (char **) 0) != 2) {
- puts("what?");
- break;
- } else {
- int dict1 = atoi(tok1), dict2 = atoi(tok2);
- if (dict1 < 0 || dict1 > 9 || dict2 < 0 || dict2 > 9) {
- puts("invalid number");
- break;
- }
- dict_merge(&darray[dict1], &darray[dict2]);
+ d = &darray[dictnum];
+ }
+ break;
+ case 'j':
+ if (tokenize (in + 1, &tok1, &tok2, (char **) 0) != 2)
+ {
+ puts ("what?");
+ break;
+ }
+ else
+ {
+ int dict1 = atoi (tok1), dict2 = atoi (tok2);
+ if (dict1 < 0 || dict1 > 9 || dict2 < 0 || dict2 > 9)
+ {
+ puts ("invalid number");
+ break;
}
- break;
- default:
- putchar('?');
- putchar('\n');
- break;
+ dict_merge (&darray[dict1], &darray[dict2]);
+ }
+ break;
+ default:
+ putchar ('?');
+ putchar ('\n');
+ break;
}
}
- return 0;
+ return 0;
}
#endif
diff --git a/isisd/dict.h b/isisd/dict.h
index 2977a90f3..1a5e9d7c5 100644
--- a/isisd/dict.h
+++ b/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
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c
index 86fed1d90..3770ebded 100644
--- a/isisd/isis_adjacency.c
+++ b/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;
}
-
diff --git a/isisd/isis_adjacency.h b/isisd/isis_adjacency.h
index 5c0772cc4..a9b1913e8 100644
--- a/isisd/isis_adjacency.h
+++ b/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 */
-
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index 192b107f8..671ebbffe 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -67,24 +67,27 @@ isis_circuit_new ()
int i;
circuit = XMALLOC (MTYPE_ISIS_CIRCUIT, sizeof (struct isis_circuit));
- if (circuit) {
- memset (circuit, 0, sizeof (struct isis_circuit));
- /* set default metrics for circuit */
- for (i = 0; i < 2; i++) {
- circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS;
- circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
- circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
- circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
- }
- } else {
- zlog_err ("Can't malloc isis circuit");
- return NULL;
- }
-
+ if (circuit)
+ {
+ memset (circuit, 0, sizeof (struct isis_circuit));
+ /* set default metrics for circuit */
+ for (i = 0; i < 2; i++)
+ {
+ circuit->metrics[i].metric_default = DEFAULT_CIRCUIT_METRICS;
+ circuit->metrics[i].metric_expense = METRICS_UNSUPPORTED;
+ circuit->metrics[i].metric_error = METRICS_UNSUPPORTED;
+ circuit->metrics[i].metric_delay = METRICS_UNSUPPORTED;
+ }
+ }
+ else
+ {
+ zlog_err ("Can't malloc isis circuit");
+ return NULL;
+ }
+
return circuit;
}
-
void
isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
{
@@ -98,18 +101,20 @@ isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
/*
* Default values
*/
- for (i = 0; i < 2; i++) {
- circuit->hello_interval[i] = HELLO_INTERVAL;
- circuit->hello_multiplier[i] = HELLO_MULTIPLIER;
- circuit->csnp_interval[i] = CSNP_INTERVAL;
- circuit->psnp_interval[i] = PSNP_INTERVAL;
- circuit->u.bc.priority[i] = DEFAULT_PRIORITY;
- }
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- circuit->u.bc.adjdb[0] = list_new ();
- circuit->u.bc.adjdb[1] = list_new ();
- circuit->u.bc.pad_hellos = 1;
- }
+ for (i = 0; i < 2; i++)
+ {
+ circuit->hello_interval[i] = HELLO_INTERVAL;
+ circuit->hello_multiplier[i] = HELLO_MULTIPLIER;
+ circuit->csnp_interval[i] = CSNP_INTERVAL;
+ circuit->psnp_interval[i] = PSNP_INTERVAL;
+ circuit->u.bc.priority[i] = DEFAULT_PRIORITY;
+ }
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ circuit->u.bc.adjdb[0] = list_new ();
+ circuit->u.bc.adjdb[1] = list_new ();
+ circuit->u.bc.pad_hellos = 1;
+ }
circuit->lsp_interval = LSP_INTERVAL;
/*
@@ -123,11 +128,11 @@ isis_circuit_configure (struct isis_circuit *circuit, struct isis_area *area)
return;
}
-void
+void
isis_circuit_deconfigure (struct isis_circuit *circuit,
- struct isis_area *area)
+ struct isis_area *area)
{
-
+
/* Remove circuit from area */
listnode_delete (area->circuit_list, circuit);
/* Free the index of SRM and SSN flags */
@@ -141,16 +146,17 @@ circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
{
struct isis_circuit *circuit = NULL;
struct listnode *node;
-
+
if (!list)
return NULL;
-
- for (node = listhead (list); node; nextnode (node)) {
- circuit = getdata (node);
- if (circuit->interface == ifp)
- return circuit;
- }
-
+
+ for (node = listhead (list); node; nextnode (node))
+ {
+ circuit = getdata (node);
+ if (circuit->interface == ifp)
+ return circuit;
+ }
+
return NULL;
}
@@ -164,13 +170,14 @@ circuit_scan_by_ifp (struct interface *ifp)
if (!isis->area_list)
return NULL;
- for (node = listhead (isis->area_list); node; nextnode (node)) {
- area = getdata (node);
- circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
- if (circuit)
- return circuit;
- }
-
+ for (node = listhead (isis->area_list); node; nextnode (node))
+ {
+ area = getdata (node);
+ circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
+ if (circuit)
+ return circuit;
+ }
+
return circuit_lookup_by_ifp (ifp, isis->init_circ_list);
}
@@ -181,17 +188,18 @@ isis_circuit_del (struct isis_circuit *circuit)
if (!circuit)
return;
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- /* destroy adjacency databases */
- list_delete (circuit->u.bc.adjdb[0]);
- list_delete (circuit->u.bc.adjdb[1]);
- /* destroy neighbour lists */
- if (circuit->u.bc.lan_neighs[0])
- list_delete (circuit->u.bc.lan_neighs[0]);
- if (circuit->u.bc.lan_neighs[1])
- list_delete (circuit->u.bc.lan_neighs[1]);
- /* destroy addresses */
- }
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ /* destroy adjacency databases */
+ list_delete (circuit->u.bc.adjdb[0]);
+ list_delete (circuit->u.bc.adjdb[1]);
+ /* destroy neighbour lists */
+ if (circuit->u.bc.lan_neighs[0])
+ list_delete (circuit->u.bc.lan_neighs[0]);
+ if (circuit->u.bc.lan_neighs[1])
+ list_delete (circuit->u.bc.lan_neighs[1]);
+ /* destroy addresses */
+ }
if (circuit->ip_addrs)
list_delete (circuit->ip_addrs);
#ifdef HAVE_IPV6
@@ -200,7 +208,7 @@ isis_circuit_del (struct isis_circuit *circuit)
if (circuit->ipv6_non_link)
list_delete (circuit->ipv6_non_link);
#endif /* HAVE_IPV6 */
-
+
/* and lastly the circuit itself */
XFREE (MTYPE_ISIS_CIRCUIT, circuit);
@@ -208,63 +216,70 @@ isis_circuit_del (struct isis_circuit *circuit)
}
void
-isis_circuit_add_addr (struct isis_circuit *circuit,
- struct connected *conn)
+isis_circuit_add_addr (struct isis_circuit *circuit, struct connected *conn)
{
struct prefix_ipv4 *ipv4;
- u_char buf [BUFSIZ];
+ u_char buf[BUFSIZ];
#ifdef HAVE_IPV6
struct prefix_ipv6 *ipv6;
#endif /* HAVE_IPV6 */
- if (!circuit->ip_addrs) {
- circuit->ip_addrs = list_new ();
- }
+ if (!circuit->ip_addrs)
+ {
+ circuit->ip_addrs = list_new ();
+ }
#ifdef HAVE_IPV6
- if (!circuit->ipv6_link) {
- circuit->ipv6_link = list_new ();
- }
- if (!circuit->ipv6_non_link) {
- circuit->ipv6_non_link = list_new ();
- }
+ if (!circuit->ipv6_link)
+ {
+ circuit->ipv6_link = list_new ();
+ }
+ if (!circuit->ipv6_non_link)
+ {
+ circuit->ipv6_non_link = list_new ();
+ }
#endif /* HAVE_IPV6 */
memset (&buf, 0, BUFSIZ);
- if (conn->address->family == AF_INET) {
- ipv4 = prefix_ipv4_new ();
- ipv4->prefixlen = conn->address->prefixlen;
- ipv4->prefix = conn->address->u.prefix4;
- listnode_add (circuit->ip_addrs, ipv4);
- prefix2str (conn->address, buf, BUFSIZ);
+ if (conn->address->family == AF_INET)
+ {
+ ipv4 = prefix_ipv4_new ();
+ ipv4->prefixlen = conn->address->prefixlen;
+ ipv4->prefix = conn->address->u.prefix4;
+ listnode_add (circuit->ip_addrs, ipv4);
+ prefix2str (conn->address, buf, BUFSIZ);
#ifdef EXTREME_DEBUG
- zlog_info ("Added IP address %s to circuit %d", buf,
- circuit->circuit_id);
-#endif /* EXTREME_DEBUG */
- }
+ zlog_info ("Added IP address %s to circuit %d", buf,
+ circuit->circuit_id);
+#endif /* EXTREME_DEBUG */
+ }
#ifdef HAVE_IPV6
- if (conn->address->family == AF_INET6) {
- ipv6 = prefix_ipv6_new ();
- ipv6->prefixlen = conn->address->prefixlen;
- ipv6->prefix = conn->address->u.prefix6;
- if (IN6_IS_ADDR_LINKLOCAL(&ipv6->prefix)) {
- listnode_add (circuit->ipv6_link, ipv6);
- } else {
- listnode_add (circuit->ipv6_non_link, ipv6);
- }
- prefix2str (conn->address, buf, BUFSIZ);
+ if (conn->address->family == AF_INET6)
+ {
+ ipv6 = prefix_ipv6_new ();
+ ipv6->prefixlen = conn->address->prefixlen;
+ ipv6->prefix = conn->address->u.prefix6;
+ if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
+ {
+ listnode_add (circuit->ipv6_link, ipv6);
+ }
+ else
+ {
+ listnode_add (circuit->ipv6_non_link, ipv6);
+ }
+ prefix2str (conn->address, buf, BUFSIZ);
#ifdef EXTREME_DEBUG
- zlog_info ("Added IPv6 address %s to circuit %d", buf,
- circuit->circuit_id);
-#endif /* EXTREME_DEBUG */
- }
+ zlog_info ("Added IPv6 address %s to circuit %d", buf,
+ circuit->circuit_id);
+#endif /* EXTREME_DEBUG */
+ }
#endif /* HAVE_IPV6 */
-
+
return;
}
void
isis_circuit_del_addr (struct isis_circuit *circuit,
- struct connected *connected)
+ struct connected *connected)
{
}
@@ -277,60 +292,71 @@ isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
circuit->interface = ifp;
ifp->info = circuit;
-
- circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */
+
+ circuit->circuit_id = ifp->ifindex % 255; /* FIXME: Why not ? */
/* isis_circuit_update_addrs (circuit, ifp); */
- if (if_is_broadcast (ifp)) {
- circuit->circ_type = CIRCUIT_T_BROADCAST;
- /*
- * Get the Hardware Address
- */
+ if (if_is_broadcast (ifp))
+ {
+ circuit->circ_type = CIRCUIT_T_BROADCAST;
+ /*
+ * Get the Hardware Address
+ */
#ifdef HAVE_SOCKADDR_DL
- if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
- zlog_warn ("unsupported link layer");
- else
- memcpy (circuit->u.bc.snpa, LLADDR(&circuit->interface->sdl), ETH_ALEN);
+ if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
+ zlog_warn ("unsupported link layer");
+ else
+ memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl),
+ ETH_ALEN);
#else
- if (circuit->interface->hw_addr_len != ETH_ALEN) {
- zlog_warn ("unsupported link layer");
- } else {
- memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
- }
+ if (circuit->interface->hw_addr_len != ETH_ALEN)
+ {
+ zlog_warn ("unsupported link layer");
+ }
+ else
+ {
+ memcpy (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN);
+ }
#ifdef EXTREME_DEGUG
- zlog_info ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
- circuit->interface->ifindex, ISO_MTU (circuit),
- snpa_print (circuit->u.bc.snpa));
+ zlog_info ("isis_circuit_if_add: if_id %d, isomtu %d snpa %s",
+ circuit->interface->ifindex, ISO_MTU (circuit),
+ snpa_print (circuit->u.bc.snpa));
#endif /* EXTREME_DEBUG */
-#endif /* HAVE_SOCKADDR_DL */
- } else if (if_is_pointopoint (ifp)) {
- circuit->circ_type = CIRCUIT_T_P2P;
- } else {
- zlog_warn ("isis_circuit_if_add: unsupported media");
- }
-
- for (node = ifp->connected ? listhead (ifp->connected) : NULL; node;
- nextnode (node)) {
- conn = getdata (node);
- isis_circuit_add_addr (circuit, conn);
- }
+#endif /* HAVE_SOCKADDR_DL */
+ }
+ else if (if_is_pointopoint (ifp))
+ {
+ circuit->circ_type = CIRCUIT_T_P2P;
+ }
+ else
+ {
+ zlog_warn ("isis_circuit_if_add: unsupported media");
+ }
+
+ for (node = ifp->connected ? listhead (ifp->connected) : NULL; node;
+ nextnode (node))
+ {
+ conn = getdata (node);
+ isis_circuit_add_addr (circuit, conn);
+ }
return;
}
void
-isis_circuit_update_params (struct isis_circuit *circuit,
- struct interface *ifp)
+isis_circuit_update_params (struct isis_circuit *circuit,
+ struct interface *ifp)
{
assert (circuit);
-
- if (circuit->circuit_id != ifp->ifindex) {
- zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id,
- ifp->ifindex);
- circuit->circuit_id = ifp->ifindex % 255;
- }
+
+ if (circuit->circuit_id != ifp->ifindex)
+ {
+ zlog_warn ("changing circuit_id %d->%d", circuit->circuit_id,
+ ifp->ifindex);
+ circuit->circuit_id = ifp->ifindex % 255;
+ }
/* FIXME: Why is this needed? shouldn't we compare to the area's mtu */
/* Ofer, this was here in case someone changes the mtu (e.g. with ifconfig)
@@ -341,125 +367,141 @@ isis_circuit_update_params (struct isis_circuit *circuit,
ifp->mtu);
circuit->mtu = ifp->mtu;
}
- */
+ */
/*
* Get the Hardware Address
*/
#ifdef HAVE_SOCKADDR_DL
if (circuit->interface->sdl.sdl_alen != ETHER_ADDR_LEN)
- zlog_warn ("unsupported link layer");
- else
- memcpy (circuit->u.bc.snpa, LLADDR(&circuit->interface->sdl), ETH_ALEN);
-#else
- if (circuit->interface->hw_addr_len != ETH_ALEN) {
zlog_warn ("unsupported link layer");
- } else {
- if (memcmp(circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN)) {
- zlog_warn ("changing circuit snpa %s->%s",
- snpa_print (circuit->u.bc.snpa),
- snpa_print (circuit->interface->hw_addr));
+ else
+ memcpy (circuit->u.bc.snpa, LLADDR (&circuit->interface->sdl), ETH_ALEN);
+#else
+ if (circuit->interface->hw_addr_len != ETH_ALEN)
+ {
+ zlog_warn ("unsupported link layer");
}
- }
-#endif
-
+ else
+ {
+ if (memcmp (circuit->u.bc.snpa, circuit->interface->hw_addr, ETH_ALEN))
+ {
+ zlog_warn ("changing circuit snpa %s->%s",
+ snpa_print (circuit->u.bc.snpa),
+ snpa_print (circuit->interface->hw_addr));
+ }
+ }
+#endif
+ if (if_is_broadcast (ifp))
+ {
+ circuit->circ_type = CIRCUIT_T_BROADCAST;
+ }
+ else if (if_is_pointopoint (ifp))
+ {
+ circuit->circ_type = CIRCUIT_T_P2P;
+ }
+ else
+ {
+ zlog_warn ("isis_circuit_update_params: unsupported media");
+ }
- if (if_is_broadcast (ifp)) {
- circuit->circ_type = CIRCUIT_T_BROADCAST;
- } else if (if_is_pointopoint (ifp)) {
- circuit->circ_type = CIRCUIT_T_P2P;
- } else {
- zlog_warn ("isis_circuit_update_params: unsupported media");
- }
-
return;
}
void
-isis_circuit_if_del (struct isis_circuit *circuit)
+isis_circuit_if_del (struct isis_circuit *circuit)
{
circuit->interface->info = NULL;
circuit->interface = NULL;
-
+
return;
}
void
isis_circuit_up (struct isis_circuit *circuit)
{
-
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- if (circuit->area->min_bcast_mtu == 0 ||
- ISO_MTU(circuit) < circuit->area->min_bcast_mtu )
- circuit->area->min_bcast_mtu = ISO_MTU(circuit);
- /*
- * ISO 10589 - 8.4.1 Enabling of broadcast circuits
- */
-
- /* initilizing the hello sending threads
- * for a broadcast IF
- */
-
- /* 8.4.1 a) commence sending of IIH PDUs */
-
- if (circuit->circuit_is_type & IS_LEVEL_1) {
- thread_add_event (master, send_lan_l1_hello, circuit, 0);
- circuit->u.bc.lan_neighs[0] = list_new ();
- }
-
- if (circuit->circuit_is_type & IS_LEVEL_2) {
- thread_add_event (master, send_lan_l2_hello, circuit, 0);
- circuit->u.bc.lan_neighs[1] = list_new ();
- }
-
- /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
- /* 8.4.1 c) FIXME: listen for ESH PDUs */
-
- /* 8.4.1 d) */
- /* dr election will commence in... */
- if (circuit->circuit_is_type & IS_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]);
- if (circuit->circuit_is_type & IS_LEVEL_2)
- 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]);
- } else {
- /* initializing the hello send threads
- * for a ptp IF
- */
- thread_add_event (master, send_p2p_hello, circuit, 0);
- }
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ if (circuit->area->min_bcast_mtu == 0 ||
+ ISO_MTU (circuit) < circuit->area->min_bcast_mtu)
+ circuit->area->min_bcast_mtu = ISO_MTU (circuit);
+ /*
+ * ISO 10589 - 8.4.1 Enabling of broadcast circuits
+ */
+
+ /* initilizing the hello sending threads
+ * for a broadcast IF
+ */
+
+ /* 8.4.1 a) commence sending of IIH PDUs */
+
+ if (circuit->circuit_is_type & IS_LEVEL_1)
+ {
+ thread_add_event (master, send_lan_l1_hello, circuit, 0);
+ circuit->u.bc.lan_neighs[0] = list_new ();
+ }
+
+ if (circuit->circuit_is_type & IS_LEVEL_2)
+ {
+ thread_add_event (master, send_lan_l2_hello, circuit, 0);
+ circuit->u.bc.lan_neighs[1] = list_new ();
+ }
+
+ /* 8.4.1 b) FIXME: solicit ES - 8.4.6 */
+ /* 8.4.1 c) FIXME: listen for ESH PDUs */
+
+ /* 8.4.1 d) */
+ /* dr election will commence in... */
+ if (circuit->circuit_is_type & IS_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]);
+ if (circuit->circuit_is_type & IS_LEVEL_2)
+ 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]);
+ }
+ else
+ {
+ /* initializing the hello send threads
+ * for a ptp IF
+ */
+ thread_add_event (master, send_p2p_hello, circuit, 0);
+
+ }
/* initializing PSNP timers */
- if (circuit->circuit_is_type & IS_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->circuit_is_type & IS_LEVEL_2) {
- THREAD_TIMER_ON(master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
- isis_jitter(circuit->psnp_interval[1], PSNP_JITTER));
- }
-
+ if (circuit->circuit_is_type & IS_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->circuit_is_type & IS_LEVEL_2)
+ {
+ THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
+ isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
+ }
+
/* initialize the circuit streams */
if (circuit->rcv_stream == NULL)
- circuit->rcv_stream = stream_new (ISO_MTU(circuit));
+ circuit->rcv_stream = stream_new (ISO_MTU (circuit));
if (circuit->snd_stream == NULL)
- circuit->snd_stream = stream_new (ISO_MTU(circuit));
+ circuit->snd_stream = stream_new (ISO_MTU (circuit));
/* unified init for circuits */
isis_sock_init (circuit);
#ifdef GNU_LINUX
- THREAD_READ_ON(master, circuit->t_read, isis_receive, circuit,
- circuit->fd);
+ THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
+ circuit->fd);
#else
- THREAD_TIMER_ON(master, circuit->t_read, isis_receive, circuit,
- circuit->fd);
+ THREAD_TIMER_ON (master, circuit->t_read, isis_receive, circuit,
+ circuit->fd);
#endif
return;
}
@@ -467,15 +509,18 @@ isis_circuit_up (struct isis_circuit *circuit)
void
isis_circuit_down (struct isis_circuit *circuit)
{
- /* Cancel all active threads -- FIXME: wrong place*/
+ /* Cancel all active threads -- FIXME: wrong place */
/* HT: Read thread if GNU_LINUX, TIMER thread otherwise. */
- THREAD_OFF(circuit->t_read);
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[0]);
- THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[1]);
- } else if (circuit->circ_type == CIRCUIT_T_P2P) {
- THREAD_TIMER_OFF(circuit->u.p2p.t_send_p2p_hello);
- }
+ THREAD_OFF (circuit->t_read);
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[0]);
+ THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[1]);
+ }
+ else if (circuit->circ_type == CIRCUIT_T_P2P)
+ {
+ THREAD_TIMER_OFF (circuit->u.p2p.t_send_p2p_hello);
+ }
/* close the socket */
close (circuit->fd);
@@ -486,22 +531,24 @@ void
circuit_update_nlpids (struct isis_circuit *circuit)
{
circuit->nlpids.count = 0;
-
- if (circuit->ip_router) {
- circuit->nlpids.nlpids[0] = NLPID_IP;
- circuit->nlpids.count++;
- }
+
+ if (circuit->ip_router)
+ {
+ circuit->nlpids.nlpids[0] = NLPID_IP;
+ circuit->nlpids.count++;
+ }
#ifdef HAVE_IPV6
- if (circuit->ipv6_router) {
- circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
- circuit->nlpids.count++;
- }
+ if (circuit->ipv6_router)
+ {
+ circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6;
+ circuit->nlpids.count++;
+ }
#endif /* HAVE_IPV6 */
return;
}
int
-isis_interface_config_write (struct vty *vty)
+isis_interface_config_write (struct vty *vty)
{
int write = 0;
@@ -519,146 +566,194 @@ isis_interface_config_write (struct vty *vty)
char buf[BUFSIZ];
-
LIST_LOOP (iflist, ifp, node)
{
/* IF name */
- vty_out (vty, "interface %s%s", ifp->name,VTY_NEWLINE);
+ vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
write++;
/* IF desc */
- if (ifp->desc) {
- vty_out (vty, " description %s%s", ifp->desc,VTY_NEWLINE);
- write++;
- }
+ if (ifp->desc)
+ {
+ vty_out (vty, " description %s%s", ifp->desc, VTY_NEWLINE);
+ write++;
+ }
/* ISIS Circuit */
LIST_LOOP (isis->area_list, area, node2)
{
c = circuit_lookup_by_ifp (ifp, area->circuit_list);
- if (c) {
- if (c->ip_router) {
- vty_out (vty, " ip router isis %s%s",area->area_tag,VTY_NEWLINE);
- write++;
- }
+ if (c)
+ {
+ if (c->ip_router)
+ {
+ vty_out (vty, " ip router isis %s%s", area->area_tag,
+ VTY_NEWLINE);
+ write++;
+ }
#ifdef HAVE_IPV6
- if (c->ipv6_router) {
- vty_out (vty, " ipv6 router isis %s%s",area->area_tag,VTY_NEWLINE);
- write++;
- }
+ if (c->ipv6_router)
+ {
+ vty_out (vty, " ipv6 router isis %s%s", area->area_tag,
+ VTY_NEWLINE);
+ write++;
+ }
#endif /* HAVE_IPV6 */
- /* ISIS - circuit type */
- if (c->circuit_is_type == IS_LEVEL_1) {
- vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
- write ++;
- } else {if (c->circuit_is_type == IS_LEVEL_2) {
- vty_out (vty, " isis circuit-type level-2-only%s", VTY_NEWLINE);
- write ++;
- }}
-
- /* ISIS - CSNP interval - FIXME: compare to cisco*/
- if (c->csnp_interval[0] == c->csnp_interval[1]) {
- if (c->csnp_interval[0] != CSNP_INTERVAL) {
- vty_out (vty, " isis csnp-interval %d%s", c->csnp_interval[0],
- VTY_NEWLINE);
- write ++;
- }
- } else {
- for (i=0;i<2;i++) {
- if (c->csnp_interval[1] != CSNP_INTERVAL) {
- vty_out (vty, " isis csnp-interval %d level-%d%s",
- c->csnp_interval[1],i+1, VTY_NEWLINE);
- write ++;
- }
- }
- }
-
- /* ISIS - Hello padding - Defaults to true so only display if false */
- if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos) {
- vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
- write ++;
- }
-
- /* ISIS - Hello interval - FIXME: compare to cisco */
- if (c->hello_interval[0] == c->hello_interval[1]) {
- if (c->hello_interval[0] != HELLO_INTERVAL) {
- vty_out (vty, " isis hello-interval %d%s", c->hello_interval[0],
- VTY_NEWLINE);
- write ++;
- }
- } else {
- for (i=0;i<2;i++) {
- if (c->hello_interval[i] != HELLO_INTERVAL) {
- if (c->hello_interval[i] == HELLO_MINIMAL) {
- vty_out (vty, " isis hello-interval minimal level-%d%s", i+1,
- VTY_NEWLINE);
- } else {
- vty_out (vty, " isis hello-interval %d level-%d%s",
- c->hello_interval[i],i+1, VTY_NEWLINE);
- }
- write ++;
- }
- }
- }
-
- /* ISIS - Hello Multiplier */
- if (c->hello_multiplier[0] == c->hello_multiplier[1]) {
- if (c->hello_multiplier[0] != HELLO_MULTIPLIER ) {
- vty_out (vty, " isis hello-multiplier %d%s",
- c->hello_multiplier[0], VTY_NEWLINE);
- write ++;
- }
- } else {
- for (i=0;i<2;i++) {
- if (c->hello_multiplier[i] != HELLO_MULTIPLIER) {
- vty_out (vty, " isis hello-multiplier %d level-%d%s",
- c->hello_multiplier[i],i+1, VTY_NEWLINE);
- write ++;
- }
- }
- }
- /* ISIS - Priority */
- if (c->circ_type == CIRCUIT_T_BROADCAST) {
- if (c->u.bc.priority[0] == c->u.bc.priority[1]) {
- if (c->u.bc.priority[0] != DEFAULT_PRIORITY) {
- vty_out (vty, " isis priority %d%s", c->u.bc.priority[0],
- VTY_NEWLINE);
- write ++;
- }
- } else {
- for (i=0;i<2;i++) {
- if (c->u.bc.priority[i] != DEFAULT_PRIORITY) {
- vty_out (vty, " isis priority %d level-%d%s",
- c->u.bc.priority[i],i+1, VTY_NEWLINE);
- write ++;
- }
- }
- }
- }
- /* ISIS - Metric */
- if (c->metrics[0].metric_default == c->metrics[1].metric_default) {
- if (c->metrics[0].metric_default != DEFAULT_CIRCUIT_METRICS) {
- vty_out (vty, " isis metric %d%s", c->metrics[0].metric_default,
- VTY_NEWLINE);
- write ++;
- }
- } else {
- for (i=0;i<2;i++) {
- if (c->metrics[i].metric_default != DEFAULT_CIRCUIT_METRICS) {
- vty_out (vty, " isis metric %d level-%d%s",
- c->metrics[i].metric_default,i+1, VTY_NEWLINE);
- write ++;
- }
- }
- }
-
- }
+ /* ISIS - circuit type */
+ if (c->circuit_is_type == IS_LEVEL_1)
+ {
+ vty_out (vty, " isis circuit-type level-1%s", VTY_NEWLINE);
+ write++;
+ }
+ else
+ {
+ if (c->circuit_is_type == IS_LEVEL_2)
+ {
+ vty_out (vty, " isis circuit-type level-2-only%s",
+ VTY_NEWLINE);
+ write++;
+ }
+ }
+
+ /* ISIS - CSNP interval - FIXME: compare to cisco */
+ if (c->csnp_interval[0] == c->csnp_interval[1])
+ {
+ if (c->csnp_interval[0] != CSNP_INTERVAL)
+ {
+ vty_out (vty, " isis csnp-interval %d%s",
+ c->csnp_interval[0], VTY_NEWLINE);
+ write++;
+ }
+ }
+ else
+ {
+ for (i = 0; i < 2; i++)
+ {
+ if (c->csnp_interval[1] != CSNP_INTERVAL)
+ {
+ vty_out (vty, " isis csnp-interval %d level-%d%s",
+ c->csnp_interval[1], i + 1, VTY_NEWLINE);
+ write++;
+ }
+ }
+ }
+
+ /* ISIS - Hello padding - Defaults to true so only display if false */
+ if (c->circ_type == CIRCUIT_T_BROADCAST && !c->u.bc.pad_hellos)
+ {
+ vty_out (vty, " no isis hello padding%s", VTY_NEWLINE);
+ write++;
+ }
+
+ /* ISIS - Hello interval - FIXME: compare to cisco */
+ if (c->hello_interval[0] == c->hello_interval[1])
+ {
+ if (c->hello_interval[0] != HELLO_INTERVAL)
+ {
+ vty_out (vty, " isis hello-interval %d%s",
+ c->hello_interval[0], VTY_NEWLINE);
+ write++;
+ }
+ }
+ else
+ {
+ for (i = 0; i < 2; i++)
+ {
+ if (c->hello_interval[i] != HELLO_INTERVAL)
+ {
+ if (c->hello_interval[i] == HELLO_MINIMAL)
+ {
+ vty_out (vty,
+ " isis hello-interval minimal level-%d%s",
+ i + 1, VTY_NEWLINE);
+ }
+ else
+ {
+ vty_out (vty, " isis hello-interval %d level-%d%s",
+ c->hello_interval[i], i + 1, VTY_NEWLINE);
+ }
+ write++;
+ }
+ }
+ }
+
+ /* ISIS - Hello Multiplier */
+ if (c->hello_multiplier[0] == c->hello_multiplier[1])
+ {
+ if (c->hello_multiplier[0] != HELLO_MULTIPLIER)
+ {
+ vty_out (vty, " isis hello-multiplier %d%s",
+ c->hello_multiplier[0], VTY_NEWLINE);
+ write++;
+ }
+ }
+ else
+ {
+ for (i = 0; i < 2; i++)
+ {
+ if (c->hello_multiplier[i] != HELLO_MULTIPLIER)
+ {
+ vty_out (vty, " isis hello-multiplier %d level-%d%s",
+ c->hello_multiplier[i], i + 1, VTY_NEWLINE);
+ write++;
+ }
+ }
+ }
+ /* ISIS - Priority */
+ if (c->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ if (c->u.bc.priority[0] == c->u.bc.priority[1])
+ {
+ if (c->u.bc.priority[0] != DEFAULT_PRIORITY)
+ {
+ vty_out (vty, " isis priority %d%s",
+ c->u.bc.priority[0], VTY_NEWLINE);
+ write++;
+ }
+ }
+ else
+ {
+ for (i = 0; i < 2; i++)
+ {
+ if (c->u.bc.priority[i] != DEFAULT_PRIORITY)
+ {
+ vty_out (vty, " isis priority %d level-%d%s",
+ c->u.bc.priority[i], i + 1, VTY_NEWLINE);
+ write++;
+ }
+ }
+ }
+ }
+ /* ISIS - Metric */
+ if (c->metrics[0].metric_default == c->metrics[1].metric_default)
+ {
+ if (c->metrics[0].metric_default != DEFAULT_CIRCUIT_METRICS)
+ {
+ vty_out (vty, " isis metric %d%s",
+ c->metrics[0].metric_default, VTY_NEWLINE);
+ write++;
+ }
+ }
+ else
+ {
+ for (i = 0; i < 2; i++)
+ {
+ if (c->metrics[i].metric_default != DEFAULT_CIRCUIT_METRICS)
+ {
+ vty_out (vty, " isis metric %d level-%d%s",
+ c->metrics[i].metric_default, i + 1,
+ VTY_NEWLINE);
+ write++;
+ }
+ }
+ }
+
+ }
}
- vty_out (vty, "!%s",VTY_NEWLINE);
+ vty_out (vty, "!%s", VTY_NEWLINE);
}
-
+
return write;
}
-
DEFUN (ip_router_isis,
ip_router_isis_cmd,
@@ -666,47 +761,51 @@ DEFUN (ip_router_isis,
"Interface Internet Protocol config commands\n"
"IP router interface commands\n"
"IS-IS Routing for IP\n"
- "Routing process tag\n"
- )
+ "Routing process tag\n")
{
struct isis_circuit *c;
struct interface *ifp;
struct isis_area *area;
-
- ifp = (struct interface *)vty->index;
+
+ ifp = (struct interface *) vty->index;
assert (ifp);
-
+
area = isis_area_lookup (argv[0]);
/* Prevent more than one circuit per interface */
if (area)
c = circuit_lookup_by_ifp (ifp, area->circuit_list);
- else c = NULL;
- if (c && (ifp->info != NULL)) {
+ else
+ c = NULL;
+ if (c && (ifp->info != NULL))
+ {
#ifdef HAVE_IPV6
- if (c->ipv6_router == 0) {
+ if (c->ipv6_router == 0)
+ {
#endif /* HAVE_IPV6 */
- vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out (vty, "ISIS circuit is already defined%s", VTY_NEWLINE);
+ return CMD_WARNING;
#ifdef HAVE_IPV6
- }
+ }
#endif /* HAVE_IPV6 */
- }
-
+ }
+
/* this is here for ciscopability */
- if (!area) {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!area)
+ {
+ vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
- if (!c) {
- c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
- c = isis_csm_state_change (ISIS_ENABLE, c, area);
- c->interface = ifp; /* this is automatic */
- ifp->info = c; /* hardly related to the FSM */
- }
+ if (!c)
+ {
+ c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
+ c = isis_csm_state_change (ISIS_ENABLE, c, area);
+ c->interface = ifp; /* this is automatic */
+ ifp->info = c; /* hardly related to the FSM */
+ }
- if(!c)
+ if (!c)
return CMD_WARNING;
c->ip_router = 1;
@@ -714,7 +813,7 @@ DEFUN (ip_router_isis,
circuit_update_nlpids (c);
vty->node = INTERFACE_NODE;
-
+
return CMD_SUCCESS;
}
@@ -725,36 +824,37 @@ DEFUN (no_ip_router_isis,
"Interface Internet Protocol config commands\n"
"IP router interface commands\n"
"IS-IS Routing for IP\n"
- "Routing process tag\n"
- )
+ "Routing process tag\n")
{
struct isis_circuit *circuit = NULL;
struct interface *ifp;
struct isis_area *area;
struct listnode *node;
- ifp = (struct interface *)vty->index;
+ ifp = (struct interface *) vty->index;
assert (ifp);
-
+
area = isis_area_lookup (argv[0]);
- if (!area) {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!area)
+ {
+ vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
LIST_LOOP (area->circuit_list, circuit, node)
if (circuit->interface == ifp)
break;
- if (!circuit) {
- vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!circuit)
+ {
+ vty_out (vty, "Can't find ISIS interface %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
circuit->ip_router = 0;
area->ip_circuits--;
#ifdef HAVE_IPV6
if (circuit->ipv6_router == 0)
#endif
isis_csm_state_change (ISIS_DISABLE, circuit, area);
-
+
return CMD_SUCCESS;
}
@@ -765,38 +865,40 @@ DEFUN (isis_circuit_type,
"Configure circuit type for interface\n"
"Level-1 only adjacencies are formed\n"
"Level-1-2 adjacencies are formed\n"
- "Level-2 only adjacencies are formed\n"
- )
+ "Level-2 only adjacencies are formed\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int circuit_t;
int is_type;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
/* UGLY - will remove l8r */
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
circuit_t = string2circuit_t (argv[0]);
- if (!circuit_t) {
- vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
-
+ if (!circuit_t)
+ {
+ vty_out (vty, "Unknown circuit-type %s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
+
is_type = circuit->area->is_type;
if (is_type == IS_LEVEL_1_AND_2 || is_type == circuit_t)
- isis_event_circuit_type_change (circuit, circuit_t);
- else {
- vty_out (vty, "invalid circuit level for area %s.%s",
- circuit->area->area_tag, VTY_NEWLINE);
- }
-
+ isis_event_circuit_type_change (circuit, circuit_t);
+ else
+ {
+ vty_out (vty, "invalid circuit level for area %s.%s",
+ circuit->area->area_tag, VTY_NEWLINE);
+ }
+
return CMD_SUCCESS;
}
@@ -808,25 +910,25 @@ DEFUN (no_isis_circuit_type,
"Configure circuit type for interface\n"
"Level-1 only adjacencies are formed\n"
"Level-1-2 adjacencies are formed\n"
- "Level-2 only adjacencies are formed\n"
- )
+ "Level-2 only adjacencies are formed\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
+
+ assert (circuit);
- assert(circuit);
-
/*
* Set the circuits level to its default value which is that of the area
*/
isis_event_circuit_type_change (circuit, circuit->area->is_type);
-
+
return CMD_SUCCESS;
}
@@ -840,22 +942,24 @@ DEFUN (isis_passwd,
struct isis_circuit *circuit;
struct interface *ifp;
int len;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
-
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
+
len = strlen (argv[0]);
- if (len > 254) {
- vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (len > 254)
+ {
+ vty_out (vty, "Too long circuit password (>254)%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
circuit->passwd.len = len;
circuit->passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
strncpy (circuit->passwd.passwd, argv[0], 255);
-
+
return CMD_SUCCESS;
}
@@ -868,15 +972,16 @@ DEFUN (no_isis_passwd,
{
struct isis_circuit *circuit;
struct interface *ifp;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
-
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
+
memset (&circuit->passwd, 0, sizeof (struct isis_passwd));
-
+
return CMD_SUCCESS;
}
@@ -886,25 +991,25 @@ DEFUN (isis_priority,
"isis priority <0-127>",
"IS-IS commands\n"
"Set priority for Designated Router election\n"
- "Priority value\n"
- )
+ "Priority value\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int prio;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
prio = atoi (argv[0]);
circuit->u.bc.priority[0] = prio;
circuit->u.bc.priority[1] = prio;
-
+
return CMD_SUCCESS;
}
@@ -913,22 +1018,22 @@ DEFUN (no_isis_priority,
"no isis priority",
NO_STR
"IS-IS commands\n"
- "Set priority for Designated Router election\n"
- )
+ "Set priority for Designated Router election\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
-
+
return CMD_SUCCESS;
}
@@ -938,33 +1043,32 @@ ALIAS (no_isis_priority,
NO_STR
"IS-IS commands\n"
"Set priority for Designated Router election\n"
- "Priority value\n"
- )
+ "Priority value\n")
DEFUN (isis_priority_l1,
isis_priority_l1_cmd,
- "isis priority <0-127> level-1",
+ "isis priority <0-127> level-1",
"IS-IS commands\n"
"Set priority for Designated Router election\n"
"Priority value\n"
- "Specify priority for level-1 routing\n"
- )
+ "Specify priority for level-1 routing\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int prio;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
prio = atoi (argv[0]);
circuit->u.bc.priority[0] = prio;
-
+
return CMD_SUCCESS;
}
@@ -974,21 +1078,21 @@ DEFUN (no_isis_priority_l1,
NO_STR
"IS-IS commands\n"
"Set priority for Designated Router election\n"
- "Specify priority for level-1 routing\n"
- )
+ "Specify priority for level-1 routing\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
circuit->u.bc.priority[0] = DEFAULT_PRIORITY;
-
+
return CMD_SUCCESS;
}
@@ -999,33 +1103,32 @@ ALIAS (no_isis_priority_l1,
"IS-IS commands\n"
"Set priority for Designated Router election\n"
"Priority value\n"
- "Specify priority for level-1 routing\n"
- )
+ "Specify priority for level-1 routing\n")
DEFUN (isis_priority_l2,
isis_priority_l2_cmd,
- "isis priority <0-127> level-2",
+ "isis priority <0-127> level-2",
"IS-IS commands\n"
"Set priority for Designated Router election\n"
"Priority value\n"
- "Specify priority for level-2 routing\n"
- )
+ "Specify priority for level-2 routing\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int prio;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
prio = atoi (argv[0]);
circuit->u.bc.priority[1] = prio;
-
+
return CMD_SUCCESS;
}
@@ -1035,21 +1138,21 @@ DEFUN (no_isis_priority_l2,
NO_STR
"IS-IS commands\n"
"Set priority for Designated Router election\n"
- "Specify priority for level-2 routing\n"
- )
+ "Specify priority for level-2 routing\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
circuit->u.bc.priority[1] = DEFAULT_PRIORITY;
-
+
return CMD_SUCCESS;
}
@@ -1060,28 +1163,26 @@ ALIAS (no_isis_priority_l2,
"IS-IS commands\n"
"Set priority for Designated Router election\n"
"Priority value\n"
- "Specify priority for level-2 routing\n"
- )
+ "Specify priority for level-2 routing\n")
/* Metric command */
-
-DEFUN (isis_metric,
+ DEFUN (isis_metric,
isis_metric_cmd,
"isis metric <0-63>",
"IS-IS commands\n"
"Set default metric for circuit\n"
- "Default metric value\n"
- )
+ "Default metric value\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int met;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
met = atoi (argv[0]);
@@ -1097,17 +1198,17 @@ DEFUN (no_isis_metric,
"no isis metric",
NO_STR
"IS-IS commands\n"
- "Set default metric for circuit\n"
- )
+ "Set default metric for circuit\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
circuit->metrics[0].metric_default = DEFAULT_CIRCUIT_METRICS;
@@ -1122,40 +1223,40 @@ ALIAS (no_isis_metric,
NO_STR
"IS-IS commands\n"
"Set default metric for circuit\n"
- "Default metric value\n"
- )
-/* end of metrics */
+ "Default metric value\n")
-
-DEFUN (isis_hello_interval,
+/* end of metrics */
+ DEFUN (isis_hello_interval,
isis_hello_interval_cmd,
"isis hello-interval (<1-65535>|minimal)",
"IS-IS commands\n"
"Set Hello interval\n"
"Hello interval value\n"
- "Holdtime 1 seconds, interval depends on multiplier\n"
- )
+ "Holdtime 1 seconds, interval depends on multiplier\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int interval;
char c;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
- assert (circuit);
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
+ assert (circuit);
c = *argv[0];
- if (isdigit((int)c)) {
- interval = atoi (argv[0]);
- } else
- interval = HELLO_MINIMAL; /* FIXME: should be calculated */
-
- circuit->hello_interval[0] = (u_int16_t)interval;
- circuit->hello_interval[1] = (u_int16_t)interval;
-
+ if (isdigit ((int) c))
+ {
+ interval = atoi (argv[0]);
+ }
+ else
+ interval = HELLO_MINIMAL; /* FIXME: should be calculated */
+
+ circuit->hello_interval[0] = (u_int16_t) interval;
+ circuit->hello_interval[1] = (u_int16_t) interval;
+
return CMD_SUCCESS;
}
@@ -1164,23 +1265,23 @@ DEFUN (no_isis_hello_interval,
"no isis hello-interval",
NO_STR
"IS-IS commands\n"
- "Set Hello interval\n"
- )
+ "Set Hello interval\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
- circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
+
+ circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
circuit->hello_interval[1] = HELLO_INTERVAL;
-
+
return CMD_SUCCESS;
}
@@ -1191,8 +1292,7 @@ ALIAS (no_isis_hello_interval,
"IS-IS commands\n"
"Set Hello interval\n"
"Hello interval value\n"
- "Holdtime 1 second, interval depends on multiplier\n"
- )
+ "Holdtime 1 second, interval depends on multiplier\n")
DEFUN (isis_hello_interval_l1,
isis_hello_interval_l1_cmd,
@@ -1201,29 +1301,31 @@ DEFUN (isis_hello_interval_l1,
"Set Hello interval\n"
"Hello interval value\n"
"Holdtime 1 second, interval depends on multiplier\n"
- "Specify hello-interval for level-1 IIHs\n"
- )
+ "Specify hello-interval for level-1 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
long interval;
char c;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
c = *argv[0];
- if (isdigit((int)c)) {
- interval = atoi (argv[0]);
- } else
+ if (isdigit ((int) c))
+ {
+ interval = atoi (argv[0]);
+ }
+ else
interval = HELLO_MINIMAL;
- circuit->hello_interval[0] = (u_int16_t)interval;
-
+ circuit->hello_interval[0] = (u_int16_t) interval;
+
return CMD_SUCCESS;
}
@@ -1233,22 +1335,22 @@ DEFUN (no_isis_hello_interval_l1,
NO_STR
"IS-IS commands\n"
"Set Hello interval\n"
- "Specify hello-interval for level-1 IIHs\n"
- )
+ "Specify hello-interval for level-1 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
- circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
-
+
+ circuit->hello_interval[0] = HELLO_INTERVAL; /* Default is 1 sec. */
+
return CMD_SUCCESS;
}
@@ -1260,8 +1362,7 @@ ALIAS (no_isis_hello_interval_l1,
"Set Hello interval\n"
"Hello interval value\n"
"Holdtime 1 second, interval depends on multiplier\n"
- "Specify hello-interval for level-1 IIHs\n"
- )
+ "Specify hello-interval for level-1 IIHs\n")
DEFUN (isis_hello_interval_l2,
isis_hello_interval_l2_cmd,
@@ -1270,29 +1371,31 @@ DEFUN (isis_hello_interval_l2,
"Set Hello interval\n"
"Hello interval value\n"
"Holdtime 1 second, interval depends on multiplier\n"
- "Specify hello-interval for level-2 IIHs\n"
- )
+ "Specify hello-interval for level-2 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
long interval;
char c;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
c = *argv[0];
- if (isdigit((int)c)) {
- interval = atoi (argv[0]);
- } else
+ if (isdigit ((int) c))
+ {
+ interval = atoi (argv[0]);
+ }
+ else
interval = HELLO_MINIMAL;
- circuit->hello_interval[1] = (u_int16_t)interval;
-
+ circuit->hello_interval[1] = (u_int16_t) interval;
+
return CMD_SUCCESS;
}
@@ -1302,22 +1405,22 @@ DEFUN (no_isis_hello_interval_l2,
NO_STR
"IS-IS commands\n"
"Set Hello interval\n"
- "Specify hello-interval for level-2 IIHs\n"
- )
+ "Specify hello-interval for level-2 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
- circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
-
+
+ circuit->hello_interval[1] = HELLO_INTERVAL; /* Default is 1 sec. */
+
return CMD_SUCCESS;
}
@@ -1329,34 +1432,32 @@ ALIAS (no_isis_hello_interval_l2,
"Set Hello interval\n"
"Hello interval value\n"
"Holdtime 1 second, interval depends on multiplier\n"
- "Specify hello-interval for level-2 IIHs\n"
- )
-
+ "Specify hello-interval for level-2 IIHs\n")
DEFUN (isis_hello_multiplier,
isis_hello_multiplier_cmd,
"isis hello-multiplier <3-1000>",
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
- "Hello multiplier value\n"
- )
+ "Hello multiplier value\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int mult;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
mult = atoi (argv[0]);
- circuit->hello_multiplier[0] = (u_int16_t)mult;
- circuit->hello_multiplier[1] = (u_int16_t)mult;
-
+ circuit->hello_multiplier[0] = (u_int16_t) mult;
+ circuit->hello_multiplier[1] = (u_int16_t) mult;
+
return CMD_SUCCESS;
}
@@ -1365,17 +1466,17 @@ DEFUN (no_isis_hello_multiplier,
"no isis hello-multiplier",
NO_STR
"IS-IS commands\n"
- "Set multiplier for Hello holding time\n"
- )
+ "Set multiplier for Hello holding time\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
@@ -1390,8 +1491,7 @@ ALIAS (no_isis_hello_multiplier,
NO_STR
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
- "Hello multiplier value\n"
- )
+ "Hello multiplier value\n")
DEFUN (isis_hello_multiplier_l1,
isis_hello_multiplier_l1_cmd,
@@ -1399,24 +1499,24 @@ DEFUN (isis_hello_multiplier_l1,
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
"Hello multiplier value\n"
- "Specify hello multiplier for level-1 IIHs\n"
- )
+ "Specify hello multiplier for level-1 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int mult;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
mult = atoi (argv[0]);
- circuit->hello_multiplier[0] = (u_int16_t)mult;
-
+ circuit->hello_multiplier[0] = (u_int16_t) mult;
+
return CMD_SUCCESS;
}
@@ -1426,17 +1526,17 @@ DEFUN (no_isis_hello_multiplier_l1,
NO_STR
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
- "Specify hello multiplier for level-1 IIHs\n"
- )
+ "Specify hello multiplier for level-1 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
circuit->hello_multiplier[0] = HELLO_MULTIPLIER;
@@ -1451,8 +1551,7 @@ ALIAS (no_isis_hello_multiplier_l1,
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
"Hello multiplier value\n"
- "Specify hello multiplier for level-1 IIHs\n"
- )
+ "Specify hello multiplier for level-1 IIHs\n")
DEFUN (isis_hello_multiplier_l2,
isis_hello_multiplier_l2_cmd,
@@ -1460,24 +1559,24 @@ DEFUN (isis_hello_multiplier_l2,
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
"Hello multiplier value\n"
- "Specify hello multiplier for level-2 IIHs\n"
- )
+ "Specify hello multiplier for level-2 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
int mult;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
mult = atoi (argv[0]);
- circuit->hello_multiplier[1] = (u_int16_t)mult;
-
+ circuit->hello_multiplier[1] = (u_int16_t) mult;
+
return CMD_SUCCESS;
}
@@ -1487,17 +1586,17 @@ DEFUN (no_isis_hello_multiplier_l2,
NO_STR
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
- "Specify hello multiplier for level-2 IIHs\n"
- )
+ "Specify hello multiplier for level-2 IIHs\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
circuit->hello_multiplier[1] = HELLO_MULTIPLIER;
@@ -1512,8 +1611,7 @@ ALIAS (no_isis_hello_multiplier_l2,
"IS-IS commands\n"
"Set multiplier for Hello holding time\n"
"Hello multiplier value\n"
- "Specify hello multiplier for level-2 IIHs\n"
- )
+ "Specify hello multiplier for level-2 IIHs\n")
DEFUN (isis_hello,
isis_hello_cmd,
@@ -1525,16 +1623,17 @@ DEFUN (isis_hello,
{
struct interface *ifp;
struct isis_circuit *circuit;
-
- ifp = vty->index;
+
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
circuit->u.bc.pad_hellos = 1;
-
+
return CMD_SUCCESS;
}
@@ -1543,9 +1642,7 @@ DEFUN (ip_address,
ip_address_cmd,
"ip address A.B.C.D/A",
"Interface Internet Protocol config commands\n"
- "Set the IP address of an interface\n"
- "IP address (e.g. 10.0.0.1/8\n")
-
+ "Set the IP address of an interface\n" "IP address (e.g. 10.0.0.1/8\n")
{
struct interface *ifp;
struct isis_circuit *circuit;
@@ -1553,11 +1650,12 @@ DEFUN (ip_address,
struct listnode *node;
int ret, found = 1;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
#ifdef HAVE_IPV6
@@ -1565,32 +1663,36 @@ DEFUN (ip_address,
#endif /* HAVE_IPV6 */
ipv4 = prefix_ipv4_new ();
-
+
ret = str2prefix_ipv4 (argv[0], ipv4);
- if (ret <= 0) {
- zlog_warn ("ip_address_cmd(): malformed address");
- vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- if (!circuit->ip_addrs)
- circuit->ip_addrs = list_new ();
- else {
- for (node = listhead (circuit->ip_addrs); node; nextnode (node)) {
- ip = getdata (node);
- if (prefix_same ((struct prefix *)ip, (struct prefix *)ipv4))
- found = 1;
+ if (ret <= 0)
+ {
+ zlog_warn ("ip_address_cmd(): malformed address");
+ vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
+ return CMD_WARNING;
}
- if (found) {
- prefix_ipv4_free (ipv4);
- return CMD_SUCCESS;
+
+ if (!circuit->ip_addrs)
+ circuit->ip_addrs = list_new ();
+ else
+ {
+ for (node = listhead (circuit->ip_addrs); node; nextnode (node))
+ {
+ ip = getdata (node);
+ if (prefix_same ((struct prefix *) ip, (struct prefix *) ipv4))
+ found = 1;
+ }
+ if (found)
+ {
+ prefix_ipv4_free (ipv4);
+ return CMD_SUCCESS;
+ }
}
- }
-
+
listnode_add (circuit->ip_addrs, ipv4);
-#ifdef EXTREME_DEBUG
- zlog_info ("added IP address %s to circuit %d", argv[0],
+#ifdef EXTREME_DEBUG
+ zlog_info ("added IP address %s to circuit %d", argv[0],
circuit->interface->ifindex);
#endif /* EXTREME_DEBUG */
return CMD_SUCCESS;
@@ -1610,36 +1712,43 @@ DEFUN (no_ip_address,
struct listnode *node;
int ret;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
/* UGLY - will remove l8r */
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
- if (!circuit->ip_addrs || circuit->ip_addrs->count == 0) {
- vty_out (vty, "Invalid address %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!circuit->ip_addrs || circuit->ip_addrs->count == 0)
+ {
+ vty_out (vty, "Invalid address %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
ret = str2prefix_ipv4 (argv[0], &ipv4);
- if (ret <= 0) {
- vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- for (node = listhead (circuit->ip_addrs); node; nextnode (node)) {
- ip = getdata (node);
- if (prefix_same ((struct prefix *)ip, (struct prefix *)&ipv4))
- break;
- }
-
- if (ip) {
- listnode_delete (circuit->ip_addrs, ip);
- } else {
- vty_out (vty, "Invalid address %s", VTY_NEWLINE);
- }
-
+ if (ret <= 0)
+ {
+ vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ for (node = listhead (circuit->ip_addrs); node; nextnode (node))
+ {
+ ip = getdata (node);
+ if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
+ break;
+ }
+
+ if (ip)
+ {
+ listnode_delete (circuit->ip_addrs, ip);
+ }
+ else
+ {
+ vty_out (vty, "Invalid address %s", VTY_NEWLINE);
+ }
+
return CMD_SUCCESS;
}
#endif
@@ -1656,15 +1765,16 @@ DEFUN (no_isis_hello,
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
circuit->u.bc.pad_hellos = 0;
-
+
return CMD_SUCCESS;
}
@@ -1679,18 +1789,19 @@ DEFUN (csnp_interval,
struct interface *ifp;
unsigned long interval;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
interval = atol (argv[0]);
- circuit->csnp_interval[0] = (u_int16_t)interval;
- circuit->csnp_interval[1] = (u_int16_t)interval;
-
+ circuit->csnp_interval[0] = (u_int16_t) interval;
+ circuit->csnp_interval[1] = (u_int16_t) interval;
+
return CMD_SUCCESS;
}
@@ -1699,22 +1810,22 @@ DEFUN (no_csnp_interval,
"no isis csnp-interval",
NO_STR
"IS-IS commands\n"
- "Set CSNP interval in seconds\n"
- )
+ "Set CSNP interval in seconds\n")
{
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
circuit->csnp_interval[0] = CSNP_INTERVAL;
circuit->csnp_interval[1] = CSNP_INTERVAL;
-
+
return CMD_SUCCESS;
}
@@ -1726,7 +1837,6 @@ ALIAS (no_csnp_interval,
"Set CSNP interval in seconds\n"
"CSNP interval value\n")
-
DEFUN (csnp_interval_l1,
csnp_interval_l1_cmd,
"isis csnp-interval <0-65535> level-1",
@@ -1739,17 +1849,18 @@ DEFUN (csnp_interval_l1,
struct interface *ifp;
unsigned long interval;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
interval = atol (argv[0]);
-
- circuit->csnp_interval[0] = (u_int16_t)interval;
-
+
+ circuit->csnp_interval[0] = (u_int16_t) interval;
+
return CMD_SUCCESS;
}
@@ -1764,15 +1875,16 @@ DEFUN (no_csnp_interval_l1,
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
circuit->csnp_interval[0] = CSNP_INTERVAL;
-
+
return CMD_SUCCESS;
}
@@ -1785,7 +1897,6 @@ ALIAS (no_csnp_interval_l1,
"CSNP interval value\n"
"Specify interval for level-1 CSNPs\n")
-
DEFUN (csnp_interval_l2,
csnp_interval_l2_cmd,
"isis csnp-interval <0-65535> level-2",
@@ -1798,17 +1909,18 @@ DEFUN (csnp_interval_l2,
struct interface *ifp;
unsigned long interval;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
interval = atol (argv[0]);
-
- circuit->csnp_interval[1] = (u_int16_t)interval;
-
+
+ circuit->csnp_interval[1] = (u_int16_t) interval;
+
return CMD_SUCCESS;
}
@@ -1823,15 +1935,16 @@ DEFUN (no_csnp_interval_l2,
struct isis_circuit *circuit;
struct interface *ifp;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
-
+
circuit->csnp_interval[1] = CSNP_INTERVAL;
-
+
return CMD_SUCCESS;
}
@@ -1844,7 +1957,6 @@ ALIAS (no_csnp_interval_l2,
"CSNP interval value\n"
"Specify interval for level-2 CSNPs\n")
-
#ifdef HAVE_IPV6
DEFUN (ipv6_router_isis,
ipv6_router_isis_cmd,
@@ -1857,38 +1969,44 @@ DEFUN (ipv6_router_isis,
struct isis_circuit *c;
struct interface *ifp;
struct isis_area *area;
-
- ifp = (struct interface *)vty->index;
+
+ ifp = (struct interface *) vty->index;
assert (ifp);
-
+
area = isis_area_lookup (argv[0]);
/* Prevent more than one circuit per interface */
if (area)
c = circuit_lookup_by_ifp (ifp, area->circuit_list);
- else c = NULL;
-
- if (c && (ifp->info != NULL)) {
- if (c->ipv6_router == 1) {
- vty_out (vty, "ISIS circuit is already defined for IPv6%s", VTY_NEWLINE);
- return CMD_WARNING;
+ else
+ c = NULL;
+
+ if (c && (ifp->info != NULL))
+ {
+ if (c->ipv6_router == 1)
+ {
+ vty_out (vty, "ISIS circuit is already defined for IPv6%s",
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
}
- }
/* this is here for ciscopability */
- if (!area) {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!area)
+ {
+ vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
- if (!c) {
- c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
- c = isis_csm_state_change (ISIS_ENABLE, c, area);
- c->interface = ifp;
- ifp->info = c;
- }
+ if (!c)
+ {
+ c = circuit_lookup_by_ifp (ifp, isis->init_circ_list);
+ c = isis_csm_state_change (ISIS_ENABLE, c, area);
+ c->interface = ifp;
+ ifp->info = c;
+ }
- if(!c)
+ if (!c)
return CMD_WARNING;
c->ipv6_router = 1;
@@ -1912,20 +2030,21 @@ DEFUN (no_ipv6_router_isis,
struct isis_circuit *c;
struct interface *ifp;
struct isis_area *area;
-
- ifp = (struct interface *)vty->index;
+
+ ifp = (struct interface *) vty->index;
/* UGLY - will remove l8r
if (circuit == NULL) {
- return CMD_WARNING;
- } */
+ return CMD_WARNING;
+ } */
assert (ifp);
-
+
area = isis_area_lookup (argv[0]);
- if (!area) {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ if (!area)
+ {
+ vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
c = circuit_lookup_by_ifp (ifp, area->circuit_list);
if (!c)
return CMD_WARNING;
@@ -1938,7 +2057,7 @@ DEFUN (no_ipv6_router_isis,
return CMD_SUCCESS;
}
-#if 0 /* Guess we don't really need these */
+#if 0 /* Guess we don't really need these */
DEFUN (ipv6_address,
ipv6_address_cmd,
@@ -1953,46 +2072,52 @@ DEFUN (ipv6_address,
struct listnode *node;
int ret, found = 1;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
/* UGLY - will remove l8r */
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
#ifdef EXTREME_DEBUG
zlog_info ("ipv6_address_cmd circuit %d", circuit->idx);
#endif /* EXTREME_DEBUG */
-
- if (circuit == NULL) {
- zlog_warn ("ipv6_address_cmd(): no circuit");
- return CMD_WARNING;
- }
-
-
+
+ if (circuit == NULL)
+ {
+ zlog_warn ("ipv6_address_cmd(): no circuit");
+ return CMD_WARNING;
+ }
+
+
ipv6 = prefix_ipv6_new ();
-
+
ret = str2prefix_ipv6 (argv[0], ipv6);
- if (ret <= 0) {
- vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- if (!circuit->ipv6_addrs)
- circuit->ipv6_addrs = list_new ();
- else {
- for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) {
- ip6 = getdata (node);
- if (prefix_same ((struct prefix *)ip6, (struct prefix *)ipv6))
- found = 1;
+ if (ret <= 0)
+ {
+ vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
+ return CMD_WARNING;
}
- if (found) {
- prefix_ipv6_free (ipv6);
- return CMD_SUCCESS;
+
+ if (!circuit->ipv6_addrs)
+ circuit->ipv6_addrs = list_new ();
+ else
+ {
+ for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
+ {
+ ip6 = getdata (node);
+ if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
+ found = 1;
+ }
+ if (found)
+ {
+ prefix_ipv6_free (ipv6);
+ return CMD_SUCCESS;
+ }
}
- }
-
+
listnode_add (circuit->ipv6_addrs, ipv6);
#ifdef EXTREME_DEBUG
zlog_info ("added IPv6 address %s to circuit %d", argv[0], circuit->idx);
@@ -2003,7 +2128,7 @@ DEFUN (ipv6_address,
DEFUN (no_ipv6_address,
no_ipv6_address_cmd,
- "no ipv6 address X:X::X:X/M",
+ "no ipv6 address X:X::X:X/M",
NO_STR
"Interface Internet Protocol config commands\n"
"Set the IP address of an interface\n"
@@ -2015,50 +2140,54 @@ DEFUN (no_ipv6_address,
struct listnode *node;
int ret;
- ifp = vty->index;
+ ifp = vty->index;
circuit = ifp->info;
/* UGLY - will remove l8r */
- if (circuit == NULL) {
- return CMD_WARNING;
- }
+ if (circuit == NULL)
+ {
+ return CMD_WARNING;
+ }
assert (circuit);
- if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0) {
- vty_out (vty, "Invalid address %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!circuit->ipv6_addrs || circuit->ipv6_addrs->count == 0)
+ {
+ vty_out (vty, "Invalid address %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
ret = str2prefix_ipv6 (argv[0], &ipv6);
- if (ret <= 0) {
- vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- for (node = listhead (circuit->ipv6_addrs); node; nextnode (node)) {
- ip6 = getdata (node);
- if (prefix_same ((struct prefix *)ip6, (struct prefix *)&ipv6))
- break;
- }
-
- if (ip6) {
- listnode_delete (circuit->ipv6_addrs, ip6);
- } else {
- vty_out (vty, "Invalid address %s", VTY_NEWLINE);
- }
-
+ if (ret <= 0)
+ {
+ vty_out (vty, "%% Malformed address %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ for (node = listhead (circuit->ipv6_addrs); node; nextnode (node))
+ {
+ ip6 = getdata (node);
+ if (prefix_same ((struct prefix *) ip6, (struct prefix *) &ipv6))
+ break;
+ }
+
+ if (ip6)
+ {
+ listnode_delete (circuit->ipv6_addrs, ip6);
+ }
+ else
+ {
+ vty_out (vty, "Invalid address %s", VTY_NEWLINE);
+ }
+
return CMD_SUCCESS;
}
#endif /* 0 */
-#endif /* HAVE_IPV6 */
-
+#endif /* HAVE_IPV6 */
-struct cmd_node interface_node =
-{
+struct cmd_node interface_node = {
INTERFACE_NODE,
"%s(config-if)# ",
1,
};
-
int
isis_if_new_hook (struct interface *ifp)
{
@@ -2077,11 +2206,9 @@ isis_if_delete_hook (struct interface *ifp)
return 0;
}
-
void
isis_circuit_init ()
{
-
/* Initialize Zebra interface data structure */
if_init ();
if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
@@ -2162,5 +2289,4 @@ isis_circuit_init ()
install_element (INTERFACE_NODE, &no_ipv6_address_cmd);
#endif
#endif
-
}
diff --git a/isisd/isis_circuit.h b/isisd/isis_circuit.h
index 7163c5b99..484c05759 100644
--- a/isisd/isis_circuit.h
+++ b/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 */
diff --git a/isisd/isis_common.h b/isisd/isis_common.h
index 951e6371b..7a0768a8c 100644
--- a/isisd/isis_common.h
+++ b/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;
};
diff --git a/isisd/isis_constants.h b/isisd/isis_constants.h
index c732bfc46..1b75ba6b1 100644
--- a/isisd/isis_constants.h
+++ b/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 */
diff --git a/isisd/isis_csm.c b/isisd/isis_csm.c
index b20579037..8f44db15a 100644
--- a/isisd/isis_csm.c
+++ b/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;
}
-
-
-
diff --git a/isisd/isis_csm.h b/isisd/isis_csm.h
index 23cc21508..d6b13ac69 100644
--- a/isisd/isis_csm.h
+++ b/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 */
diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c
index a2fddcce8..b44d2123f 100644
--- a/isisd/isis_dr.c
+++ b/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;
}
-
diff --git a/isisd/isis_dr.h b/isisd/isis_dr.h
index 73d9cd38c..b0386d4dc 100644
--- a/isisd/isis_dr.h
+++ b/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 */
-
diff --git a/isisd/isis_dynhn.c b/isisd/isis_dynhn.c
index 6b1d27b9a..41c363714 100644
--- a/isisd/isis_dynhn.c
+++ b/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;
}
-
diff --git a/isisd/isis_dynhn.h b/isisd/isis_dynhn.h
index 2a7f3ec96..37a7b03c0 100644
--- a/isisd/isis_dynhn.h
+++ b/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 */
-
-
-
-
diff --git a/isisd/isis_events.c b/isisd/isis_events.c
index be136e264..a99869b92 100644
--- a/isisd/isis_events.c
+++ b/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;
}
-
diff --git a/isisd/isis_events.h b/isisd/isis_events.h
index 75dd92e8b..a6ec2e8cf 100644
--- a/isisd/isis_events.h
+++ b/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 */
-
diff --git a/isisd/isis_flags.c b/isisd/isis_flags.c
index 716bee054..0ef048e2c 100644
--- a/isisd/isis_flags.c
+++ b/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);
}
diff --git a/isisd/isis_flags.h b/isisd/isis_flags.h
index 66b94848d..f2421f2f4 100644
--- a/isisd/isis_flags.h
+++ b/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 flags_any_set (u_int32_t *flags);
+int flags_any_set (u_int32_t * flags);
#define ISIS_SET_FLAG(F,C) \
F[C->idx>>5] |= (1<<(C->idx & 0x1F));
@@ -50,9 +50,3 @@ int flags_any_set (u_int32_t *flags);
memset(FLAGS,0x00,ISIS_MAX_CIRCUITS*4);
#endif /* _ZEBRA_ISIS_FLAGS_H */
-
-
-
-
-
-
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index a29ba8031..214b438c1 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -55,46 +55,47 @@
#include "spgrid.h"
#endif
-#define LSP_MEMORY_PREASSIGN
+#define LSP_MEMORY_PREASSIGN
extern struct isis *isis;
extern struct thread_master *master;
-int
-lsp_id_cmp (u_char *id1, u_char *id2)
-{
+int
+lsp_id_cmp (u_char * id1, u_char * id2)
+{
return memcmp (id1, id2, ISIS_SYS_ID_LEN + 2);
}
dict_t *
-lsp_db_init (void)
+lsp_db_init (void)
{
dict_t *dict;
-
- dict = dict_create (DICTCOUNT_T_MAX, (dict_comp_t)lsp_id_cmp);
-
+
+ dict = dict_create (DICTCOUNT_T_MAX, (dict_comp_t) lsp_id_cmp);
+
return dict;
}
struct isis_lsp *
-lsp_search (u_char *id, dict_t *lspdb)
+lsp_search (u_char * id, dict_t * lspdb)
{
dnode_t *node;
-#ifdef EXTREME_DEBUG
+#ifdef EXTREME_DEBUG
dnode_t *dn;
- zlog_warn("searching db");
- for (dn = dict_first(lspdb); dn; dn = dict_next(lspdb, dn)) {
- zlog_warn("%s\t%pX", rawlspid_print((char *) dnode_getkey(dn)),
- dnode_get(dn));
- }
+ zlog_warn ("searching db");
+ for (dn = dict_first (lspdb); dn; dn = dict_next (lspdb, dn))
+ {
+ zlog_warn ("%s\t%pX", rawlspid_print ((char *) dnode_getkey (dn)),
+ dnode_get (dn));
+ }
#endif /* EXTREME DEBUG */
node = dict_lookup (lspdb, id);
-
+
if (node)
- return (struct isis_lsp *)dnode_get (node);
+ return (struct isis_lsp *) dnode_get (node);
return NULL;
}
@@ -104,13 +105,14 @@ lsp_clear_data (struct isis_lsp *lsp)
{
if (!lsp)
return;
-
- if (lsp->own_lsp) {
- if (lsp->tlv_data.nlpids)
- XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.nlpids);
- if (lsp->tlv_data.hostname)
- XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.hostname);
- }
+
+ if (lsp->own_lsp)
+ {
+ if (lsp->tlv_data.nlpids)
+ XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.nlpids);
+ if (lsp->tlv_data.hostname)
+ XFREE (MTYPE_ISIS_TLV, lsp->tlv_data.hostname);
+ }
if (lsp->tlv_data.is_neighs)
list_delete (lsp->tlv_data.is_neighs);
if (lsp->tlv_data.area_addrs)
@@ -140,35 +142,37 @@ lsp_destroy (struct isis_lsp *lsp)
{
if (!lsp)
return;
-
+
lsp_clear_data (lsp);
-
- if (LSP_FRAGMENT (lsp->lsp_header->lsp_id) == 0 && lsp->lspu.frags) {
+
+ if (LSP_FRAGMENT (lsp->lsp_header->lsp_id) == 0 && lsp->lspu.frags)
+ {
list_delete (lsp->lspu.frags);
- }
-
+ }
+
if (lsp->pdu)
stream_free (lsp->pdu);
XFREE (MTYPE_ISIS_LSP, lsp);
}
-void
-lsp_db_destroy (dict_t *lspdb)
+void
+lsp_db_destroy (dict_t * lspdb)
{
dnode_t *dnode, *next;
struct isis_lsp *lsp;
-
+
dnode = dict_first (lspdb);
- while (dnode) {
- next = dict_next (lspdb, dnode);
- lsp = dnode_get (dnode);
- lsp_destroy (lsp);
- dict_delete_free (lspdb, dnode);
- dnode = next;
- }
-
+ while (dnode)
+ {
+ next = dict_next (lspdb, dnode);
+ lsp = dnode_get (dnode);
+ lsp_destroy (lsp);
+ dict_delete_free (lspdb, dnode);
+ dnode = next;
+ }
+
dict_free (lspdb);
-
+
return;
}
@@ -176,133 +180,136 @@ lsp_db_destroy (dict_t *lspdb)
* Remove all the frags belonging to the given lsp
*/
void
-lsp_remove_frags (struct list *frags, dict_t *lspdb)
+lsp_remove_frags (struct list *frags, dict_t * lspdb)
{
dnode_t *dnode;
struct listnode *lnode;
struct isis_lsp *lsp;
- for (lnode = listhead (frags); lnode; nextnode (lnode)) {
- lsp = getdata (lnode);
- dnode = dict_lookup (lspdb, lsp->lsp_header->lsp_id);
- lsp_destroy (lsp);
- dnode_destroy (dict_delete(lspdb, dnode));
- }
-
+ for (lnode = listhead (frags); lnode; nextnode (lnode))
+ {
+ lsp = getdata (lnode);
+ dnode = dict_lookup (lspdb, lsp->lsp_header->lsp_id);
+ lsp_destroy (lsp);
+ dnode_destroy (dict_delete (lspdb, dnode));
+ }
+
list_delete_all_node (frags);
-
+
return;
}
void
-lsp_search_and_destroy (u_char *id, dict_t *lspdb)
+lsp_search_and_destroy (u_char * id, dict_t * lspdb)
{
dnode_t *node;
struct isis_lsp *lsp;
node = dict_lookup (lspdb, id);
- if (node) {
- node = dict_delete (lspdb, node);
- lsp = dnode_get (node);
- /*
- * If this is a zero lsp, remove all the frags now
- */
- if (LSP_FRAGMENT(lsp->lsp_header->lsp_id) == 0) {
- if (lsp->lspu.frags)
- lsp_remove_frags (lsp->lspu.frags, lspdb);
- } else {
- /*
- * else just remove this frag, from the zero lsps' frag list
- */
- if (lsp->lspu.zero_lsp && lsp->lspu.zero_lsp->lspu.frags)
- listnode_delete (lsp->lspu.zero_lsp->lspu.frags, lsp);
- }
- lsp_destroy (lsp);
- dnode_destroy (node);
- }
+ if (node)
+ {
+ node = dict_delete (lspdb, node);
+ lsp = dnode_get (node);
+ /*
+ * If this is a zero lsp, remove all the frags now
+ */
+ if (LSP_FRAGMENT (lsp->lsp_header->lsp_id) == 0)
+ {
+ if (lsp->lspu.frags)
+ lsp_remove_frags (lsp->lspu.frags, lspdb);
+ }
+ else
+ {
+ /*
+ * else just remove this frag, from the zero lsps' frag list
+ */
+ if (lsp->lspu.zero_lsp && lsp->lspu.zero_lsp->lspu.frags)
+ listnode_delete (lsp->lspu.zero_lsp->lspu.frags, lsp);
+ }
+ lsp_destroy (lsp);
+ dnode_destroy (node);
+ }
}
/*
* Compares a LSP to given values
* Params are given in net order
*/
-int
-lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num,
+int
+lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num,
u_int16_t checksum, u_int16_t rem_lifetime)
{
- /* no point in double ntohl on seqnum */
- if (lsp->lsp_header->seq_num == seq_num &&
+ /* no point in double ntohl on seqnum */
+ if (lsp->lsp_header->seq_num == seq_num &&
lsp->lsp_header->checksum == checksum &&
/*comparing with 0, no need to do ntohl */
((lsp->lsp_header->rem_lifetime == 0 && rem_lifetime == 0) ||
- (lsp->lsp_header->rem_lifetime != 0 && rem_lifetime != 0))) {
- if (isis->debugs & DEBUG_SNP_PACKETS) {
- zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x,"
- " lifetime %us",
- areatag,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl(lsp->lsp_header->seq_num),
- ntohs(lsp->lsp_header->checksum),
- ntohs(lsp->lsp_header->rem_lifetime) );
- zlog_info ("ISIS-Snp (%s): is equal to ours seq 0x%08x,"
- " cksum 0x%04x, lifetime %us",
- areatag,
- ntohl(seq_num),
- ntohs(checksum),
- ntohs(rem_lifetime));
- }
- return LSP_EQUAL;
- }
+ (lsp->lsp_header->rem_lifetime != 0 && rem_lifetime != 0)))
+ {
+ if (isis->debugs & DEBUG_SNP_PACKETS)
+ {
+ zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x,"
+ " lifetime %us",
+ areatag,
+ rawlspid_print (lsp->lsp_header->lsp_id),
+ ntohl (lsp->lsp_header->seq_num),
+ ntohs (lsp->lsp_header->checksum),
+ ntohs (lsp->lsp_header->rem_lifetime));
+ zlog_info ("ISIS-Snp (%s): is equal to ours seq 0x%08x,"
+ " cksum 0x%04x, lifetime %us",
+ areatag,
+ ntohl (seq_num), ntohs (checksum), ntohs (rem_lifetime));
+ }
+ return LSP_EQUAL;
+ }
- if (ntohl(seq_num) >= ntohl(lsp->lsp_header->seq_num)) {
- if (isis->debugs & DEBUG_SNP_PACKETS) {
- zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x,"
- " lifetime %us",
- areatag,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl(seq_num),
- ntohs(checksum),
- ntohs(rem_lifetime ));
- zlog_info ("ISIS-Snp (%s): is newer than ours seq 0x%08x, "
- "cksum 0x%04x, lifetime %us",
- areatag,
- ntohl(lsp->lsp_header->seq_num),
- ntohs(lsp->lsp_header->checksum),
- ntohs(lsp->lsp_header->rem_lifetime) );
- }
- return LSP_NEWER;
- }
- if (isis->debugs & DEBUG_SNP_PACKETS) {
- zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x, lifetime %us",
- areatag,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl(seq_num),
- ntohs(checksum),
- ntohs(rem_lifetime ));
- zlog_info ("ISIS-Snp (%s): is older than ours seq 0x%08x,"
- " cksum 0x%04x, lifetime %us",
- areatag,
- ntohl(lsp->lsp_header->seq_num),
- ntohs(lsp->lsp_header->checksum),
- ntohs(lsp->lsp_header->rem_lifetime) );
- }
+ if (ntohl (seq_num) >= ntohl (lsp->lsp_header->seq_num))
+ {
+ if (isis->debugs & DEBUG_SNP_PACKETS)
+ {
+ zlog_info ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x,"
+ " lifetime %us",
+ areatag,
+ rawlspid_print (lsp->lsp_header->lsp_id),
+ ntohl (seq_num), ntohs (checksum), ntohs (rem_lifetime));
+ zlog_info ("ISIS-Snp (%s): is newer than ours seq 0x%08x, "
+ "cksum 0x%04x, lifetime %us",
+ areatag,
+ ntohl (lsp->lsp_header->seq_num),
+ ntohs (lsp->lsp_header->checksum),
+ ntohs (lsp->lsp_header->rem_lifetime));
+ }
+ return LSP_NEWER;
+ }
+ if (isis->debugs & DEBUG_SNP_PACKETS)
+ {
+ zlog_info
+ ("ISIS-Snp (%s): LSP %s seq 0x%08x, cksum 0x%04x, lifetime %us",
+ areatag, rawlspid_print (lsp->lsp_header->lsp_id), ntohl (seq_num),
+ ntohs (checksum), ntohs (rem_lifetime));
+ zlog_info ("ISIS-Snp (%s): is older than ours seq 0x%08x,"
+ " cksum 0x%04x, lifetime %us", areatag,
+ ntohl (lsp->lsp_header->seq_num),
+ ntohs (lsp->lsp_header->checksum),
+ ntohs (lsp->lsp_header->rem_lifetime));
+ }
return LSP_OLDER;
}
-void
+void
lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num)
{
u_int32_t newseq;
-
+
if (seq_num == 0 || ntohl (lsp->lsp_header->seq_num) > seq_num)
newseq = ntohl (lsp->lsp_header->seq_num) + 1;
else
- newseq = seq_num ++;
-
+ newseq = seq_num++;
+
lsp->lsp_header->seq_num = htonl (newseq);
- iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
- ntohs(lsp->lsp_header->pdu_len) - 12, 12);
+ iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
+ ntohs (lsp->lsp_header->pdu_len) - 12, 12);
return;
}
@@ -315,23 +322,24 @@ lsp_seqnum_update (struct isis_lsp *lsp0)
{
struct isis_lsp *lsp;
struct listnode *node;
-
+
lsp_inc_seqnum (lsp0, 0);
if (!lsp0->lspu.frags)
return;
- for (node = listhead (lsp0->lspu.frags); node; nextnode (node)) {
- lsp = getdata (node);
- lsp_inc_seqnum(lsp, 0);
- }
-
+ for (node = listhead (lsp0->lspu.frags); node; nextnode (node))
+ {
+ lsp = getdata (node);
+ lsp_inc_seqnum (lsp, 0);
+ }
+
return;
}
-int
+int
isis_lsp_authinfo_check (struct stream *stream, struct isis_area *area,
- int pdulen, struct isis_passwd *passwd)
+ int pdulen, struct isis_passwd *passwd)
{
uint32_t expected = 0, found;
struct tlvs tlvs;
@@ -339,23 +347,22 @@ isis_lsp_authinfo_check (struct stream *stream, struct isis_area *area,
expected |= TLVFLAG_AUTH_INFO;
retval = parse_tlvs (area->area_tag, stream->data +
- ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN,
- pdulen - ISIS_FIXED_HDR_LEN
- - ISIS_LSP_HDR_LEN,
- &expected, &found, &tlvs);
+ ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN,
+ pdulen - ISIS_FIXED_HDR_LEN
+ - ISIS_LSP_HDR_LEN, &expected, &found, &tlvs);
if (retval || !(found & TLVFLAG_AUTH_INFO))
- return 1; /* Auth fail (parsing failed or no auth-tlv)*/
+ return 1; /* Auth fail (parsing failed or no auth-tlv) */
return authentication_check (passwd, &tlvs.auth_info);
}
void
-lsp_update_data (struct isis_lsp *lsp, struct stream *stream,
- struct isis_area *area)
+lsp_update_data (struct isis_lsp *lsp, struct stream *stream,
+ struct isis_area *area)
{
- uint32_t expected = 0,found;
+ uint32_t expected = 0, found;
int retval;
-
+
/* copying only the relevant part of our stream */
lsp->pdu = stream_new (stream->endp);
lsp->pdu->putp = stream->putp;
@@ -364,27 +371,28 @@ lsp_update_data (struct isis_lsp *lsp, struct stream *stream,
memcpy (lsp->pdu->data, stream->data, stream->endp);
/* setting pointers to the correct place */
- lsp->isis_header = (struct isis_fixed_hdr *)(STREAM_DATA(lsp->pdu));
- lsp->lsp_header = (struct isis_link_state_hdr *)(STREAM_DATA(lsp->pdu) +
- ISIS_FIXED_HDR_LEN);
+ lsp->isis_header = (struct isis_fixed_hdr *) (STREAM_DATA (lsp->pdu));
+ lsp->lsp_header = (struct isis_link_state_hdr *) (STREAM_DATA (lsp->pdu) +
+ ISIS_FIXED_HDR_LEN);
lsp->age_out = ZERO_AGE_LIFETIME;
- lsp->installed = time(NULL);
+ lsp->installed = time (NULL);
/*
* Get LSP data i.e. TLVs
*/
expected |= TLVFLAG_AUTH_INFO;
expected |= TLVFLAG_AREA_ADDRS;
expected |= TLVFLAG_IS_NEIGHS;
- if ((lsp->lsp_header->lsp_bits & 3) == 3) /* a level 2 LSP */
+ if ((lsp->lsp_header->lsp_bits & 3) == 3) /* a level 2 LSP */
expected |= TLVFLAG_PARTITION_DESIG_LEVEL2_IS;
expected |= TLVFLAG_NLPID;
if (area->dynhostname)
expected |= TLVFLAG_DYN_HOSTNAME;
- if (area->newmetric) {
- expected |= TLVFLAG_TE_IS_NEIGHS;
- expected |= TLVFLAG_TE_IPV4_REACHABILITY;
- expected |= TLVFLAG_TE_ROUTER_ID;
- }
+ if (area->newmetric)
+ {
+ expected |= TLVFLAG_TE_IS_NEIGHS;
+ expected |= TLVFLAG_TE_IPV4_REACHABILITY;
+ expected |= TLVFLAG_TE_ROUTER_ID;
+ }
expected |= TLVFLAG_IPV4_ADDR;
expected |= TLVFLAG_IPV4_INT_REACHABILITY;
expected |= TLVFLAG_IPV4_EXT_REACHABILITY;
@@ -394,101 +402,103 @@ lsp_update_data (struct isis_lsp *lsp, struct stream *stream,
#endif /* HAVE_IPV6 */
retval = parse_tlvs (area->area_tag, lsp->pdu->data +
- ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN,
- ntohs(lsp->lsp_header->pdu_len) - ISIS_FIXED_HDR_LEN
- - ISIS_LSP_HDR_LEN, &expected, &found, &lsp->tlv_data);
-
- if (found & TLVFLAG_DYN_HOSTNAME) {
- if (area->dynhostname)
- isis_dynhn_insert (lsp->lsp_header->lsp_id, lsp->tlv_data.hostname,
- (lsp->lsp_header->lsp_bits & LSPBIT_IST) ==
- IS_LEVEL_1_AND_2 ? IS_LEVEL_2 :
- (lsp->lsp_header->lsp_bits & LSPBIT_IST));
- }
+ ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN,
+ ntohs (lsp->lsp_header->pdu_len) - ISIS_FIXED_HDR_LEN
+ - ISIS_LSP_HDR_LEN, &expected, &found, &lsp->tlv_data);
+
+ if (found & TLVFLAG_DYN_HOSTNAME)
+ {
+ if (area->dynhostname)
+ isis_dynhn_insert (lsp->lsp_header->lsp_id, lsp->tlv_data.hostname,
+ (lsp->lsp_header->lsp_bits & LSPBIT_IST) ==
+ IS_LEVEL_1_AND_2 ? IS_LEVEL_2 :
+ (lsp->lsp_header->lsp_bits & LSPBIT_IST));
+ }
}
void
lsp_update (struct isis_lsp *lsp, struct isis_link_state_hdr *lsp_hdr,
- struct stream *stream, struct isis_area *area)
+ struct stream *stream, struct isis_area *area)
{
-
- /* free the old lsp data*/
+ /* free the old lsp data */
XFREE (MTYPE_STREAM_DATA, lsp->pdu);
lsp_clear_data (lsp);
/* rebuild the lsp data */
lsp_update_data (lsp, stream, area);
- /* set the new values for lsp header */
+ /* set the new values for lsp header */
memcpy (lsp->lsp_header, lsp_hdr, ISIS_LSP_HDR_LEN);
-
}
-
/* creation of LSP directly from what we received */
struct isis_lsp *
-lsp_new_from_stream_ptr (struct stream *stream,
- u_int16_t pdu_len, struct isis_lsp *lsp0,
- struct isis_area *area)
+lsp_new_from_stream_ptr (struct stream *stream,
+ u_int16_t pdu_len, struct isis_lsp *lsp0,
+ struct isis_area *area)
{
struct isis_lsp *lsp;
lsp = XMALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp));
memset (lsp, 0, sizeof (struct isis_lsp));
-
+
lsp_update_data (lsp, stream, area);
-
- if (lsp0 == NULL) {
- /*
- * zero lsp -> create the list for fragments
- */
- lsp->lspu.frags = list_new ();
- } else {
- /*
- * a fragment -> set the backpointer and add this to zero lsps frag list
- */
- lsp->lspu.zero_lsp = lsp0;
- listnode_add (lsp0->lspu.frags, lsp);
- }
-
+
+ if (lsp0 == NULL)
+ {
+ /*
+ * zero lsp -> create the list for fragments
+ */
+ lsp->lspu.frags = list_new ();
+ }
+ else
+ {
+ /*
+ * a fragment -> set the backpointer and add this to zero lsps frag list
+ */
+ lsp->lspu.zero_lsp = lsp0;
+ listnode_add (lsp0->lspu.frags, lsp);
+ }
+
return lsp;
}
struct isis_lsp *
-lsp_new (u_char *lsp_id, u_int16_t rem_lifetime, u_int32_t seq_num,
- u_int8_t lsp_bits, u_int16_t checksum, int level)
+lsp_new (u_char * lsp_id, u_int16_t rem_lifetime, u_int32_t seq_num,
+ u_int8_t lsp_bits, u_int16_t checksum, int level)
{
struct isis_lsp *lsp;
lsp = XMALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp));
- if (!lsp) {
- /* FIXME: set lspdbol bit */
- zlog_warn ("lsp_new(): out of memory");
- return NULL;
- }
+ if (!lsp)
+ {
+ /* FIXME: set lspdbol bit */
+ zlog_warn ("lsp_new(): out of memory");
+ return NULL;
+ }
memset (lsp, 0, sizeof (struct isis_lsp));
#ifdef LSP_MEMORY_PREASSIGN
- lsp->pdu = stream_new (1514); /*Should be minimal mtu? yup...*/
+ lsp->pdu = stream_new (1514); /*Should be minimal mtu? yup... */
#else
- /* We need to do realloc on TLVs additions*/
- lsp->pdu = malloc (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+ /* We need to do realloc on TLVs additions */
+ lsp->pdu = malloc (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
#endif /* LSP_MEMORY_PREASSIGN */
if (LSP_FRAGMENT (lsp_id) == 0)
lsp->lspu.frags = list_new ();
- lsp->isis_header = (struct isis_fixed_hdr*)(STREAM_DATA(lsp->pdu));
- lsp->lsp_header = (struct isis_link_state_hdr*)
- (STREAM_DATA(lsp->pdu) + ISIS_FIXED_HDR_LEN);
-
+ lsp->isis_header = (struct isis_fixed_hdr *) (STREAM_DATA (lsp->pdu));
+ lsp->lsp_header = (struct isis_link_state_hdr *)
+ (STREAM_DATA (lsp->pdu) + ISIS_FIXED_HDR_LEN);
+
/* at first we fill the FIXED HEADER */
- (level == 1) ? fill_fixed_hdr (lsp->isis_header, L1_LINK_STATE):
- fill_fixed_hdr (lsp->isis_header, L2_LINK_STATE);
-
+ (level == 1) ? fill_fixed_hdr (lsp->isis_header, L1_LINK_STATE) :
+ fill_fixed_hdr (lsp->isis_header, L2_LINK_STATE);
+
/* now for the LSP HEADER */
/* Minimal LSP PDU size */
- lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+ lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
memcpy (lsp->lsp_header->lsp_id, lsp_id, ISIS_SYS_ID_LEN + 2);
- lsp->lsp_header->checksum = checksum; /* Provided in network order */
+ lsp->lsp_header->checksum = checksum; /* Provided in network order */
lsp->lsp_header->seq_num = htonl (seq_num);
lsp->lsp_header->rem_lifetime = htons (rem_lifetime);
lsp->lsp_header->lsp_bits = lsp_bits;
@@ -500,16 +510,16 @@ lsp_new (u_char *lsp_id, u_int16_t rem_lifetime, u_int32_t seq_num,
/* #ifdef EXTREME_DEBUG */
/* logging */
zlog_info ("New LSP with ID %s-%02x-%02x seqnum %08x", sysid_print (lsp_id),
- LSP_PSEUDO_ID (lsp->lsp_header->lsp_id),
- LSP_FRAGMENT (lsp->lsp_header->lsp_id),
- ntohl (lsp->lsp_header->seq_num));
+ LSP_PSEUDO_ID (lsp->lsp_header->lsp_id),
+ LSP_FRAGMENT (lsp->lsp_header->lsp_id),
+ ntohl (lsp->lsp_header->seq_num));
/* #endif EXTREME DEBUG */
return lsp;
}
void
-lsp_insert (struct isis_lsp *lsp, dict_t *lspdb)
+lsp_insert (struct isis_lsp *lsp, dict_t * lspdb)
{
dict_alloc_insert (lspdb, lsp->lsp_header->lsp_id, lsp);
}
@@ -517,62 +527,64 @@ lsp_insert (struct isis_lsp *lsp, dict_t *lspdb)
/*
* Build a list of LSPs with non-zero ht bounded by start and stop ids
*/
-void
-lsp_build_list_nonzero_ht (u_char *start_id, u_char *stop_id,
- struct list *list, dict_t *lspdb)
+void
+lsp_build_list_nonzero_ht (u_char * start_id, u_char * stop_id,
+ struct list *list, dict_t * lspdb)
{
dnode_t *first, *last, *curr;
first = dict_lower_bound (lspdb, start_id);
if (!first)
return;
-
+
last = dict_upper_bound (lspdb, stop_id);
-
+
curr = first;
-
- if (((struct isis_lsp *)(curr->dict_data))->lsp_header->rem_lifetime)
+
+ if (((struct isis_lsp *) (curr->dict_data))->lsp_header->rem_lifetime)
listnode_add (list, first->dict_data);
- while (curr) {
- curr = dict_next (lspdb, curr);
- if (curr &&
- ((struct isis_lsp *)(curr->dict_data))->lsp_header->rem_lifetime)
- listnode_add (list, curr->dict_data);
- if (curr == last)
- break;
- }
-
+ while (curr)
+ {
+ curr = dict_next (lspdb, curr);
+ if (curr &&
+ ((struct isis_lsp *) (curr->dict_data))->lsp_header->rem_lifetime)
+ listnode_add (list, curr->dict_data);
+ if (curr == last)
+ break;
+ }
+
return;
}
/*
* Build a list of all LSPs bounded by start and stop ids
*/
-void
-lsp_build_list (u_char *start_id, u_char *stop_id,
- struct list *list, dict_t *lspdb)
+void
+lsp_build_list (u_char * start_id, u_char * stop_id,
+ struct list *list, dict_t * lspdb)
{
dnode_t *first, *last, *curr;
first = dict_lower_bound (lspdb, start_id);
if (!first)
return;
-
+
last = dict_upper_bound (lspdb, stop_id);
-
+
curr = first;
-
+
listnode_add (list, first->dict_data);
- while (curr) {
- curr = dict_next (lspdb, curr);
- if (curr)
- listnode_add (list, curr->dict_data);
- if (curr == last)
- break;
- }
-
+ while (curr)
+ {
+ curr = dict_next (lspdb, curr);
+ if (curr)
+ listnode_add (list, curr->dict_data);
+ if (curr == last)
+ break;
+ }
+
return;
}
@@ -580,21 +592,22 @@ lsp_build_list (u_char *start_id, u_char *stop_id,
* Build a list of LSPs with SSN flag set for the given circuit
*/
void
-lsp_build_list_ssn (struct isis_circuit *circuit, struct list *list,
- dict_t *lspdb)
+lsp_build_list_ssn (struct isis_circuit *circuit, struct list *list,
+ dict_t * lspdb)
{
dnode_t *dnode, *next;
struct isis_lsp *lsp;
-
+
dnode = dict_first (lspdb);
- while (dnode != NULL) {
- next = dict_next (lspdb, dnode);
- lsp = dnode_get (dnode);
- if (ISIS_CHECK_FLAG (lsp->SSNflags, circuit))
- listnode_add (list, lsp);
- dnode = next;
- }
-
+ while (dnode != NULL)
+ {
+ next = dict_next (lspdb, dnode);
+ lsp = dnode_get (dnode);
+ if (ISIS_CHECK_FLAG (lsp->SSNflags, circuit))
+ listnode_add (list, lsp);
+ dnode = next;
+ }
+
return;
}
@@ -602,31 +615,34 @@ void
lsp_set_time (struct isis_lsp *lsp)
{
assert (lsp);
-
- if (lsp->lsp_header->rem_lifetime == 0) {
- if (lsp->age_out != 0) lsp->age_out--;
- return;
- }
+
+ if (lsp->lsp_header->rem_lifetime == 0)
+ {
+ if (lsp->age_out != 0)
+ lsp->age_out--;
+ return;
+ }
/* If we are turning 0 */
/* ISO 10589 - 7.3.16.4 first paragraph */
- if (ntohs (lsp->lsp_header->rem_lifetime) == 1) {
- /* 7.3.16.4 a) set SRM flags on all */
- ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- /* 7.3.16.4 b) retain only the header FIXME */
- /* 7.3.16.4 c) record the time to purge FIXME (other way to do it)*/
- }
+ if (ntohs (lsp->lsp_header->rem_lifetime) == 1)
+ {
+ /* 7.3.16.4 a) set SRM flags on all */
+ ISIS_FLAGS_SET_ALL (lsp->SRMflags);
+ /* 7.3.16.4 b) retain only the header FIXME */
+ /* 7.3.16.4 c) record the time to purge FIXME (other way to do it) */
+ }
- lsp->lsp_header->rem_lifetime =
+ lsp->lsp_header->rem_lifetime =
htons (ntohs (lsp->lsp_header->rem_lifetime) - 1);
}
void
-lspid_print (u_char *lsp_id, u_char *trg, char dynhost, char frag)
+lspid_print (u_char * lsp_id, u_char * trg, char dynhost, char frag)
{
struct isis_dynhn *dyn = NULL;
- u_char id [SYSID_STRLEN];
+ u_char id[SYSID_STRLEN];
if (dynhost)
dyn = dynhn_find_by_id (lsp_id);
@@ -636,74 +652,69 @@ lspid_print (u_char *lsp_id, u_char *trg, char dynhost, char frag)
if (dyn)
sprintf (id, "%.14s", dyn->name.name);
else if (!memcmp (isis->sysid, lsp_id, ISIS_SYS_ID_LEN) & dynhost)
- sprintf (id, "%.14s", unix_hostname());
- else {
- memcpy(id, sysid_print (lsp_id), 15);
- }
+ sprintf (id, "%.14s", unix_hostname ());
+ else
+ {
+ memcpy (id, sysid_print (lsp_id), 15);
+ }
if (frag)
- sprintf (trg, "%s.%02x-%02x", id, LSP_PSEUDO_ID(lsp_id),
- LSP_FRAGMENT(lsp_id));
+ sprintf (trg, "%s.%02x-%02x", id, LSP_PSEUDO_ID (lsp_id),
+ LSP_FRAGMENT (lsp_id));
else
- sprintf (trg, "%s.%02x", id, LSP_PSEUDO_ID(lsp_id));
+ sprintf (trg, "%s.%02x", id, LSP_PSEUDO_ID (lsp_id));
}
-/* Convert the lsp attribute bits to attribute string */
-char *
-lsp_bits2string (u_char *lsp_bits) {
-
- char *pos = lsp_bits_string;
+/* Convert the lsp attribute bits to attribute string */
+char *
+lsp_bits2string (u_char * lsp_bits)
+{
+ char *pos = lsp_bits_string;
- if(!*lsp_bits)
+ if (!*lsp_bits)
return " none";
/* we only focus on the default metric */
pos += sprintf (pos, "%d/",
- ISIS_MASK_LSP_ATT_DEFAULT_BIT(*lsp_bits) ?
- 1 : 0);
+ ISIS_MASK_LSP_ATT_DEFAULT_BIT (*lsp_bits) ? 1 : 0);
pos += sprintf (pos, "%d/",
- ISIS_MASK_LSP_PARTITION_BIT(*lsp_bits) ?
- 1 : 0);
+ ISIS_MASK_LSP_PARTITION_BIT (*lsp_bits) ? 1 : 0);
+
+ pos += sprintf (pos, "%d", ISIS_MASK_LSP_OL_BIT (*lsp_bits) ? 1 : 0);
- pos += sprintf (pos, "%d",
- ISIS_MASK_LSP_OL_BIT(*lsp_bits) ?
- 1 : 0);
-
*(pos) = '\0';
-
- return lsp_bits_string;
+ return lsp_bits_string;
}
/* this function prints the lsp on show isis database */
void
-lsp_print (dnode_t *node, struct vty *vty, char dynhost)
+lsp_print (dnode_t * node, struct vty *vty, char dynhost)
{
- struct isis_lsp *lsp = dnode_get(node);
+ struct isis_lsp *lsp = dnode_get (node);
u_char LSPid[255];
lspid_print (lsp->lsp_header->lsp_id, LSPid, dynhost, 1);
- vty_out (vty, "%-21s%c ", LSPid,lsp->own_lsp?'*':' ');
- vty_out (vty, "0x%08x ", ntohl(lsp->lsp_header->seq_num));
- vty_out (vty, "0x%04x ", ntohs(lsp->lsp_header->checksum));
+ vty_out (vty, "%-21s%c ", LSPid, lsp->own_lsp ? '*' : ' ');
+ vty_out (vty, "0x%08x ", ntohl (lsp->lsp_header->seq_num));
+ vty_out (vty, "0x%04x ", ntohs (lsp->lsp_header->checksum));
- if (ntohs(lsp->lsp_header->rem_lifetime) == 0)
- vty_out (vty, " (%2u)",lsp->age_out);
+ if (ntohs (lsp->lsp_header->rem_lifetime) == 0)
+ vty_out (vty, " (%2u)", lsp->age_out);
else
- vty_out (vty, "%5u", ntohs(lsp->lsp_header->rem_lifetime));
+ vty_out (vty, "%5u", ntohs (lsp->lsp_header->rem_lifetime));
vty_out (vty, " %s%s",
- lsp_bits2string(&lsp->lsp_header->lsp_bits),
- VTY_NEWLINE);
+ lsp_bits2string (&lsp->lsp_header->lsp_bits), VTY_NEWLINE);
}
void
-lsp_print_detail (dnode_t *node, struct vty *vty, char dynhost)
+lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
{
struct isis_lsp *lsp = dnode_get (node);
struct area_addr *area_addr;
- char nlpidstr[2];
- int i;
+ char nlpidstr[2];
+ int i;
struct listnode *lnode;
struct is_neigh *is_neigh;
struct te_is_neigh *te_is_neigh;
@@ -717,124 +728,124 @@ lsp_print_detail (dnode_t *node, struct vty *vty, char dynhost)
u_char LSPid[255];
u_char hostname[255];
u_char buff[BUFSIZ];
- u_int32_t now,helper;
+ u_int32_t now, helper;
u_char ipv4_reach_prefix[20];
u_char ipv4_reach_mask[20];
u_char ipv4_address[20];
lspid_print (lsp->lsp_header->lsp_id, LSPid, dynhost, 1);
- lsp_print(node, vty, dynhost);
+ lsp_print (node, vty, dynhost);
/* for all area address */
- if (lsp->tlv_data.area_addrs) {
- LIST_LOOP (lsp->tlv_data.area_addrs, area_addr, lnode) {
- vty_out (vty, " Area Address: %s%s",
- isonet_print (area_addr->area_addr, area_addr->addr_len),
- VTY_NEWLINE);
+ if (lsp->tlv_data.area_addrs)
+ {
+ LIST_LOOP (lsp->tlv_data.area_addrs, area_addr, lnode)
+ {
+ vty_out (vty, " Area Address: %s%s",
+ isonet_print (area_addr->area_addr, area_addr->addr_len),
+ VTY_NEWLINE);
+ }
}
- }
/* for the nlpid tlv */
- if (lsp->tlv_data.nlpids) {
- for (i = 0; i < lsp->tlv_data.nlpids->count; i++) {
- switch (lsp->tlv_data.nlpids->nlpids[i]) {
- case NLPID_IP:
- case NLPID_IPV6:
- vty_out (vty, " NLPID: 0x%X%s",
- lsp->tlv_data.nlpids->nlpids[i],
- VTY_NEWLINE);
- break;
- default:
- vty_out (vty, " NLPID: %s%s",
- "unknown",
- VTY_NEWLINE);
- break;
- }
- }
- }
+ if (lsp->tlv_data.nlpids)
+ {
+ for (i = 0; i < lsp->tlv_data.nlpids->count; i++)
+ {
+ switch (lsp->tlv_data.nlpids->nlpids[i])
+ {
+ case NLPID_IP:
+ case NLPID_IPV6:
+ vty_out (vty, " NLPID: 0x%X%s",
+ lsp->tlv_data.nlpids->nlpids[i], VTY_NEWLINE);
+ break;
+ default:
+ vty_out (vty, " NLPID: %s%s", "unknown", VTY_NEWLINE);
+ break;
+ }
+ }
+ }
/* for the hostname tlv */
- if (lsp->tlv_data.hostname) {
- bzero (hostname, sizeof (hostname));
- memcpy (hostname, lsp->tlv_data.hostname->name,
- lsp->tlv_data.hostname->namelen);
- vty_out (vty, " Hostname: %s%s", hostname, VTY_NEWLINE);
- }
+ if (lsp->tlv_data.hostname)
+ {
+ bzero (hostname, sizeof (hostname));
+ memcpy (hostname, lsp->tlv_data.hostname->name,
+ lsp->tlv_data.hostname->namelen);
+ vty_out (vty, " Hostname: %s%s", hostname, VTY_NEWLINE);
+ }
- if (lsp->tlv_data.ipv4_addrs) {
- LIST_LOOP(lsp->tlv_data.ipv4_addrs, ipv4_addr, lnode) {
- memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address));
- vty_out (vty, " IP: %s%s",
- ipv4_address,
- VTY_NEWLINE);
+ if (lsp->tlv_data.ipv4_addrs)
+ {
+ LIST_LOOP (lsp->tlv_data.ipv4_addrs, ipv4_addr, lnode)
+ {
+ memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address));
+ vty_out (vty, " IP: %s%s", ipv4_address, VTY_NEWLINE);
+ }
}
- }
-
+
/* for the internal reachable tlv */
if (lsp->tlv_data.ipv4_int_reachs)
- LIST_LOOP(lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode) {
- memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix), sizeof (ipv4_reach_prefix));
- memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask));
+ LIST_LOOP (lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode)
+ {
+ memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix),
+ sizeof (ipv4_reach_prefix));
+ memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask),
+ sizeof (ipv4_reach_mask));
vty_out (vty, " Metric: %d IP %s %s%s",
- ipv4_reach->metrics.metric_default,
- ipv4_reach_prefix,
- ipv4_reach_mask,
- VTY_NEWLINE);
- }
+ ipv4_reach->metrics.metric_default, ipv4_reach_prefix,
+ ipv4_reach_mask, VTY_NEWLINE);
+ }
/* for the external reachable tlv */
if (lsp->tlv_data.ipv4_ext_reachs)
- LIST_LOOP(lsp->tlv_data.ipv4_ext_reachs, ipv4_reach, lnode) {
- memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix), sizeof (ipv4_reach_prefix));
- memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask), sizeof (ipv4_reach_mask));
+ LIST_LOOP (lsp->tlv_data.ipv4_ext_reachs, ipv4_reach, lnode)
+ {
+ memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix),
+ sizeof (ipv4_reach_prefix));
+ memcpy (ipv4_reach_mask, inet_ntoa (ipv4_reach->mask),
+ sizeof (ipv4_reach_mask));
vty_out (vty, " Metric: %d IP-External %s %s%s",
- ipv4_reach->metrics.metric_default,
- ipv4_reach_prefix,
- ipv4_reach_mask,
- VTY_NEWLINE);
- }
+ ipv4_reach->metrics.metric_default, ipv4_reach_prefix,
+ ipv4_reach_mask, VTY_NEWLINE);
+ }
/* for the IS neighbor tlv */
- if (lsp->tlv_data.is_neighs) {
- LIST_LOOP(lsp->tlv_data.is_neighs,is_neigh,lnode) {
- lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
- vty_out (vty, " Metric: %d IS %s%s",
- is_neigh->metrics.metric_default,
- LSPid,
- VTY_NEWLINE);
+ if (lsp->tlv_data.is_neighs)
+ {
+ LIST_LOOP (lsp->tlv_data.is_neighs, is_neigh, lnode)
+ {
+ lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
+ vty_out (vty, " Metric: %d IS %s%s",
+ is_neigh->metrics.metric_default, LSPid, VTY_NEWLINE);
+ }
}
- }
/* IPv6 tlv */
#ifdef HAVE_IPV6
if (lsp->tlv_data.ipv6_reachs)
- LIST_LOOP(lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode) {
- memset(&in6, 0, sizeof(in6));
- memcpy (in6.s6_addr, ipv6_reach->prefix, PSIZE(ipv6_reach->prefix_len));
+ LIST_LOOP (lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode)
+ {
+ memset (&in6, 0, sizeof (in6));
+ memcpy (in6.s6_addr, ipv6_reach->prefix,
+ PSIZE (ipv6_reach->prefix_len));
inet_ntop (AF_INET6, &in6, buff, BUFSIZ);
if ((ipv6_reach->control_info &&
- CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL)
- vty_out (vty, " Metric: %d IPv6-Intern %s/%d%s",
- ntohl (ipv6_reach->metric),
- buff,
- ipv6_reach->prefix_len,
- VTY_NEWLINE);
+ CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL)
+ vty_out (vty, " Metric: %d IPv6-Intern %s/%d%s",
+ ntohl (ipv6_reach->metric),
+ buff, ipv6_reach->prefix_len, VTY_NEWLINE);
else
- vty_out (vty, " Metric: %d IPv6-Extern %s/%d%s",
- ntohl (ipv6_reach->metric),
- buff,
- ipv6_reach->prefix_len,
- VTY_NEWLINE);
+ vty_out (vty, " Metric: %d IPv6-Extern %s/%d%s",
+ ntohl (ipv6_reach->metric),
+ buff, ipv6_reach->prefix_len, VTY_NEWLINE);
}
#endif
/* FIXME: Other tlvs such as te or external tlv will be added later */
-#if 0
+#if 0
vty_out (vty, "%s %s %c%s",
- VTY_NEWLINE,
- LSPid,
- lsp->own_lsp ? '*' : ' ',
- VTY_NEWLINE);
+ VTY_NEWLINE, LSPid, lsp->own_lsp ? '*' : ' ', VTY_NEWLINE);
vty_out (vty, " Sequence: 0x%08x Checksum: 0x%04x Lifetime: ",
ntohl (lsp->lsp_header->seq_num),
@@ -846,8 +857,7 @@ lsp_print_detail (dnode_t *node, struct vty *vty, char dynhost)
vty_out (vty, "%5u ", ntohs (lsp->lsp_header->rem_lifetime));
vty_out (vty, "%s Attributes:%s",
- VTY_NEWLINE,
- lsp_bits2string (&lsp->lsp_header->lsp_bits));
+ VTY_NEWLINE, lsp_bits2string (&lsp->lsp_header->lsp_bits));
/* if this is a self originated LSP then print
* the generation time plus when we sent it last
@@ -855,152 +865,158 @@ lsp_print_detail (dnode_t *node, struct vty *vty, char dynhost)
* time when the LSP has been installed
*/
- if (lsp->own_lsp) {
+ if (lsp->own_lsp)
+ {
- now = time (NULL);
- helper = now - lsp->last_generated;
- if (!lsp->last_generated)
- helper = 0;
+ now = time (NULL);
+ helper = now - lsp->last_generated;
+ if (!lsp->last_generated)
+ helper = 0;
- vty_out (vty, ", Generated: %s ago",
- time2string (helper));
+ vty_out (vty, ", Generated: %s ago", time2string (helper));
- now = time (NULL);
- helper = now - lsp->last_sent;
- if (!lsp->last_sent)
- helper = 0;
+ now = time (NULL);
+ helper = now - lsp->last_sent;
+ if (!lsp->last_sent)
+ helper = 0;
- vty_out (vty, ", Last sent: %s ago",
- time2string (helper));
- } else {
- now = time (NULL);
- helper = now - lsp->installed;
- if (!lsp->installed)
- helper = 0;
+ vty_out (vty, ", Last sent: %s ago", time2string (helper));
+ }
+ else
+ {
+ now = time (NULL);
+ helper = now - lsp->installed;
+ if (!lsp->installed)
+ helper = 0;
- vty_out (vty, ", Installed: %s ago",
- time2string (helper));
+ vty_out (vty, ", Installed: %s ago", time2string (helper));
- }
+ }
vty_out (vty, "%s", VTY_NEWLINE);
- if (lsp->tlv_data.nlpids) {
- vty_out (vty, " Speaks: %s%s", nlpid2string (lsp->tlv_data.nlpids),
- VTY_NEWLINE);
- }
+ if (lsp->tlv_data.nlpids)
+ {
+ vty_out (vty, " Speaks: %s%s", nlpid2string (lsp->tlv_data.nlpids),
+ VTY_NEWLINE);
+ }
- if (lsp->tlv_data.router_id) {
- vty_out (vty, " Router ID: %s%s",
- inet_ntoa (lsp->tlv_data.router_id->id), VTY_NEWLINE);
- }
+ if (lsp->tlv_data.router_id)
+ {
+ vty_out (vty, " Router ID: %s%s",
+ inet_ntoa (lsp->tlv_data.router_id->id), VTY_NEWLINE);
+ }
if (lsp->tlv_data.is_neighs)
- LIST_LOOP(lsp->tlv_data.is_neighs,is_neigh,lnode) {
- lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
- vty_out (vty, " IS %s, Metric: %d%s",
- LSPid,
- is_neigh->metrics.metric_default,
- VTY_NEWLINE);
- }
+ LIST_LOOP (lsp->tlv_data.is_neighs, is_neigh, lnode)
+ {
+ lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
+ vty_out (vty, " IS %s, Metric: %d%s",
+ LSPid, is_neigh->metrics.metric_default, VTY_NEWLINE);
+ }
if (lsp->tlv_data.te_is_neighs)
- LIST_LOOP(lsp->tlv_data.te_is_neighs,te_is_neigh,lnode) {
- /* FIXME: metric display is wrong */
- lspid_print (te_is_neigh->neigh_id, LSPid, dynhost, 0);
- vty_out (vty, " extd-IS %s, Metric: %d%s",
- LSPid,
- te_is_neigh->te_metric[0],
- VTY_NEWLINE);
- }
+ LIST_LOOP (lsp->tlv_data.te_is_neighs, te_is_neigh, lnode)
+ {
+ /* FIXME: metric display is wrong */
+ lspid_print (te_is_neigh->neigh_id, LSPid, dynhost, 0);
+ vty_out (vty, " extd-IS %s, Metric: %d%s",
+ LSPid, te_is_neigh->te_metric[0], VTY_NEWLINE);
+ }
if (lsp->tlv_data.ipv4_int_reachs)
- LIST_LOOP(lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode) {
- vty_out (vty, " int-IP %s/%d, Metric: %d%s",
- inet_ntoa (ipv4_reach->prefix),
- ip_masklen (ipv4_reach->mask),
- ipv4_reach->metrics.metric_default,
- VTY_NEWLINE);
- }
+ LIST_LOOP (lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode)
+ {
+ vty_out (vty, " int-IP %s/%d, Metric: %d%s",
+ inet_ntoa (ipv4_reach->prefix),
+ ip_masklen (ipv4_reach->mask),
+ ipv4_reach->metrics.metric_default, VTY_NEWLINE);
+ }
if (lsp->tlv_data.ipv4_ext_reachs)
- LIST_LOOP(lsp->tlv_data.ipv4_ext_reachs,ipv4_reach,lnode) {
- vty_out (vty, " ext-IP %s/%d, Metric: %d%s",
- inet_ntoa(ipv4_reach->prefix),
- ip_masklen(ipv4_reach->mask),
- ipv4_reach->metrics.metric_default,
- VTY_NEWLINE);
- }
+ LIST_LOOP (lsp->tlv_data.ipv4_ext_reachs, ipv4_reach, lnode)
+ {
+ vty_out (vty, " ext-IP %s/%d, Metric: %d%s",
+ inet_ntoa (ipv4_reach->prefix),
+ ip_masklen (ipv4_reach->mask),
+ ipv4_reach->metrics.metric_default, VTY_NEWLINE);
+ }
if (lsp->tlv_data.te_ipv4_reachs)
- LIST_LOOP(lsp->tlv_data.te_ipv4_reachs,te_ipv4_reach,lnode) {
- vty_out (vty, " extd-IP %s/%d, Metric: %d%s",
- inet_ntoa ( newprefix2inaddr (&te_ipv4_reach->prefix_start,
- te_ipv4_reach->control)),
- te_ipv4_reach->control & 0x3F,
- ntohl (te_ipv4_reach->te_metric),
- VTY_NEWLINE);
- }
+ LIST_LOOP (lsp->tlv_data.te_ipv4_reachs, te_ipv4_reach, lnode)
+ {
+ vty_out (vty, " extd-IP %s/%d, Metric: %d%s",
+ inet_ntoa (newprefix2inaddr (&te_ipv4_reach->prefix_start,
+ te_ipv4_reach->control)),
+ te_ipv4_reach->control & 0x3F,
+ ntohl (te_ipv4_reach->te_metric), VTY_NEWLINE);
+ }
#ifdef HAVE_IPV6
if (lsp->tlv_data.ipv6_reachs)
- LIST_LOOP(lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode) {
- memcpy (in6.s6_addr, ipv6_reach->prefix, 16);
- inet_ntop (AF_INET6, &in6, buff, BUFSIZ);
- if ((ipv6_reach->control_info &&
- CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL)
- vty_out (vty, " int-IPv6 %s/%d, Metric: %d%s",
- buff,
- ipv6_reach->prefix_len,
- ntohl (ipv6_reach->metric),
- VTY_NEWLINE);
- else
- vty_out (vty, " ext-IPv6 %s/%d, Metric: %d%s",
- buff,
- ipv6_reach->prefix_len,
- ntohl (ipv6_reach->metric),
- VTY_NEWLINE);
-
- }
+ LIST_LOOP (lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode)
+ {
+ memcpy (in6.s6_addr, ipv6_reach->prefix, 16);
+ inet_ntop (AF_INET6, &in6, buff, BUFSIZ);
+ if ((ipv6_reach->control_info &&
+ CTRL_INFO_DISTRIBUTION) == DISTRIBUTION_INTERNAL)
+ vty_out (vty, " int-IPv6 %s/%d, Metric: %d%s",
+ buff,
+ ipv6_reach->prefix_len,
+ ntohl (ipv6_reach->metric), VTY_NEWLINE);
+ else
+ vty_out (vty, " ext-IPv6 %s/%d, Metric: %d%s",
+ buff,
+ ipv6_reach->prefix_len,
+ ntohl (ipv6_reach->metric), VTY_NEWLINE);
+
+ }
#endif
- if (lsp->tlv_data.hostname) {
- memset (hostname, 0, sizeof (hostname));
- memcpy (hostname, lsp->tlv_data.hostname->name,
- lsp->tlv_data.hostname->namelen);
- vty_out (vty, " Hostname: %s%s", hostname, VTY_NEWLINE);
- }
+ if (lsp->tlv_data.hostname)
+ {
+ memset (hostname, 0, sizeof (hostname));
+ memcpy (hostname, lsp->tlv_data.hostname->name,
+ lsp->tlv_data.hostname->namelen);
+ vty_out (vty, " Hostname: %s%s", hostname, VTY_NEWLINE);
+ }
#endif
- return;
+ return;
}
/* print all the lsps info in the local lspdb */
-int
-lsp_print_all (struct vty *vty, dict_t *lspdb, char detail, char dynhost)
+int
+lsp_print_all (struct vty *vty, dict_t * lspdb, char detail, char dynhost)
{
- dnode_t *node = dict_first(lspdb), *next;
+ dnode_t *node = dict_first (lspdb), *next;
int lsp_count = 0;
/* print the title, for both modes */
vty_out (vty, "LSP ID LSP Seq Num LSP Checksum "
- "LSP Holdtime ATT/P/OL%s", VTY_NEWLINE);
-
- if (detail == ISIS_UI_LEVEL_BRIEF) {
- while (node != NULL) {
- /* dict_contains (lspdb, node); */ /* I think it is unnecessary, so I comment it out */
- next = dict_next (lspdb, node);
- lsp_print (node, vty, dynhost);
- node = next;
- lsp_count++;
- }
- } else if (detail == ISIS_UI_LEVEL_DETAIL) {
- while (node != NULL) {
- next = dict_next (lspdb, node);
- lsp_print_detail (node, vty, dynhost);
- node = next;
- lsp_count++;
+ "LSP Holdtime ATT/P/OL%s", VTY_NEWLINE);
+
+ if (detail == ISIS_UI_LEVEL_BRIEF)
+ {
+ while (node != NULL)
+ {
+ /* I think it is unnecessary, so I comment it out */
+ /* dict_contains (lspdb, node); */
+ next = dict_next (lspdb, node);
+ lsp_print (node, vty, dynhost);
+ node = next;
+ lsp_count++;
+ }
+ }
+ else if (detail == ISIS_UI_LEVEL_DETAIL)
+ {
+ while (node != NULL)
+ {
+ next = dict_next (lspdb, node);
+ lsp_print_detail (node, vty, dynhost);
+ node = next;
+ lsp_count++;
+ }
}
- }
return lsp_count;
}
@@ -1009,31 +1025,30 @@ lsp_print_all (struct vty *vty, dict_t *lspdb, char detail, char dynhost)
* size of memory, it scans the lsp and moves all pointers the
* way they should */
u_char *
-lsppdu_realloc (struct isis_lsp *lsp, int memorytype, int size)
+lsppdu_realloc (struct isis_lsp * lsp, int memorytype, int size)
{
u_char *retval;
-
- retval = STREAM_DATA(lsp->pdu) + ntohs(lsp->lsp_header->pdu_len);
+
+ retval = STREAM_DATA (lsp->pdu) + ntohs (lsp->lsp_header->pdu_len);
#ifdef LSP_MEMORY_PREASSIGN
- lsp->lsp_header->pdu_len = htons(ntohs(lsp->lsp_header->pdu_len) + size);
+ lsp->lsp_header->pdu_len = htons (ntohs (lsp->lsp_header->pdu_len) + size);
return retval;
-#else /* otherwise we have to move all pointers */
+#else /* otherwise we have to move all pointers */
u_char *newpdu;
newpdu = stream_new (ntohs (lsp->lsp_header->pdu_len) + size);
- memcpy (STREAM_DATA (newpdu), STREAM_DATA(lsp->pdu),
- ntohs (lsp->lsp_header->pdu_len));
+ memcpy (STREAM_DATA (newpdu), STREAM_DATA (lsp->pdu),
+ ntohs (lsp->lsp_header->pdu_len));
XFREE (memorytype, lsp->pdu);
lsp->pdu = newpdu;
- lsp->isis_header = (struct isis_fixed_hdr*)STREAM_DATA(lsp->pdu);
- lsp->lsp_header = (struct isis_link_state_hdr*)
- (STREAM_DATA(lsp->pdu) + ISIS_FIXED_HDR_LEN);
+ lsp->isis_header = (struct isis_fixed_hdr *) STREAM_DATA (lsp->pdu);
+ lsp->lsp_header = (struct isis_link_state_hdr *)
+ (STREAM_DATA (lsp->pdu) + ISIS_FIXED_HDR_LEN);
htons (ntohs (lsp->lsp_header->pdu_len) += size);
- return STREAM_DATA(lsp->pdu) + (lsp->lsp_header->pdu_len - size);
+ return STREAM_DATA (lsp->pdu) + (lsp->lsp_header->pdu_len - size);
#endif /* LSP_MEMORY_PREASSIGN */
}
-
-#if 0 /* Saving the old one just in case :) */
+#if 0 /* Saving the old one just in case :) */
/*
* Builds the lsp->tlv_data
* and writes the tlvs into lsp->pdu
@@ -1052,181 +1067,200 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
struct prefix_ipv6 *ipv6;
struct ipv6_reachability *ip6reach;
#endif /* HAVE_IPV6 */
-
+
/*
* First add the tlvs related to area
*/
-
+
/* Area addresses */
if (lsp->tlv_data.area_addrs == NULL)
lsp->tlv_data.area_addrs = list_new ();
list_add_list (lsp->tlv_data.area_addrs, area->area_addrs);
/* Protocols Supported */
- if (area->ip_circuits > 0
+ if (area->ip_circuits > 0
#ifdef HAVE_IPV6
|| area->ipv6_circuits > 0
#endif /* HAVE_IPV6 */
- )
+ )
{
lsp->tlv_data.nlpids = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct nlpids));
lsp->tlv_data.nlpids->count = 0;
- if (area->ip_circuits > 0) {
- lsp->tlv_data.nlpids->count++;
- lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP;
- }
+ if (area->ip_circuits > 0)
+ {
+ lsp->tlv_data.nlpids->count++;
+ lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP;
+ }
#ifdef HAVE_IPV6
- if (area->ipv6_circuits > 0) {
- lsp->tlv_data.nlpids->count++;
- lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] =
- NLPID_IPV6;
- }
+ if (area->ipv6_circuits > 0)
+ {
+ lsp->tlv_data.nlpids->count++;
+ lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] =
+ NLPID_IPV6;
+ }
#endif /* HAVE_IPV6 */
}
/* Dynamic Hostname */
- if (area->dynhostname) {
- lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV,
- sizeof (struct hostname));
- memcpy (&lsp->tlv_data.hostname->name, unix_hostname(),
- strlen(unix_hostname()));
- lsp->tlv_data.hostname->namelen = strlen (unix_hostname());
- }
+ if (area->dynhostname)
+ {
+ lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV,
+ sizeof (struct hostname));
+ memcpy (&lsp->tlv_data.hostname->name, unix_hostname (),
+ strlen (unix_hostname ()));
+ lsp->tlv_data.hostname->namelen = strlen (unix_hostname ());
+ }
#ifdef TOPOLOGY_GENERATE
/*
* If we have a topology in this area, we need to connect this lsp to
* the first topology lsp
*/
- if ((area->topology) && (level == 1)) {
- if (lsp->tlv_data.is_neighs == NULL)
- lsp->tlv_data.is_neighs = list_new ();
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
- memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN);
- /* connected to the first */
- is_neigh->neigh_id[ISIS_SYS_ID_LEN-1] = (0x01);
- /* this is actually the same system, why mess the SPT */
- is_neigh->metrics.metric_default = 0;
- is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
- is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
- is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
- listnode_add (lsp->tlv_data.is_neighs, is_neigh);
+ if ((area->topology) && (level == 1))
+ {
+ if (lsp->tlv_data.is_neighs == NULL)
+ lsp->tlv_data.is_neighs = list_new ();
+ is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
+ memset (is_neigh, 0, sizeof (struct is_neigh));
+ memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN);
+ /* connected to the first */
+ is_neigh->neigh_id[ISIS_SYS_ID_LEN - 1] = (0x01);
+ /* this is actually the same system, why mess the SPT */
+ is_neigh->metrics.metric_default = 0;
+ is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
+ is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
+ is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
+ listnode_add (lsp->tlv_data.is_neighs, is_neigh);
- }
+ }
#endif
/*
* Then add tlvs related to circuits
*/
- for (node = listhead (area->circuit_list); node; nextnode (node)) {
- circuit = getdata (node);
- if (circuit->state != C_STATE_UP)
- continue;
-
- /*
- * Add IPv4 internal reachability of this circuit
- */
- if (circuit->ip_router && circuit->ip_addrs &&
- circuit->ip_addrs->count > 0) {
- if (lsp->tlv_data.ipv4_int_reachs == NULL) {
- lsp->tlv_data.ipv4_int_reachs = list_new ();
- lsp->tlv_data.ipv4_int_reachs->del = free_tlv;
- }
- for (ipnode = listhead (circuit->ip_addrs); ipnode; nextnode (ipnode)) {
- ipv4 = getdata (ipnode);
- ipreach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
- ipreach->metrics = circuit->metrics[level - 1];
- ipreach->prefix = ipv4->prefix;
- masklen2ip (ipv4->prefixlen, &ipreach->mask);
- listnode_add (lsp->tlv_data.ipv4_int_reachs, ipreach);
- }
- }
+ for (node = listhead (area->circuit_list); node; nextnode (node))
+ {
+ circuit = getdata (node);
+ if (circuit->state != C_STATE_UP)
+ continue;
+
+ /*
+ * Add IPv4 internal reachability of this circuit
+ */
+ if (circuit->ip_router && circuit->ip_addrs &&
+ circuit->ip_addrs->count > 0)
+ {
+ if (lsp->tlv_data.ipv4_int_reachs == NULL)
+ {
+ lsp->tlv_data.ipv4_int_reachs = list_new ();
+ lsp->tlv_data.ipv4_int_reachs->del = free_tlv;
+ }
+ for (ipnode = listhead (circuit->ip_addrs); ipnode;
+ nextnode (ipnode))
+ {
+ ipv4 = getdata (ipnode);
+ ipreach =
+ XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
+ ipreach->metrics = circuit->metrics[level - 1];
+ ipreach->prefix = ipv4->prefix;
+ masklen2ip (ipv4->prefixlen, &ipreach->mask);
+ listnode_add (lsp->tlv_data.ipv4_int_reachs, ipreach);
+ }
+ }
#ifdef HAVE_IPV6
- /*
- * Add IPv6 reachability of this circuit
- */
- if (circuit->ipv6_router && circuit->ipv6_non_link &&
- circuit->ipv6_non_link->count > 0) {
- if (lsp->tlv_data.ipv6_reachs == NULL) {
- lsp->tlv_data.ipv6_reachs = list_new ();
- lsp->tlv_data.ipv6_reachs->del = free_tlv;
- }
- for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
- nextnode (ipnode)) {
- ipv6 = getdata (ipnode);
- ip6reach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
- memset (ip6reach, 0, sizeof (struct ipv6_reachability));
- ip6reach->metric = htonl(circuit->metrics[level - 1].metric_default);
- ip6reach->control_info = 0;
- ip6reach->prefix_len = ipv6->prefixlen;
- memcpy (&ip6reach->prefix, ipv6->prefix.s6_addr,
- (ipv6->prefixlen + 7) / 8);
- listnode_add (lsp->tlv_data.ipv6_reachs, ip6reach);
- }
- }
+ /*
+ * Add IPv6 reachability of this circuit
+ */
+ if (circuit->ipv6_router && circuit->ipv6_non_link &&
+ circuit->ipv6_non_link->count > 0)
+ {
+ if (lsp->tlv_data.ipv6_reachs == NULL)
+ {
+ lsp->tlv_data.ipv6_reachs = list_new ();
+ lsp->tlv_data.ipv6_reachs->del = free_tlv;
+ }
+ for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
+ nextnode (ipnode))
+ {
+ ipv6 = getdata (ipnode);
+ ip6reach =
+ XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
+ memset (ip6reach, 0, sizeof (struct ipv6_reachability));
+ ip6reach->metric =
+ htonl (circuit->metrics[level - 1].metric_default);
+ ip6reach->control_info = 0;
+ ip6reach->prefix_len = ipv6->prefixlen;
+ memcpy (&ip6reach->prefix, ipv6->prefix.s6_addr,
+ (ipv6->prefixlen + 7) / 8);
+ listnode_add (lsp->tlv_data.ipv6_reachs, ip6reach);
+ }
+ }
#endif /* HAVE_IPV6 */
-
- switch (circuit->circ_type) {
- case CIRCUIT_T_BROADCAST:
- if (level & circuit->circuit_is_type) {
- if (lsp->tlv_data.is_neighs == NULL) {
- lsp->tlv_data.is_neighs = list_new ();
- lsp->tlv_data.is_neighs->del = free_tlv;
- }
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
- if (level == 1)
- memcpy (&is_neigh->neigh_id,
- circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
- else
- memcpy (&is_neigh->neigh_id,
- circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
- is_neigh->metrics = circuit->metrics[level - 1];
- listnode_add (lsp->tlv_data.is_neighs, is_neigh);
- }
- break;
- case CIRCUIT_T_P2P:
- nei = circuit->u.p2p.neighbor;
- if (nei && (level & nei->circuit_t)) {
- if (lsp->tlv_data.is_neighs == NULL) {
- lsp->tlv_data.is_neighs = list_new ();
- lsp->tlv_data.is_neighs->del = free_tlv;
- }
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
- memcpy (&is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN);
- is_neigh->metrics = circuit->metrics[level - 1];
- listnode_add (lsp->tlv_data.is_neighs, is_neigh);
- }
- break;
- case CIRCUIT_T_STATIC_IN:
- zlog_warn ("lsp_area_create: unsupported circuit type");
- break;
- case CIRCUIT_T_STATIC_OUT:
- zlog_warn ("lsp_area_create: unsupported circuit type");
- break;
- case CIRCUIT_T_DA:
- zlog_warn ("lsp_area_create: unsupported circuit type");
- break;
- default:
- zlog_warn ("lsp_area_create: unknown circuit type");
+
+ switch (circuit->circ_type)
+ {
+ case CIRCUIT_T_BROADCAST:
+ if (level & circuit->circuit_is_type)
+ {
+ if (lsp->tlv_data.is_neighs == NULL)
+ {
+ lsp->tlv_data.is_neighs = list_new ();
+ lsp->tlv_data.is_neighs->del = free_tlv;
+ }
+ is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
+ memset (is_neigh, 0, sizeof (struct is_neigh));
+ if (level == 1)
+ memcpy (&is_neigh->neigh_id,
+ circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
+ else
+ memcpy (&is_neigh->neigh_id,
+ circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
+ is_neigh->metrics = circuit->metrics[level - 1];
+ listnode_add (lsp->tlv_data.is_neighs, is_neigh);
+ }
+ break;
+ case CIRCUIT_T_P2P:
+ nei = circuit->u.p2p.neighbor;
+ if (nei && (level & nei->circuit_t))
+ {
+ if (lsp->tlv_data.is_neighs == NULL)
+ {
+ lsp->tlv_data.is_neighs = list_new ();
+ lsp->tlv_data.is_neighs->del = free_tlv;
+ }
+ is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
+ memset (is_neigh, 0, sizeof (struct is_neigh));
+ memcpy (&is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN);
+ is_neigh->metrics = circuit->metrics[level - 1];
+ listnode_add (lsp->tlv_data.is_neighs, is_neigh);
+ }
+ break;
+ case CIRCUIT_T_STATIC_IN:
+ zlog_warn ("lsp_area_create: unsupported circuit type");
+ break;
+ case CIRCUIT_T_STATIC_OUT:
+ zlog_warn ("lsp_area_create: unsupported circuit type");
+ break;
+ case CIRCUIT_T_DA:
+ zlog_warn ("lsp_area_create: unsupported circuit type");
+ break;
+ default:
+ zlog_warn ("lsp_area_create: unknown circuit type");
+ }
}
- }
-
+
stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
-
+
if (lsp->tlv_data.nlpids)
tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu);
if (lsp->tlv_data.hostname)
tlv_add_dynamic_hostname (lsp->tlv_data.hostname, lsp->pdu);
- if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0 )
+ if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0)
tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu);
if (lsp->tlv_data.is_neighs && listcount (lsp->tlv_data.is_neighs) > 0)
tlv_add_is_neighs (lsp->tlv_data.is_neighs, lsp->pdu);
- if (lsp->tlv_data.ipv4_int_reachs &&
+ if (lsp->tlv_data.ipv4_int_reachs &&
listcount (lsp->tlv_data.ipv4_int_reachs) > 0)
tlv_add_ipv4_reachs (lsp->tlv_data.ipv4_int_reachs, lsp->pdu);
-#ifdef HAVE_IPV6
- if (lsp->tlv_data.ipv6_reachs &&
- listcount (lsp->tlv_data.ipv6_reachs) > 0)
+#ifdef HAVE_IPV6
+ if (lsp->tlv_data.ipv6_reachs && listcount (lsp->tlv_data.ipv6_reachs) > 0)
tlv_add_ipv6_reachs (lsp->tlv_data.ipv6_reachs, lsp->pdu);
#endif /* HAVE_IPV6 */
@@ -1245,73 +1279,79 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
void
lsp_tlv_fit (struct isis_lsp *lsp, struct list **from, struct list **to,
- int tlvsize, int frag_thold,
- int tlv_build_func(struct list *, struct stream *))
+ int tlvsize, int frag_thold,
+ int tlv_build_func (struct list *, struct stream *))
{
int count, i;
-
+
/* can we fit all ? */
- if (!FRAG_NEEDED(lsp->pdu, frag_thold,
- listcount(*from) * tlvsize + 2)) {
- tlv_build_func (*from, lsp->pdu);
- *to = *from;
- *from = NULL;
- } else if (!FRAG_NEEDED(lsp->pdu, frag_thold, tlvsize + 2)) {
- /* fit all we can */
- count = FRAG_THOLD(lsp->pdu,frag_thold) - 2 -
- (STREAM_SIZE(lsp->pdu) - STREAM_REMAIN(lsp->pdu));
- if (count)
- count = count / tlvsize;
- for (i = 0; i < count; i++) {
- listnode_add (*to, getdata(listhead(*from)));
- listnode_delete(*from, getdata(listhead(*from)));
- }
- tlv_build_func (*to, lsp->pdu);
- }
- lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));
+ if (!FRAG_NEEDED (lsp->pdu, frag_thold, listcount (*from) * tlvsize + 2))
+ {
+ tlv_build_func (*from, lsp->pdu);
+ *to = *from;
+ *from = NULL;
+ }
+ else if (!FRAG_NEEDED (lsp->pdu, frag_thold, tlvsize + 2))
+ {
+ /* fit all we can */
+ count = FRAG_THOLD (lsp->pdu, frag_thold) - 2 -
+ (STREAM_SIZE (lsp->pdu) - STREAM_REMAIN (lsp->pdu));
+ if (count)
+ count = count / tlvsize;
+ for (i = 0; i < count; i++)
+ {
+ listnode_add (*to, getdata (listhead (*from)));
+ listnode_delete (*from, getdata (listhead (*from)));
+ }
+ tlv_build_func (*to, lsp->pdu);
+ }
+ lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));
return;
}
-struct isis_lsp *
-lsp_next_frag (u_char frag_num, struct isis_lsp *lsp0, struct isis_area *area,
- int level )
+struct isis_lsp *
+lsp_next_frag (u_char frag_num, struct isis_lsp *lsp0, struct isis_area *area,
+ int level)
{
struct isis_lsp *lsp;
- u_char frag_id[ISIS_SYS_ID_LEN + 2];
-
+ u_char frag_id[ISIS_SYS_ID_LEN + 2];
+
memcpy (frag_id, lsp0->lsp_header->lsp_id, ISIS_SYS_ID_LEN + 1);
LSP_FRAGMENT (frag_id) = frag_num;
lsp = lsp_search (frag_id, area->lspdb[level - 1]);
- if (lsp) {
- /*
- * Clear the TLVs, but inherit the authinfo
- */
- lsp_clear_data (lsp);
- if (lsp0->tlv_data.auth_info.type) {
- memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info,
- sizeof (struct isis_passwd));
- tlv_add_authinfo (lsp->tlv_data.auth_info.type,
- lsp->tlv_data.auth_info.len,
- lsp->tlv_data.auth_info.passwd, lsp->pdu);
+ if (lsp)
+ {
+ /*
+ * Clear the TLVs, but inherit the authinfo
+ */
+ lsp_clear_data (lsp);
+ if (lsp0->tlv_data.auth_info.type)
+ {
+ memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info,
+ sizeof (struct isis_passwd));
+ tlv_add_authinfo (lsp->tlv_data.auth_info.type,
+ lsp->tlv_data.auth_info.len,
+ lsp->tlv_data.auth_info.passwd, lsp->pdu);
+ }
+ return lsp;
}
- return lsp;
- }
lsp = lsp_new (frag_id, area->max_lsp_lifetime[level - 1], 0, area->is_type,
- 0, level);
+ 0, level);
lsp->own_lsp = 1;
- lsp_insert (lsp, area->lspdb[level-1]);
+ lsp_insert (lsp, area->lspdb[level - 1]);
listnode_add (lsp0->lspu.frags, lsp);
lsp->lspu.zero_lsp = lsp0;
/*
* Copy the authinfo from zero LSP
*/
- if (lsp0->tlv_data.auth_info.type) {
- memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info,
- sizeof (struct isis_passwd));
- tlv_add_authinfo (lsp->tlv_data.auth_info.type,
- lsp->tlv_data.auth_info.len,
- lsp->tlv_data.auth_info.passwd, lsp->pdu);
- }
+ if (lsp0->tlv_data.auth_info.type)
+ {
+ memcpy (&lsp->tlv_data.auth_info, &lsp->tlv_data.auth_info,
+ sizeof (struct isis_passwd));
+ tlv_add_authinfo (lsp->tlv_data.auth_info.type,
+ lsp->tlv_data.auth_info.len,
+ lsp->tlv_data.auth_info.passwd, lsp->pdu);
+ }
return lsp;
}
@@ -1341,200 +1381,221 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
/*
* First add the tlvs related to area
*/
-
+
/* Area addresses */
if (lsp->tlv_data.area_addrs == NULL)
lsp->tlv_data.area_addrs = list_new ();
list_add_list (lsp->tlv_data.area_addrs, area->area_addrs);
/* Protocols Supported */
- if (area->ip_circuits > 0
+ if (area->ip_circuits > 0
#ifdef HAVE_IPV6
|| area->ipv6_circuits > 0
#endif /* HAVE_IPV6 */
- )
+ )
{
lsp->tlv_data.nlpids = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct nlpids));
lsp->tlv_data.nlpids->count = 0;
- if (area->ip_circuits > 0) {
- lsp->tlv_data.nlpids->count++;
- lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP;
- }
+ if (area->ip_circuits > 0)
+ {
+ lsp->tlv_data.nlpids->count++;
+ lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP;
+ }
#ifdef HAVE_IPV6
- if (area->ipv6_circuits > 0) {
- lsp->tlv_data.nlpids->count++;
- lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] =
- NLPID_IPV6;
- }
+ if (area->ipv6_circuits > 0)
+ {
+ lsp->tlv_data.nlpids->count++;
+ lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] =
+ NLPID_IPV6;
+ }
#endif /* HAVE_IPV6 */
}
/* Dynamic Hostname */
- if (area->dynhostname) {
- lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV,
- sizeof (struct hostname));
+ if (area->dynhostname)
+ {
+ lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV,
+ sizeof (struct hostname));
- memcpy (lsp->tlv_data.hostname->name, unix_hostname(),
- strlen (unix_hostname()));
- lsp->tlv_data.hostname->namelen = strlen (unix_hostname());
- }
+ memcpy (lsp->tlv_data.hostname->name, unix_hostname (),
+ strlen (unix_hostname ()));
+ lsp->tlv_data.hostname->namelen = strlen (unix_hostname ());
+ }
/*
* Building the zero lsp
*/
- stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+ stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
/*
* Add the authentication info if its present
*/
- (level == 1) ? (passwd = &area->area_passwd) :
- (passwd = &area->domain_passwd);
- if (passwd->type) {
- memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd));
- tlv_add_authinfo (passwd->type, passwd->len,
- passwd->passwd, lsp->pdu);
- }
+ (level == 1) ? (passwd = &area->area_passwd) :
+ (passwd = &area->domain_passwd);
+ if (passwd->type)
+ {
+ memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd));
+ tlv_add_authinfo (passwd->type, passwd->len, passwd->passwd, lsp->pdu);
+ }
if (lsp->tlv_data.nlpids)
tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu);
if (lsp->tlv_data.hostname)
tlv_add_dynamic_hostname (lsp->tlv_data.hostname, lsp->pdu);
- if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0 )
+ if (lsp->tlv_data.area_addrs && listcount (lsp->tlv_data.area_addrs) > 0)
tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu);
-
+
memset (&tlv_data, 0, sizeof (struct tlvs));
/*
* Then build lists of tlvs related to circuits
*/
- for (node = listhead (area->circuit_list); node; nextnode (node)) {
- circuit = getdata (node);
- if (circuit->state != C_STATE_UP)
- continue;
-
- /*
- * Add IPv4 internal reachability of this circuit
- */
- if (circuit->ip_router && circuit->ip_addrs &&
- circuit->ip_addrs->count > 0) {
- if (tlv_data.ipv4_int_reachs == NULL) {
- tlv_data.ipv4_int_reachs = list_new ();
- }
- for (ipnode = listhead (circuit->ip_addrs); ipnode; nextnode (ipnode)) {
- ipv4 = getdata (ipnode);
- ipreach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
- ipreach->metrics = circuit->metrics[level - 1];
- ipreach->prefix = ipv4->prefix;
- masklen2ip (ipv4->prefixlen, &ipreach->mask);
- listnode_add (tlv_data.ipv4_int_reachs, ipreach);
- }
+ for (node = listhead (area->circuit_list); node; nextnode (node))
+ {
+ circuit = getdata (node);
+ if (circuit->state != C_STATE_UP)
+ continue;
- }
+ /*
+ * Add IPv4 internal reachability of this circuit
+ */
+ if (circuit->ip_router && circuit->ip_addrs &&
+ circuit->ip_addrs->count > 0)
+ {
+ if (tlv_data.ipv4_int_reachs == NULL)
+ {
+ tlv_data.ipv4_int_reachs = list_new ();
+ }
+ for (ipnode = listhead (circuit->ip_addrs); ipnode;
+ nextnode (ipnode))
+ {
+ ipv4 = getdata (ipnode);
+ ipreach =
+ XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
+ ipreach->metrics = circuit->metrics[level - 1];
+ ipreach->prefix = ipv4->prefix;
+ masklen2ip (ipv4->prefixlen, &ipreach->mask);
+ listnode_add (tlv_data.ipv4_int_reachs, ipreach);
+ }
+
+ }
#ifdef HAVE_IPV6
- /*
- * Add IPv6 reachability of this circuit
- */
- if (circuit->ipv6_router && circuit->ipv6_non_link &&
- circuit->ipv6_non_link->count > 0) {
-
- if (tlv_data.ipv6_reachs == NULL) {
- tlv_data.ipv6_reachs = list_new ();
- }
- for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
- nextnode (ipnode)) {
- ipv6 = getdata (ipnode);
- ip6reach = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
- memset (ip6reach, 0, sizeof (struct ipv6_reachability));
- ip6reach->metric = htonl(circuit->metrics[level - 1].metric_default);
- ip6reach->control_info = 0;
- ip6reach->prefix_len = ipv6->prefixlen;
- memcpy (ip6reach->prefix, ipv6->prefix.s6_addr,
- (ipv6->prefixlen + 7) / 8);
- listnode_add (tlv_data.ipv6_reachs, ip6reach);
- }
- }
+ /*
+ * Add IPv6 reachability of this circuit
+ */
+ if (circuit->ipv6_router && circuit->ipv6_non_link &&
+ circuit->ipv6_non_link->count > 0)
+ {
+
+ if (tlv_data.ipv6_reachs == NULL)
+ {
+ tlv_data.ipv6_reachs = list_new ();
+ }
+ for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
+ nextnode (ipnode))
+ {
+ ipv6 = getdata (ipnode);
+ ip6reach =
+ XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
+ memset (ip6reach, 0, sizeof (struct ipv6_reachability));
+ ip6reach->metric =
+ htonl (circuit->metrics[level - 1].metric_default);
+ ip6reach->control_info = 0;
+ ip6reach->prefix_len = ipv6->prefixlen;
+ memcpy (ip6reach->prefix, ipv6->prefix.s6_addr,
+ (ipv6->prefixlen + 7) / 8);
+ listnode_add (tlv_data.ipv6_reachs, ip6reach);
+ }
+ }
#endif /* HAVE_IPV6 */
-
- switch (circuit->circ_type) {
- case CIRCUIT_T_BROADCAST:
- if (level & circuit->circuit_is_type) {
- if (tlv_data.is_neighs == NULL) {
- tlv_data.is_neighs = list_new ();
- }
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
- if (level == 1)
- memcpy (is_neigh->neigh_id,
- circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
- else
- memcpy (is_neigh->neigh_id,
- circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
- is_neigh->metrics = circuit->metrics[level - 1];
- listnode_add (tlv_data.is_neighs, is_neigh);
- }
- break;
- case CIRCUIT_T_P2P:
- nei = circuit->u.p2p.neighbor;
- if (nei && (level & nei->circuit_t)) {
- if (tlv_data.is_neighs == NULL) {
- tlv_data.is_neighs = list_new ();
- tlv_data.is_neighs->del = free_tlv;
- }
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
- memcpy (is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN);
- is_neigh->metrics = circuit->metrics[level - 1];
- listnode_add (tlv_data.is_neighs, is_neigh);
- }
- break;
- case CIRCUIT_T_STATIC_IN:
- zlog_warn ("lsp_area_create: unsupported circuit type");
- break;
- case CIRCUIT_T_STATIC_OUT:
- zlog_warn ("lsp_area_create: unsupported circuit type");
- break;
- case CIRCUIT_T_DA:
- zlog_warn ("lsp_area_create: unsupported circuit type");
- break;
- default:
- zlog_warn ("lsp_area_create: unknown circuit type");
+
+ switch (circuit->circ_type)
+ {
+ case CIRCUIT_T_BROADCAST:
+ if (level & circuit->circuit_is_type)
+ {
+ if (tlv_data.is_neighs == NULL)
+ {
+ tlv_data.is_neighs = list_new ();
+ }
+ is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
+ memset (is_neigh, 0, sizeof (struct is_neigh));
+ if (level == 1)
+ memcpy (is_neigh->neigh_id,
+ circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
+ else
+ memcpy (is_neigh->neigh_id,
+ circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
+ is_neigh->metrics = circuit->metrics[level - 1];
+ listnode_add (tlv_data.is_neighs, is_neigh);
+ }
+ break;
+ case CIRCUIT_T_P2P:
+ nei = circuit->u.p2p.neighbor;
+ if (nei && (level & nei->circuit_t))
+ {
+ if (tlv_data.is_neighs == NULL)
+ {
+ tlv_data.is_neighs = list_new ();
+ tlv_data.is_neighs->del = free_tlv;
+ }
+ is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
+ memset (is_neigh, 0, sizeof (struct is_neigh));
+ memcpy (is_neigh->neigh_id, nei->sysid, ISIS_SYS_ID_LEN);
+ is_neigh->metrics = circuit->metrics[level - 1];
+ listnode_add (tlv_data.is_neighs, is_neigh);
+ }
+ break;
+ case CIRCUIT_T_STATIC_IN:
+ zlog_warn ("lsp_area_create: unsupported circuit type");
+ break;
+ case CIRCUIT_T_STATIC_OUT:
+ zlog_warn ("lsp_area_create: unsupported circuit type");
+ break;
+ case CIRCUIT_T_DA:
+ zlog_warn ("lsp_area_create: unsupported circuit type");
+ break;
+ default:
+ zlog_warn ("lsp_area_create: unknown circuit type");
+ }
}
- }
-
- while (tlv_data.ipv4_int_reachs && listcount(tlv_data.ipv4_int_reachs)) {
- if (lsp->tlv_data.ipv4_int_reachs == NULL)
- lsp->tlv_data.ipv4_int_reachs = list_new ();
- lsp_tlv_fit (lsp, &tlv_data.ipv4_int_reachs,
- &lsp->tlv_data.ipv4_int_reachs,
- IPV4_REACH_LEN, area->lsp_frag_threshold,
- tlv_add_ipv4_reachs);
- if (tlv_data.ipv4_int_reachs && listcount(tlv_data.ipv4_int_reachs))
- lsp = lsp_next_frag (LSP_FRAGMENT(lsp->lsp_header->lsp_id) + 1,
- lsp0, area, level);
- }
-#ifdef HAVE_IPV6
- while (tlv_data.ipv6_reachs && listcount(tlv_data.ipv6_reachs)) {
- if (lsp->tlv_data.ipv6_reachs == NULL)
- lsp->tlv_data.ipv6_reachs = list_new ();
- lsp_tlv_fit (lsp, &tlv_data.ipv6_reachs,
- &lsp->tlv_data.ipv6_reachs,
- IPV6_REACH_LEN, area->lsp_frag_threshold,
- tlv_add_ipv6_reachs);
- if (tlv_data.ipv6_reachs && listcount(tlv_data.ipv6_reachs))
- lsp = lsp_next_frag (LSP_FRAGMENT(lsp->lsp_header->lsp_id) + 1,
- lsp0, area, level);
- }
-#endif /* HAVE_IPV6 */
+ while (tlv_data.ipv4_int_reachs && listcount (tlv_data.ipv4_int_reachs))
+ {
+ if (lsp->tlv_data.ipv4_int_reachs == NULL)
+ lsp->tlv_data.ipv4_int_reachs = list_new ();
+ lsp_tlv_fit (lsp, &tlv_data.ipv4_int_reachs,
+ &lsp->tlv_data.ipv4_int_reachs,
+ IPV4_REACH_LEN, area->lsp_frag_threshold,
+ tlv_add_ipv4_reachs);
+ if (tlv_data.ipv4_int_reachs && listcount (tlv_data.ipv4_int_reachs))
+ lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1,
+ lsp0, area, level);
+ }
+
+#ifdef HAVE_IPV6
+ while (tlv_data.ipv6_reachs && listcount (tlv_data.ipv6_reachs))
+ {
+ if (lsp->tlv_data.ipv6_reachs == NULL)
+ lsp->tlv_data.ipv6_reachs = list_new ();
+ lsp_tlv_fit (lsp, &tlv_data.ipv6_reachs,
+ &lsp->tlv_data.ipv6_reachs,
+ IPV6_REACH_LEN, area->lsp_frag_threshold,
+ tlv_add_ipv6_reachs);
+ if (tlv_data.ipv6_reachs && listcount (tlv_data.ipv6_reachs))
+ lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1,
+ lsp0, area, level);
+ }
+#endif /* HAVE_IPV6 */
+
+ while (tlv_data.is_neighs && listcount (tlv_data.is_neighs))
+ {
+ if (lsp->tlv_data.is_neighs == NULL)
+ lsp->tlv_data.is_neighs = list_new ();
+ lsp_tlv_fit (lsp, &tlv_data.is_neighs,
+ &lsp->tlv_data.is_neighs,
+ IS_NEIGHBOURS_LEN, area->lsp_frag_threshold,
+ tlv_add_is_neighs);
+ if (tlv_data.is_neighs && listcount (tlv_data.is_neighs))
+ lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1,
+ lsp0, area, level);
+ }
- while (tlv_data.is_neighs && listcount(tlv_data.is_neighs)) {
- if (lsp->tlv_data.is_neighs == NULL)
- lsp->tlv_data.is_neighs = list_new ();
- lsp_tlv_fit (lsp, &tlv_data.is_neighs,
- &lsp->tlv_data.is_neighs,
- IS_NEIGHBOURS_LEN, area->lsp_frag_threshold,
- tlv_add_is_neighs);
- if (tlv_data.is_neighs && listcount(tlv_data.is_neighs))
- lsp = lsp_next_frag (LSP_FRAGMENT(lsp->lsp_header->lsp_id) + 1,
- lsp0, area, level);
- }
-
-
return;
}
#endif
@@ -1547,57 +1608,58 @@ build_lsp_data (struct isis_lsp *lsp, struct isis_area *area)
u_char *tlv_ptr;
struct is_neigh *is_neigh;
-
+
/* add our nlpids */
- /* the 2 is for the TL plus 1 for the nlpid*/
- tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 3);
- *tlv_ptr = PROTOCOLS_SUPPORTED; /* Type */
- *(tlv_ptr+1) = 1; /* one protocol */
-#ifdef HAVE_IPV6 /*dunno if its right*/
- *(tlv_ptr+2) = NLPID_IPV6;
+ /* the 2 is for the TL plus 1 for the nlpid */
+ tlv_ptr = lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 3);
+ *tlv_ptr = PROTOCOLS_SUPPORTED; /* Type */
+ *(tlv_ptr + 1) = 1; /* one protocol */
+#ifdef HAVE_IPV6 /*dunno if its right */
+ *(tlv_ptr + 2) = NLPID_IPV6;
#else
- *(tlv_ptr+2) = NLPID_IP;
+ *(tlv_ptr + 2) = NLPID_IP;
#endif /* HAVE_IPV6 */
/* we should add our areas here
* FIXME: we need to figure out which should be added? Adj? All? First? */
/* first, lets add ourselves to the IS neighbours info */
- /* the 2 is for the TL plus 1 for the virtual field*/
- tlv_ptr = lsppdu_realloc(lsp,MTYPE_ISIS_TLV, 3);
- *tlv_ptr = IS_NEIGHBOURS; /* Type */
- *(tlv_ptr+2) = 0; /* virtual is zero */
- lsp->tlv_data.is_neighs = list_new (); /* new list of is_neighbours */
+ /* the 2 is for the TL plus 1 for the virtual field */
+ tlv_ptr = lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 3);
+ *tlv_ptr = IS_NEIGHBOURS; /* Type */
+ *(tlv_ptr + 2) = 0; /* virtual is zero */
+ lsp->tlv_data.is_neighs = list_new (); /* new list of is_neighbours */
/* assign space for the is_neigh at the pdu end */
- is_neigh = (struct is_neigh*) lsppdu_realloc(lsp,MTYPE_ISIS_TLV,
- sizeof(struct is_neigh));
+ is_neigh = (struct is_neigh *) lsppdu_realloc (lsp, MTYPE_ISIS_TLV,
+ sizeof (struct is_neigh));
/* add this node to our list */
- listnode_add (lsp->tlv_data.is_neighs, is_neigh);
+ listnode_add (lsp->tlv_data.is_neighs, is_neigh);
/* FIXME: Do we need our designated address here? */
- memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN + 1);
+ memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN + 1);
/* FIXME: Where should we really get our own LSPs metrics from? */
- circuit = (struct isis_circuit*)listhead(circuit_list);
- /* is_neigh->metrics = circuit->metrics[lsp->level -1];*/
+ circuit = (struct isis_circuit *) listhead (circuit_list);
+ /* is_neigh->metrics = circuit->metrics[lsp->level -1]; */
/* Length */
- *(tlv_ptr+1)=(lsp->tlv_data.is_neighs->count * sizeof(struct is_neigh) +1);
+ *(tlv_ptr + 1) =
+ (lsp->tlv_data.is_neighs->count * sizeof (struct is_neigh) + 1);
/* FIXME: scan for adjencecies and add them */
/* FIXME: add reachability info */
- /* adding dynamic hostname if needed*/
- if (area->dynhostname) {
- tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 2); /* the 2 is for the TL */
- *tlv_ptr = DYNAMIC_HOSTNAME; /* Type */
- *(tlv_ptr+1) = strlen (unix_hostname()); /* Length */
- lsp->tlv_data.hostname = (struct hostname *)
- (lsppdu_realloc(lsp,
- MTYPE_ISIS_TLV,
- /* the -1 is to fit the length in the struct */
- strlen (unix_hostname())) - 1);
- memcpy (lsp->tlv_data.hostname->name, unix_hostname(),
- strlen(unix_hostname()));
- }
+ /* adding dynamic hostname if needed */
+ if (area->dynhostname)
+ {
+ tlv_ptr = lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 2); /* the 2 is for the TL */
+ *tlv_ptr = DYNAMIC_HOSTNAME; /* Type */
+ *(tlv_ptr + 1) = strlen (unix_hostname ()); /* Length */
+ lsp->tlv_data.hostname = (struct hostname *)
+ (lsppdu_realloc (lsp, MTYPE_ISIS_TLV,
+ /* the -1 is to fit the length in the struct */
+ strlen (unix_hostname ())) - 1);
+ memcpy (lsp->tlv_data.hostname->name, unix_hostname (),
+ strlen (unix_hostname ()));
+ }
}
@@ -1605,8 +1667,8 @@ build_lsp_data (struct isis_lsp *lsp, struct isis_area *area)
* 7.3.7 Generation on non-pseudonode LSPs
*/
int
-lsp_generate_non_pseudo (struct isis_area *area, int level) {
-
+lsp_generate_non_pseudo (struct isis_area *area, int level)
+{
struct isis_lsp *oldlsp, *newlsp;
u_int32_t seq_num = 0;
u_char lspid[ISIS_SYS_ID_LEN + 2];
@@ -1615,32 +1677,33 @@ lsp_generate_non_pseudo (struct isis_area *area, int level) {
memcpy (&lspid, isis->sysid, ISIS_SYS_ID_LEN);
/* only builds the lsp if the area shares the level */
- if ((area->is_type & level) == level) {
- oldlsp = lsp_search (lspid, area->lspdb[level-1]);
- if (oldlsp) {
- seq_num = ntohl (oldlsp->lsp_header->seq_num);
- lsp_search_and_destroy (oldlsp->lsp_header->lsp_id,
- area->lspdb[level-1]);
- /* FIXME: we should actually initiate a purge */
- }
- newlsp = lsp_new (lspid, area->max_lsp_lifetime[level-1], seq_num,
- area->is_type, 0, level);
- newlsp->own_lsp = 1;
-
- lsp_insert (newlsp, area->lspdb[level-1]);
- /* build_lsp_data (newlsp, area); */
- lsp_build_nonpseudo (newlsp, area);
- /* time to calculate our checksum */
- lsp_seqnum_update (newlsp);
- }
-
+ if ((area->is_type & level) == level)
+ {
+ oldlsp = lsp_search (lspid, area->lspdb[level - 1]);
+ if (oldlsp)
+ {
+ seq_num = ntohl (oldlsp->lsp_header->seq_num);
+ lsp_search_and_destroy (oldlsp->lsp_header->lsp_id,
+ area->lspdb[level - 1]);
+ /* FIXME: we should actually initiate a purge */
+ }
+ newlsp = lsp_new (lspid, area->max_lsp_lifetime[level - 1], seq_num,
+ area->is_type, 0, level);
+ newlsp->own_lsp = 1;
+
+ lsp_insert (newlsp, area->lspdb[level - 1]);
+ /* build_lsp_data (newlsp, area); */
+ lsp_build_nonpseudo (newlsp, area);
+ /* time to calculate our checksum */
+ lsp_seqnum_update (newlsp);
+ }
/* DEBUG_ADJ_PACKETS */
- if (isis->debugs & DEBUG_ADJ_PACKETS) {
- /* FIXME: is this place right? fix missing info */
- zlog_info ("ISIS-Upd (%s): Building L%d LSP",
- area->area_tag, level);
- }
+ if (isis->debugs & DEBUG_ADJ_PACKETS)
+ {
+ /* FIXME: is this place right? fix missing info */
+ zlog_info ("ISIS-Upd (%s): Building L%d LSP", area->area_tag, level);
+ }
return ISIS_OK;
}
@@ -1651,21 +1714,20 @@ lsp_generate_non_pseudo (struct isis_area *area, int level) {
int
lsp_l1_generate (struct isis_area *area)
{
- THREAD_TIMER_ON(master, area->t_lsp_refresh[0], lsp_refresh_l1, area,
- MAX_LSP_GEN_INTERVAL);
+ THREAD_TIMER_ON (master, area->t_lsp_refresh[0], lsp_refresh_l1, area,
+ MAX_LSP_GEN_INTERVAL);
return lsp_generate_non_pseudo (area, 1);
}
-
/*
* 7.3.9 Generation of level 2 LSPs (non-pseudonode)
*/
int
lsp_l2_generate (struct isis_area *area)
{
- THREAD_TIMER_ON(master, area->t_lsp_refresh[1], lsp_refresh_l2, area,
- MAX_LSP_GEN_INTERVAL);
+ THREAD_TIMER_ON (master, area->t_lsp_refresh[1], lsp_refresh_l2, area,
+ MAX_LSP_GEN_INTERVAL);
return lsp_generate_non_pseudo (area, 2);
}
@@ -1680,45 +1742,49 @@ lsp_non_pseudo_regenerate (struct isis_area *area, int level)
memset (lspid, 0, ISIS_SYS_ID_LEN + 2);
memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
-
+
lsp = lsp_search (lspid, lspdb);
-
- if (!lsp) {
- zlog_err ("ISIS-Upd (%s): lsp_non_pseudo_regenerate(): no L%d LSP found!",
- area->area_tag,
- level);
- return ISIS_ERROR;
- }
+ if (!lsp)
+ {
+ zlog_err
+ ("ISIS-Upd (%s): lsp_non_pseudo_regenerate(): no L%d LSP found!",
+ area->area_tag, level);
- lsp_clear_data (lsp);
+ return ISIS_ERROR;
+ }
+
+ lsp_clear_data (lsp);
lsp_build_nonpseudo (lsp, area);
- lsp->lsp_header->rem_lifetime = htons (isis_jitter
- (area->max_lsp_lifetime[level-1],
- MAX_AGE_JITTER));
+ lsp->lsp_header->rem_lifetime = htons (isis_jitter
+ (area->max_lsp_lifetime[level - 1],
+ MAX_AGE_JITTER));
lsp_seqnum_update (lsp);
-
- if (isis->debugs & DEBUG_UPDATE_PACKETS) {
- zlog_info ("ISIS-Upd (%s): refreshing our L%d LSP %s, "
- "seq 0x%08x, cksum 0x%04x lifetime %us",
- area->area_tag,
- level,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl(lsp->lsp_header->seq_num),
- ntohs(lsp->lsp_header->checksum),
- ntohs(lsp->lsp_header->rem_lifetime));
- }
+
+ if (isis->debugs & DEBUG_UPDATE_PACKETS)
+ {
+ zlog_info ("ISIS-Upd (%s): refreshing our L%d LSP %s, "
+ "seq 0x%08x, cksum 0x%04x lifetime %us",
+ area->area_tag,
+ level,
+ rawlspid_print (lsp->lsp_header->lsp_id),
+ ntohl (lsp->lsp_header->seq_num),
+ ntohs (lsp->lsp_header->checksum),
+ ntohs (lsp->lsp_header->rem_lifetime));
+ }
lsp->last_generated = time (NULL);
area->lsp_regenerate_pending[level - 1] = 0;
ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- for (node = listhead (lsp->lspu.frags); node; nextnode(node)) {
- frag = getdata (node);
- frag->lsp_header->rem_lifetime = htons (isis_jitter
- (area->max_lsp_lifetime[level-1],
- MAX_AGE_JITTER));
- ISIS_FLAGS_SET_ALL (frag->SRMflags);
- }
+ for (node = listhead (lsp->lspu.frags); node; nextnode (node))
+ {
+ frag = getdata (node);
+ frag->lsp_header->rem_lifetime = htons (isis_jitter
+ (area->
+ max_lsp_lifetime[level - 1],
+ MAX_AGE_JITTER));
+ ISIS_FLAGS_SET_ALL (frag->SRMflags);
+ }
if (area->ip_circuits)
isis_spf_schedule (area, level);
@@ -1729,12 +1795,11 @@ lsp_non_pseudo_regenerate (struct isis_area *area, int level)
return ISIS_OK;
}
-
/*
* Done at least every MAX_LSP_GEN_INTERVAL. Search own LSPs, update holding
* time and set SRM
*/
-int
+int
lsp_refresh_l1 (struct thread *thread)
{
struct isis_area *area;
@@ -1742,21 +1807,21 @@ lsp_refresh_l1 (struct thread *thread)
area = THREAD_ARG (thread);
assert (area);
-
+
area->t_lsp_refresh[0] = NULL;
- if (area->is_type & IS_LEVEL_1)
+ if (area->is_type & IS_LEVEL_1)
lsp_non_pseudo_regenerate (area, 1);
-
- ref_time = area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ?
+
+ ref_time = area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ?
MAX_LSP_GEN_INTERVAL : area->lsp_refresh[0];
- THREAD_TIMER_ON(master, area->t_lsp_refresh[0], lsp_refresh_l1, area,
- isis_jitter(ref_time, MAX_AGE_JITTER));
+ THREAD_TIMER_ON (master, area->t_lsp_refresh[0], lsp_refresh_l1, area,
+ isis_jitter (ref_time, MAX_AGE_JITTER));
return ISIS_OK;
}
-int
+int
lsp_refresh_l2 (struct thread *thread)
{
struct isis_area *area;
@@ -1764,21 +1829,20 @@ lsp_refresh_l2 (struct thread *thread)
area = THREAD_ARG (thread);
assert (area);
-
+
area->t_lsp_refresh[1] = NULL;
- if (area->is_type & IS_LEVEL_2)
+ if (area->is_type & IS_LEVEL_2)
lsp_non_pseudo_regenerate (area, 2);
- ref_time = area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ?
+ ref_time = area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ?
MAX_LSP_GEN_INTERVAL : area->lsp_refresh[1];
- THREAD_TIMER_ON(master, area->t_lsp_refresh[1], lsp_refresh_l2, area,
- isis_jitter(ref_time, MAX_AGE_JITTER));
+ THREAD_TIMER_ON (master, area->t_lsp_refresh[1], lsp_refresh_l2, area,
+ isis_jitter (ref_time, MAX_AGE_JITTER));
return ISIS_OK;
}
-
/*
* Something has changed -> regenerate LSP
*/
@@ -1801,60 +1865,66 @@ lsp_l2_regenerate (struct thread *thread)
area = THREAD_ARG (thread);
area->lsp_regenerate_pending[1] = 0;
-
+
return lsp_non_pseudo_regenerate (area, 2);
}
-int
+int
lsp_regenerate_schedule (struct isis_area *area)
{
struct isis_lsp *lsp;
u_char id[ISIS_SYS_ID_LEN + 2];
time_t now, diff;
- memcpy(id, isis->sysid, ISIS_SYS_ID_LEN);
- LSP_PSEUDO_ID(id) = LSP_FRAGMENT(id) = 0;
+ memcpy (id, isis->sysid, ISIS_SYS_ID_LEN);
+ LSP_PSEUDO_ID (id) = LSP_FRAGMENT (id) = 0;
now = time (NULL);
/*
* First level 1
*/
- if (area->is_type & IS_LEVEL_1) {
- lsp = lsp_search (id, area->lspdb[0]);
- if (!lsp || area->lsp_regenerate_pending[0])
- goto L2;
- /*
- * Throttle avoidance
- */
- diff = now - lsp->last_generated;
- if (diff < MIN_LSP_GEN_INTERVAL) {
- area->lsp_regenerate_pending[0] = 1;
- thread_add_timer (master, lsp_l1_regenerate, area,
- MIN_LSP_GEN_INTERVAL - diff);
- return ISIS_OK;
- } else
- lsp_non_pseudo_regenerate (area, 1);
- }
+ if (area->is_type & IS_LEVEL_1)
+ {
+ lsp = lsp_search (id, area->lspdb[0]);
+ if (!lsp || area->lsp_regenerate_pending[0])
+ goto L2;
+ /*
+ * Throttle avoidance
+ */
+ diff = now - lsp->last_generated;
+ if (diff < MIN_LSP_GEN_INTERVAL)
+ {
+ area->lsp_regenerate_pending[0] = 1;
+ thread_add_timer (master, lsp_l1_regenerate, area,
+ MIN_LSP_GEN_INTERVAL - diff);
+ return ISIS_OK;
+ }
+ else
+ lsp_non_pseudo_regenerate (area, 1);
+ }
/*
* then 2
*/
- L2:
- if (area->is_type & IS_LEVEL_2) {
- lsp = lsp_search (id, area->lspdb[1]);
- if (!lsp || area->lsp_regenerate_pending[1])
- return ISIS_OK;
- /*
- * Throttle avoidance
- */
- diff = now - lsp->last_generated;
- if (diff < MIN_LSP_GEN_INTERVAL) {
- area->lsp_regenerate_pending[1] = 1;
- thread_add_timer (master, lsp_l2_regenerate, area,
- MIN_LSP_GEN_INTERVAL - diff);
- return ISIS_OK;
- } else
- lsp_non_pseudo_regenerate (area, 2);
- }
-
- return ISIS_OK;
+L2:
+ if (area->is_type & IS_LEVEL_2)
+ {
+ lsp = lsp_search (id, area->lspdb[1]);
+ if (!lsp || area->lsp_regenerate_pending[1])
+ return ISIS_OK;
+ /*
+ * Throttle avoidance
+ */
+ diff = now - lsp->last_generated;
+ if (diff < MIN_LSP_GEN_INTERVAL)
+ {
+ area->lsp_regenerate_pending[1] = 1;
+ thread_add_timer (master, lsp_l2_regenerate, area,
+ MIN_LSP_GEN_INTERVAL - diff);
+ return ISIS_OK;
+ }
+ else
+ lsp_non_pseudo_regenerate (area, 2);
+ }
+
+ return ISIS_OK;
}
/*
@@ -1865,8 +1935,8 @@ lsp_regenerate_schedule (struct isis_area *area)
* 7.3.8 and 7.3.10 Generation of level 1 and 2 pseudonode LSPs
*/
void
-lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
- int level)
+lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
+ int level)
{
struct isis_adjacency *adj;
struct is_neigh *is_neigh;
@@ -1877,10 +1947,10 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
assert (circuit);
assert (circuit->circ_type == CIRCUIT_T_BROADCAST);
-
+
if (!circuit->u.bc.is_dr[level - 1])
- return; /* we are not DIS on this circuit */
-
+ return; /* we are not DIS on this circuit */
+
lsp->level = level;
if (level == 1)
lsp->lsp_header->lsp_bits |= IS_LEVEL_1;
@@ -1890,56 +1960,63 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
/*
* add self to IS neighbours
*/
- if (lsp->tlv_data.is_neighs == NULL) {
- lsp->tlv_data.is_neighs = list_new ();
- lsp->tlv_data.is_neighs->del = free_tlv;
- }
+ if (lsp->tlv_data.is_neighs == NULL)
+ {
+ lsp->tlv_data.is_neighs = list_new ();
+ lsp->tlv_data.is_neighs->del = free_tlv;
+ }
is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
memset (is_neigh, 0, sizeof (struct is_neigh));
memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN);
listnode_add (lsp->tlv_data.is_neighs, is_neigh);
-
- adj_list = list_new();
- isis_adj_build_up_list (circuit->u.bc.adjdb[level-1], adj_list);
-
- for (node = listhead (adj_list); node; nextnode (node)){
- adj = getdata (node);
- if (adj->circuit_t & level) {
- if ((level == 1 && adj->sys_type == ISIS_SYSTYPE_L1_IS) ||
- (level == 1 && adj->sys_type == ISIS_SYSTYPE_L2_IS &&
- adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
- (level == 2 && adj->sys_type == ISIS_SYSTYPE_L2_IS)) {
- /* an IS neighbour -> add it */
- is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
- memset (is_neigh, 0, sizeof (struct is_neigh));
- memcpy (&is_neigh->neigh_id, adj->sysid, ISIS_SYS_ID_LEN);
- listnode_add (lsp->tlv_data.is_neighs, is_neigh);
- } else if (level == 1 && adj->sys_type == ISIS_SYSTYPE_ES) {
- /* an ES neigbour add it, if we are building level 1 LSP */
- /* FIXME: the tlv-format is hard to use here */
- if (lsp->tlv_data.es_neighs == NULL) {
- lsp->tlv_data.es_neighs = list_new ();
- lsp->tlv_data.es_neighs->del = free_tlv;
- }
- es_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct es_neigh));
- memset (es_neigh, 0, sizeof (struct es_neigh));
- memcpy (&es_neigh->first_es_neigh, adj->sysid, ISIS_SYS_ID_LEN);
- listnode_add (lsp->tlv_data.es_neighs, is_neigh);
- }
+
+ adj_list = list_new ();
+ isis_adj_build_up_list (circuit->u.bc.adjdb[level - 1], adj_list);
+
+ for (node = listhead (adj_list); node; nextnode (node))
+ {
+ adj = getdata (node);
+ if (adj->circuit_t & level)
+ {
+ if ((level == 1 && adj->sys_type == ISIS_SYSTYPE_L1_IS) ||
+ (level == 1 && adj->sys_type == ISIS_SYSTYPE_L2_IS &&
+ adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
+ (level == 2 && adj->sys_type == ISIS_SYSTYPE_L2_IS))
+ {
+ /* an IS neighbour -> add it */
+ is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh));
+ memset (is_neigh, 0, sizeof (struct is_neigh));
+ memcpy (&is_neigh->neigh_id, adj->sysid, ISIS_SYS_ID_LEN);
+ listnode_add (lsp->tlv_data.is_neighs, is_neigh);
+ }
+ else if (level == 1 && adj->sys_type == ISIS_SYSTYPE_ES)
+ {
+ /* an ES neigbour add it, if we are building level 1 LSP */
+ /* FIXME: the tlv-format is hard to use here */
+ if (lsp->tlv_data.es_neighs == NULL)
+ {
+ lsp->tlv_data.es_neighs = list_new ();
+ lsp->tlv_data.es_neighs->del = free_tlv;
+ }
+ es_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct es_neigh));
+ memset (es_neigh, 0, sizeof (struct es_neigh));
+ memcpy (&es_neigh->first_es_neigh, adj->sysid, ISIS_SYS_ID_LEN);
+ listnode_add (lsp->tlv_data.es_neighs, is_neigh);
+ }
+ }
}
- }
-
+
stream_set_putp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
/*
* Add the authentication info if it's present
*/
- (level == 1) ? (passwd = &circuit->area->area_passwd) :
- (passwd = &circuit->area->domain_passwd);
- if (passwd->type) {
- memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd));
- tlv_add_authinfo (passwd->type, passwd->len,
- passwd->passwd, lsp->pdu);
- }
+ (level == 1) ? (passwd = &circuit->area->area_passwd) :
+ (passwd = &circuit->area->domain_passwd);
+ if (passwd->type)
+ {
+ memcpy (&lsp->tlv_data.auth_info, passwd, sizeof (struct isis_passwd));
+ tlv_add_authinfo (passwd->type, passwd->len, passwd->passwd, lsp->pdu);
+ }
if (lsp->tlv_data.is_neighs && listcount (lsp->tlv_data.is_neighs) > 0)
tlv_add_is_neighs (lsp->tlv_data.is_neighs, lsp->pdu);
@@ -1948,9 +2025,9 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
tlv_add_is_neighs (lsp->tlv_data.es_neighs, lsp->pdu);
lsp->lsp_header->pdu_len = htons (stream_get_putp (lsp->pdu));
- iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
- ntohs(lsp->lsp_header->pdu_len) - 12, 12);
-
+ iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
+ ntohs (lsp->lsp_header->pdu_len) - 12, 12);
+
list_delete (adj_list);
return;
@@ -1962,41 +2039,42 @@ lsp_pseudo_regenerate (struct isis_circuit *circuit, int level)
dict_t *lspdb = circuit->area->lspdb[level - 1];
struct isis_lsp *lsp;
u_char lsp_id[ISIS_SYS_ID_LEN + 2];
-
+
memcpy (lsp_id, isis->sysid, ISIS_SYS_ID_LEN);
- LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id;
- LSP_FRAGMENT(lsp_id) = 0;
-
+ LSP_PSEUDO_ID (lsp_id) = circuit->circuit_id;
+ LSP_FRAGMENT (lsp_id) = 0;
+
lsp = lsp_search (lsp_id, lspdb);
-
- if (!lsp) {
- zlog_err ("lsp_pseudo_regenerate(): no l%d LSP %s found!", level,
- rawlspid_print(lsp_id));
- return ISIS_ERROR;
- }
- lsp_clear_data (lsp);
+
+ if (!lsp)
+ {
+ zlog_err ("lsp_pseudo_regenerate(): no l%d LSP %s found!", level,
+ rawlspid_print (lsp_id));
+ return ISIS_ERROR;
+ }
+ lsp_clear_data (lsp);
lsp_build_pseudo (lsp, circuit, level);
- lsp->lsp_header->rem_lifetime =
+ lsp->lsp_header->rem_lifetime =
htons (isis_jitter (circuit->area->max_lsp_lifetime[level - 1],
- MAX_AGE_JITTER));
+ MAX_AGE_JITTER));
lsp_inc_seqnum (lsp, 0);
-
- if (isis->debugs & DEBUG_UPDATE_PACKETS) {
- zlog_info ("ISIS-Upd (%s): refreshing pseudo LSP L%d %s",
- circuit->area->area_tag, level,
- rawlspid_print (lsp->lsp_header->lsp_id));
- }
+
+ if (isis->debugs & DEBUG_UPDATE_PACKETS)
+ {
+ zlog_info ("ISIS-Upd (%s): refreshing pseudo LSP L%d %s",
+ circuit->area->area_tag, level,
+ rawlspid_print (lsp->lsp_header->lsp_id));
+ }
lsp->last_generated = time (NULL);
ISIS_FLAGS_SET_ALL (lsp->SRMflags);
-
+
return ISIS_OK;
}
-
int
lsp_l1_refresh_pseudo (struct thread *thread)
{
@@ -2004,32 +2082,33 @@ lsp_l1_refresh_pseudo (struct thread *thread)
int retval;
unsigned long ref_time;
- circuit = THREAD_ARG(thread);
-
+ circuit = THREAD_ARG (thread);
+
if (!circuit->u.bc.is_dr[0])
- return ISIS_ERROR; /* FIXME: purge and such */
-
+ return ISIS_ERROR; /* FIXME: purge and such */
+
retval = lsp_pseudo_regenerate (circuit, 1);
-
- ref_time = circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ?
+
+ ref_time = circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ?
MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[0];
- THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[0],
- lsp_l1_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));
-
+ THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[0],
+ lsp_l1_refresh_pseudo, circuit,
+ isis_jitter (ref_time, MAX_AGE_JITTER));
+
return retval;
}
-int
+int
lsp_l1_pseudo_generate (struct isis_circuit *circuit)
{
struct isis_lsp *lsp;
u_char id[ISIS_SYS_ID_LEN + 2];
unsigned long ref_time;
- memcpy(id, isis->sysid, ISIS_SYS_ID_LEN);
- LSP_FRAGMENT(id) = 0;
- LSP_PSEUDO_ID(id) = circuit->circuit_id;
+ memcpy (id, isis->sysid, ISIS_SYS_ID_LEN);
+ LSP_FRAGMENT (id) = 0;
+ LSP_PSEUDO_ID (id) = circuit->circuit_id;
/*
* If for some reason have a pseudo LSP in the db already -> regenerate
@@ -2037,19 +2116,20 @@ lsp_l1_pseudo_generate (struct isis_circuit *circuit)
if (lsp_search (id, circuit->area->lspdb[0]))
return lsp_pseudo_regenerate (circuit, 1);
lsp = lsp_new (id, circuit->area->max_lsp_lifetime[0],
- 1, circuit->area->is_type, 0, 1);
-
+ 1, circuit->area->is_type, 0, 1);
+
lsp_build_pseudo (lsp, circuit, 1);
-
+
lsp->own_lsp = 1;
lsp_insert (lsp, circuit->area->lspdb[0]);
ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- ref_time = circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ?
+ ref_time = circuit->area->lsp_refresh[0] > MAX_LSP_GEN_INTERVAL ?
MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[0];
- THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[0],
- lsp_l1_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));
+ THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[0],
+ lsp_l1_refresh_pseudo, circuit,
+ isis_jitter (ref_time, MAX_AGE_JITTER));
return lsp_regenerate_schedule (circuit->area);
}
@@ -2060,64 +2140,63 @@ lsp_l2_refresh_pseudo (struct thread *thread)
struct isis_circuit *circuit;
int retval;
unsigned long ref_time;
- circuit = THREAD_ARG(thread);
-
+ circuit = THREAD_ARG (thread);
+
if (!circuit->u.bc.is_dr[1])
- return ISIS_ERROR; /* FIXME: purge and such */
-
+ return ISIS_ERROR; /* FIXME: purge and such */
+
retval = lsp_pseudo_regenerate (circuit, 2);
- ref_time = circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ?
+ ref_time = circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ?
MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[1];
- THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[1],
- lsp_l2_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));
+ THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[1],
+ lsp_l2_refresh_pseudo, circuit,
+ isis_jitter (ref_time, MAX_AGE_JITTER));
return retval;
}
-
-int
+int
lsp_l2_pseudo_generate (struct isis_circuit *circuit)
{
struct isis_lsp *lsp;
u_char id[ISIS_SYS_ID_LEN + 2];
unsigned long ref_time;
- memcpy(id, isis->sysid, ISIS_SYS_ID_LEN);
- LSP_FRAGMENT(id) = 0;
- LSP_PSEUDO_ID(id) = circuit->circuit_id;
+ memcpy (id, isis->sysid, ISIS_SYS_ID_LEN);
+ LSP_FRAGMENT (id) = 0;
+ LSP_PSEUDO_ID (id) = circuit->circuit_id;
if (lsp_search (id, circuit->area->lspdb[1]))
return lsp_pseudo_regenerate (circuit, 2);
lsp = lsp_new (id, circuit->area->max_lsp_lifetime[1],
- 1, circuit->area->is_type, 0, 2);
+ 1, circuit->area->is_type, 0, 2);
lsp_build_pseudo (lsp, circuit, 2);
-
- ref_time = circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ?
+
+ ref_time = circuit->area->lsp_refresh[1] > MAX_LSP_GEN_INTERVAL ?
MAX_LSP_GEN_INTERVAL : circuit->area->lsp_refresh[1];
lsp->own_lsp = 1;
lsp_insert (lsp, circuit->area->lspdb[1]);
ISIS_FLAGS_SET_ALL (lsp->SRMflags);
-
- THREAD_TIMER_ON(master, circuit->u.bc.t_refresh_pseudo_lsp[1],
- lsp_l2_refresh_pseudo, circuit, isis_jitter (ref_time, MAX_AGE_JITTER));
-
- return lsp_regenerate_schedule (circuit->area);
-}
+ THREAD_TIMER_ON (master, circuit->u.bc.t_refresh_pseudo_lsp[1],
+ lsp_l2_refresh_pseudo, circuit,
+ isis_jitter (ref_time, MAX_AGE_JITTER));
+ return lsp_regenerate_schedule (circuit->area);
+}
/*
* Walk through LSPs for an area
* - set remaining lifetime
* - set LSPs with SRMflag set for sending
*/
-int
+int
lsp_tick (struct thread *thread)
{
struct isis_area *area;
@@ -2129,80 +2208,92 @@ lsp_tick (struct thread *thread)
int level;
lsp_list = list_new ();
-
+
area = THREAD_ARG (thread);
assert (area);
- THREAD_TIMER_ON(master, area->t_tick, lsp_tick, area, 1);
+ THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
/*
* Build a list of LSPs with (any) SRMflag set
* and removed the ones that have aged out
*/
- for (level = 0; level < ISIS_LEVELS; level++) {
- if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) {
- dnode = dict_first (area->lspdb[level]);
- while (dnode != NULL) {
- dnode_next = dict_next (area->lspdb[level], dnode);
- lsp = dnode_get (dnode);
- lsp_set_time (lsp);
- if (lsp->age_out == 0) {
-
- zlog_info ("ISIS-Upd (%s): L%u LSP %s seq 0x%08x aged out",
- area->area_tag,
- lsp->level,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl(lsp->lsp_header->seq_num));
-
- lsp_destroy (lsp);
- dict_delete (area->lspdb[level], dnode);
- } else if (flags_any_set (lsp->SRMflags))
- listnode_add (lsp_list, lsp);
- dnode = dnode_next;
- }
-
- /*
- * Send LSPs on circuits indicated by the SRMflags
- */
- if (listcount (lsp_list) > 0) {
- for (cnode = listhead (area->circuit_list); cnode; nextnode (cnode)) {
- circuit = getdata (cnode);
- for (lspnode = listhead (lsp_list); lspnode; nextnode (lspnode)) {
- lsp = getdata (lspnode);
- if (ISIS_CHECK_FLAG (lsp->SRMflags, circuit)) {
- /* FIXME: if same or elder lsp is already in lsp queue */
- listnode_add (circuit->lsp_queue, lsp);
- thread_add_event (master, send_lsp, circuit, 0);
- }
- }
- }
- }
- list_delete_all_node (lsp_list);
+ for (level = 0; level < ISIS_LEVELS; level++)
+ {
+ if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
+ {
+ dnode = dict_first (area->lspdb[level]);
+ while (dnode != NULL)
+ {
+ dnode_next = dict_next (area->lspdb[level], dnode);
+ lsp = dnode_get (dnode);
+ lsp_set_time (lsp);
+ if (lsp->age_out == 0)
+ {
+
+ zlog_info ("ISIS-Upd (%s): L%u LSP %s seq 0x%08x aged out",
+ area->area_tag,
+ lsp->level,
+ rawlspid_print (lsp->lsp_header->lsp_id),
+ ntohl (lsp->lsp_header->seq_num));
+
+ lsp_destroy (lsp);
+ dict_delete (area->lspdb[level], dnode);
+ }
+ else if (flags_any_set (lsp->SRMflags))
+ listnode_add (lsp_list, lsp);
+ dnode = dnode_next;
+ }
+
+ /*
+ * Send LSPs on circuits indicated by the SRMflags
+ */
+ if (listcount (lsp_list) > 0)
+ {
+ for (cnode = listhead (area->circuit_list); cnode;
+ nextnode (cnode))
+ {
+ circuit = getdata (cnode);
+ for (lspnode = listhead (lsp_list); lspnode;
+ nextnode (lspnode))
+ {
+ lsp = getdata (lspnode);
+ if (ISIS_CHECK_FLAG (lsp->SRMflags, circuit))
+ {
+ /* FIXME: if same or elder lsp is already in lsp
+ * queue */
+ listnode_add (circuit->lsp_queue, lsp);
+ thread_add_event (master, send_lsp, circuit, 0);
+ }
+ }
+ }
+ }
+ list_delete_all_node (lsp_list);
+ }
}
- }
list_delete (lsp_list);
return ISIS_OK;
}
-
void
-lsp_purge_dr (u_char *id, struct isis_circuit *circuit, int level)
+lsp_purge_dr (u_char * id, struct isis_circuit *circuit, int level)
{
struct isis_lsp *lsp;
-
+
lsp = lsp_search (id, circuit->area->lspdb[level - 1]);
-
- if (lsp && lsp->purged == 0) {
- lsp->lsp_header->rem_lifetime = htons (0);
- lsp->lsp_header->pdu_len = htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
- lsp->purged = 0;
- iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
- ntohs(lsp->lsp_header->pdu_len) - 12, 12);
- ISIS_FLAGS_SET_ALL(lsp->SRMflags);
- }
-
-
+
+ if (lsp && lsp->purged == 0)
+ {
+ lsp->lsp_header->rem_lifetime = htons (0);
+ lsp->lsp_header->pdu_len =
+ htons (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
+ lsp->purged = 0;
+ iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
+ ntohs (lsp->lsp_header->pdu_len) - 12, 12);
+ ISIS_FLAGS_SET_ALL (lsp->SRMflags);
+ }
+
return;
}
@@ -2211,8 +2302,8 @@ lsp_purge_dr (u_char *id, struct isis_circuit *circuit, int level)
* -> Do as in 7.3.16.4
*/
void
-lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
- struct isis_area *area)
+lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
+ struct isis_area *area)
{
struct isis_lsp *lsp;
@@ -2222,17 +2313,17 @@ lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
zlog_info ("LSP PURGE NON EXIST");
lsp = XMALLOC (MTYPE_ISIS_LSP, sizeof (struct isis_lsp));
memset (lsp, 0, sizeof (struct isis_lsp));
- /*FIXME: BUG BUG BUG! the lsp doesn't exist here!*/
- /*did smt here, maybe good probably not*/
+ /*FIXME: BUG BUG BUG! the lsp doesn't exist here! */
+ /*did smt here, maybe good probably not */
lsp->level = ((lsp_hdr->lsp_bits & LSPBIT_IST) == IS_LEVEL_1) ? 1 : 2;
lsp->pdu = stream_new (ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN);
- lsp->isis_header = (struct isis_fixed_hdr*)STREAM_DATA(lsp->pdu);
+ lsp->isis_header = (struct isis_fixed_hdr *) STREAM_DATA (lsp->pdu);
fill_fixed_hdr (lsp->isis_header, (lsp->level == 1) ? L1_LINK_STATE
- : L2_LINK_STATE);
- lsp->lsp_header = (struct isis_link_state_hdr*)(STREAM_DATA(lsp->pdu) +
- ISIS_FIXED_HDR_LEN);
+ : L2_LINK_STATE);
+ lsp->lsp_header = (struct isis_link_state_hdr *) (STREAM_DATA (lsp->pdu) +
+ ISIS_FIXED_HDR_LEN);
memcpy (lsp->lsp_header, lsp_hdr, ISIS_LSP_HDR_LEN);
-
+
/*
* Retain only LSP header
*/
@@ -2244,13 +2335,13 @@ lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
/*
* Put the lsp into LSPdb
*/
- lsp_insert (lsp, area->lspdb[lsp->level-1]);
+ lsp_insert (lsp, area->lspdb[lsp->level - 1]);
/*
* Send in to whole area
*/
ISIS_FLAGS_SET_ALL (lsp->SRMflags);
-
+
return;
}
@@ -2258,27 +2349,29 @@ lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
int
top_lsp_refresh (struct thread *thread)
{
- struct isis_lsp *lsp;
+ struct isis_lsp *lsp;
lsp = THREAD_ARG (thread);
assert (lsp);
lsp->t_lsp_top_ref = NULL;
- lsp->lsp_header->rem_lifetime = htons (isis_jitter(MAX_AGE,MAX_AGE_JITTER));
- lsp->lsp_header->seq_num = htonl(ntohl(lsp->lsp_header->seq_num) +1);
+ lsp->lsp_header->rem_lifetime =
+ htons (isis_jitter (MAX_AGE, MAX_AGE_JITTER));
+ lsp->lsp_header->seq_num = htonl (ntohl (lsp->lsp_header->seq_num) + 1);
ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- if (isis->debugs & DEBUG_UPDATE_PACKETS) {
- zlog_info ("ISIS-Upd (): refreshing Topology L1 %s",
- rawlspid_print (lsp->lsp_header->lsp_id));
- }
+ if (isis->debugs & DEBUG_UPDATE_PACKETS)
+ {
+ zlog_info ("ISIS-Upd (): refreshing Topology L1 %s",
+ rawlspid_print (lsp->lsp_header->lsp_id));
+ }
/* time to calculate our checksum */
iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
- ntohs(lsp->lsp_header->pdu_len) - 12, 12);
- THREAD_TIMER_ON(master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp,
- isis_jitter (MAX_LSP_GEN_INTERVAL, MAX_LSP_GEN_JITTER));
+ ntohs (lsp->lsp_header->pdu_len) - 12, 12);
+ THREAD_TIMER_ON (master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp,
+ isis_jitter (MAX_LSP_GEN_INTERVAL, MAX_LSP_GEN_JITTER));
return ISIS_OK;
}
@@ -2293,34 +2386,39 @@ generate_topology_lsps (struct isis_area *area)
struct isis_lsp *lsp;
/* first we find the maximal node */
- LIST_LOOP (area->topology, arc, node) {
- if (arc->from_node > max) max = arc->from_node;
- if (arc->to_node > max) max = arc->to_node;
+ LIST_LOOP (area->topology, arc, node)
+ {
+ if (arc->from_node > max)
+ max = arc->from_node;
+ if (arc->to_node > max)
+ max = arc->to_node;
}
+ for (i = 1; i < (max + 1); i++)
+ {
+ memcpy (lspid, area->topology_baseis, ISIS_SYS_ID_LEN);
+ LSP_PSEUDO_ID (lspid) = 0x00;
+ LSP_FRAGMENT (lspid) = 0x00;
+ lspid[ISIS_SYS_ID_LEN - 1] = (i & 0xFF);
+ lspid[ISIS_SYS_ID_LEN - 2] = ((i >> 8) & 0xFF);
+
+ lsp = lsp_new (lspid, isis_jitter (area->max_lsp_lifetime[0],
+ MAX_AGE_JITTER), 1, IS_LEVEL_1, 0,
+ 1);
+ lsp->from_topology = 1;
+ /* creating data based on topology */
+ build_topology_lsp_data (lsp, area, i);
+ /* time to calculate our checksum */
+ iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
+ ntohs (lsp->lsp_header->pdu_len) - 12, 12);
+ THREAD_TIMER_ON (master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp,
+ isis_jitter (MAX_LSP_GEN_INTERVAL,
+ MAX_LSP_GEN_JITTER));
+
+ ISIS_FLAGS_SET_ALL (lsp->SRMflags);
+ lsp_insert (lsp, area->lspdb[0]);
- for (i = 1; i < (max+1); i++) {
- memcpy (lspid,area->topology_baseis,ISIS_SYS_ID_LEN);
- LSP_PSEUDO_ID (lspid) = 0x00;
- LSP_FRAGMENT (lspid) = 0x00;
- lspid[ISIS_SYS_ID_LEN-1] = (i & 0xFF);
- lspid[ISIS_SYS_ID_LEN-2] = ((i >> 8) & 0xFF);
-
- lsp = lsp_new (lspid, isis_jitter (area->max_lsp_lifetime[0],
- MAX_AGE_JITTER), 1, IS_LEVEL_1, 0, 1);
- lsp->from_topology = 1;
- /* creating data based on topology */
- build_topology_lsp_data (lsp,area,i);
- /* time to calculate our checksum */
- iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
- ntohs(lsp->lsp_header->pdu_len) - 12, 12);
- THREAD_TIMER_ON(master, lsp->t_lsp_top_ref, top_lsp_refresh, lsp,
- isis_jitter(MAX_LSP_GEN_INTERVAL, MAX_LSP_GEN_JITTER));
-
- ISIS_FLAGS_SET_ALL(lsp->SRMflags);
- lsp_insert (lsp,area->lspdb[0]);
-
- }
+ }
}
void
@@ -2330,20 +2428,22 @@ remove_topology_lsps (struct isis_area *area)
dnode_t *dnode, *dnode_next;
dnode = dict_first (area->lspdb[0]);
- while (dnode != NULL) {
- dnode_next = dict_next (area->lspdb[0], dnode);
- lsp = dnode_get (dnode);
- if (lsp->from_topology) {
- THREAD_TIMER_OFF(lsp->t_lsp_top_ref);
- lsp_destroy (lsp);
- dict_delete (area->lspdb[0], dnode);
+ while (dnode != NULL)
+ {
+ dnode_next = dict_next (area->lspdb[0], dnode);
+ lsp = dnode_get (dnode);
+ if (lsp->from_topology)
+ {
+ THREAD_TIMER_OFF (lsp->t_lsp_top_ref);
+ lsp_destroy (lsp);
+ dict_delete (area->lspdb[0], dnode);
+ }
+ dnode = dnode_next;
}
- dnode = dnode_next;
- }
}
void
-build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area,
+build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area,
int lsp_top_num)
{
struct listnode *node;
@@ -2354,89 +2454,98 @@ build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area,
char buff[200];
/* add our nlpids */
- /* the 2 is for the TL plus 1 for the nlpid*/
- tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 3);
- *tlv_ptr = PROTOCOLS_SUPPORTED; /* Type */
- *(tlv_ptr+1) = 1; /* one protocol */
- *(tlv_ptr+2) = NLPID_IP;
- lsp->tlv_data.nlpids = (struct nlpids*)(tlv_ptr+1);
+ /* the 2 is for the TL plus 1 for the nlpid */
+ tlv_ptr = lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 3);
+ *tlv_ptr = PROTOCOLS_SUPPORTED; /* Type */
+ *(tlv_ptr + 1) = 1; /* one protocol */
+ *(tlv_ptr + 2) = NLPID_IP;
+ lsp->tlv_data.nlpids = (struct nlpids *) (tlv_ptr + 1);
/* first, lets add the tops */
- /* the 2 is for the TL plus 1 for the virtual field*/
- tlv_ptr = lsppdu_realloc (lsp ,MTYPE_ISIS_TLV, 3);
- *tlv_ptr = IS_NEIGHBOURS; /* Type */
- *(tlv_ptr+1) = 1; /* this is the virtual char len*/
- *(tlv_ptr+2) = 0; /* virtual is zero */
- lsp->tlv_data.is_neighs = list_new (); /* new list of is_neighbours */
+ /* the 2 is for the TL plus 1 for the virtual field */
+ tlv_ptr = lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 3);
+ *tlv_ptr = IS_NEIGHBOURS; /* Type */
+ *(tlv_ptr + 1) = 1; /* this is the virtual char len */
+ *(tlv_ptr + 2) = 0; /* virtual is zero */
+ lsp->tlv_data.is_neighs = list_new (); /* new list of is_neighbours */
/* add reachability for this IS for simulated 1 */
- if (lsp_top_num == 1) {
- /* assign space for the is_neigh at the pdu end */
- is_neigh = (struct is_neigh*) lsppdu_realloc(lsp, MTYPE_ISIS_TLV,
- sizeof(struct is_neigh));
- /* add this node to our list */
- listnode_add (lsp->tlv_data.is_neighs, is_neigh);
- memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN);
- LSP_PSEUDO_ID (is_neigh->neigh_id) = 0x00;
- is_neigh->metrics.metric_default = 0x00; /* no special reason */
- is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
- is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
- is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
- /* don't forget the length */
- *(tlv_ptr+1) += IS_NEIGHBOURS_LEN; /* the -1 is the virtual */
- /* no need to check for fragging here, it is a lonely is_reach */
- }
-
- /* addding is reachabilities */
- LIST_LOOP (area->topology, arc, node) {
- if ((arc->from_node == lsp_top_num) ||
- (arc->to_node == lsp_top_num)) {
- if (arc->to_node == lsp_top_num) to_lsp = arc->from_node;
- if (arc->from_node == lsp_top_num) to_lsp = arc->to_node;
-
- /* if the length here is about to cross the FF limit, we reTLV */
- if (*(tlv_ptr+1) >= (0xFF - IS_NEIGHBOURS_LEN)) {
- /* retlv */
- /* the 2 is for the TL plus 1 for the virtual field*/
- tlv_ptr = lsppdu_realloc(lsp,MTYPE_ISIS_TLV, 3);
- *tlv_ptr = IS_NEIGHBOURS; /* Type */
- *(tlv_ptr+1) = 1; /* this is the virtual char len*/
- *(tlv_ptr+2) = 0; /* virtual is zero */
- }
- /* doing this here assures us that we won't add an "empty" tlv */
+ if (lsp_top_num == 1)
+ {
/* assign space for the is_neigh at the pdu end */
- is_neigh = (struct is_neigh*) lsppdu_realloc (lsp, MTYPE_ISIS_TLV,
- sizeof(struct is_neigh));
+ is_neigh = (struct is_neigh *) lsppdu_realloc (lsp, MTYPE_ISIS_TLV,
+ sizeof (struct
+ is_neigh));
/* add this node to our list */
- listnode_add (lsp->tlv_data.is_neighs, is_neigh);
- memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN);
+ listnode_add (lsp->tlv_data.is_neighs, is_neigh);
+ memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN);
LSP_PSEUDO_ID (is_neigh->neigh_id) = 0x00;
- is_neigh->neigh_id[ISIS_SYS_ID_LEN-1] = (to_lsp & 0xFF);
- is_neigh->neigh_id[ISIS_SYS_ID_LEN-2] = ((to_lsp >> 8) & 0xFF);
- is_neigh->metrics.metric_default = arc->distance;
+ is_neigh->metrics.metric_default = 0x00; /* no special reason */
is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
/* don't forget the length */
- *(tlv_ptr+1) += IS_NEIGHBOURS_LEN; /* the -1 is the virtual */
+ *(tlv_ptr + 1) += IS_NEIGHBOURS_LEN; /* the -1 is the virtual */
+ /* no need to check for fragging here, it is a lonely is_reach */
}
- }
- /* adding dynamic hostname if needed*/
- if (area->dynhostname) {
- memset (buff,0x00,200);
- sprintf (buff,"feedme%d",lsp_top_num);
- tlv_ptr = lsppdu_realloc (lsp,MTYPE_ISIS_TLV, 2); /* the 2 is for the TL */
- *tlv_ptr = DYNAMIC_HOSTNAME; /* Type */
- *(tlv_ptr+1) = strlen (buff); /* Length */
- /* the -1 is to fit the length in the struct */
- lsp->tlv_data.hostname = (struct hostname *)
- (lsppdu_realloc (lsp, MTYPE_ISIS_TLV, strlen(buff)) - 1);
- memcpy (lsp->tlv_data.hostname->name, buff, strlen(buff));
+ /* addding is reachabilities */
+ LIST_LOOP (area->topology, arc, node)
+ {
+ if ((arc->from_node == lsp_top_num) || (arc->to_node == lsp_top_num))
+ {
+ if (arc->to_node == lsp_top_num)
+ to_lsp = arc->from_node;
+ if (arc->from_node == lsp_top_num)
+ to_lsp = arc->to_node;
+
+ /* if the length here is about to cross the FF limit, we reTLV */
+ if (*(tlv_ptr + 1) >= (0xFF - IS_NEIGHBOURS_LEN))
+ {
+ /* retlv */
+ /* the 2 is for the TL plus 1 for the virtual field */
+ tlv_ptr = lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 3);
+ *tlv_ptr = IS_NEIGHBOURS; /* Type */
+ *(tlv_ptr + 1) = 1; /* this is the virtual char len */
+ *(tlv_ptr + 2) = 0; /* virtual is zero */
+ }
+ /* doing this here assures us that we won't add an "empty" tlv */
+ /* assign space for the is_neigh at the pdu end */
+ is_neigh = (struct is_neigh *) lsppdu_realloc (lsp, MTYPE_ISIS_TLV,
+ sizeof (struct
+ is_neigh));
+ /* add this node to our list */
+ listnode_add (lsp->tlv_data.is_neighs, is_neigh);
+ memcpy (&is_neigh->neigh_id, area->topology_baseis, ISIS_SYS_ID_LEN);
+ LSP_PSEUDO_ID (is_neigh->neigh_id) = 0x00;
+ is_neigh->neigh_id[ISIS_SYS_ID_LEN - 1] = (to_lsp & 0xFF);
+ is_neigh->neigh_id[ISIS_SYS_ID_LEN - 2] = ((to_lsp >> 8) & 0xFF);
+ is_neigh->metrics.metric_default = arc->distance;
+ is_neigh->metrics.metric_delay = METRICS_UNSUPPORTED;
+ is_neigh->metrics.metric_expense = METRICS_UNSUPPORTED;
+ is_neigh->metrics.metric_error = METRICS_UNSUPPORTED;
+ /* don't forget the length */
+ *(tlv_ptr + 1) += IS_NEIGHBOURS_LEN; /* the -1 is the virtual */
+ }
}
+ /* adding dynamic hostname if needed */
+ if (area->dynhostname)
+ {
+ memset (buff, 0x00, 200);
+ sprintf (buff, "feedme%d", lsp_top_num);
+ /* the 2 is for the TL */
+ tlv_ptr = lsppdu_realloc (lsp, MTYPE_ISIS_TLV, 2);
+ *tlv_ptr = DYNAMIC_HOSTNAME; /* Type */
+ *(tlv_ptr + 1) = strlen (buff); /* Length */
+ /* the -1 is to fit the length in the struct */
+ lsp->tlv_data.hostname = (struct hostname *)
+ (lsppdu_realloc (lsp, MTYPE_ISIS_TLV, strlen (buff)) - 1);
+ memcpy (lsp->tlv_data.hostname->name, buff, strlen (buff));
+ }
+
/* thanks to hannes, another bug bites the dust */
- lsp->pdu->putp = ntohs(lsp->lsp_header->pdu_len);
- lsp->pdu->endp = ntohs(lsp->lsp_header->pdu_len);
+ lsp->pdu->putp = ntohs (lsp->lsp_header->pdu_len);
+ lsp->pdu->endp = ntohs (lsp->lsp_header->pdu_len);
}
#endif /* TOPOLOGY_GENERATE */
diff --git a/isisd/isis_lsp.h b/isisd/isis_lsp.h
index 71a75089a..c6eb7c27b 100644
--- a/isisd/isis_lsp.h
+++ b/isisd/isis_lsp.h
@@ -26,7 +26,7 @@
/* 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 flags.h as well*/
+#define ISIS_MAX_CIRCUITS 32 /* = 1024 - FIXME:defined in flags.h as well */
/* Structure for isis_lsp, this structure will only support the fixed
* System ID (Currently 6) (atleast for now). In order to support more
@@ -34,19 +34,20 @@
* sake it should better be avoided */
struct isis_lsp
{
- struct isis_fixed_hdr *isis_header; /* normally equals pdu */
- struct isis_link_state_hdr *lsp_header; /* pdu + isis_header_len */
- struct stream *pdu; /* full pdu lsp */
- union {
+ struct isis_fixed_hdr *isis_header; /* normally equals pdu */
+ struct isis_link_state_hdr *lsp_header; /* pdu + isis_header_len */
+ struct stream *pdu; /* full pdu lsp */
+ union
+ {
struct list *frags;
struct isis_lsp *zero_lsp;
} lspu;
u_int32_t SRMflags[ISIS_MAX_CIRCUITS];
u_int32_t SSNflags[ISIS_MAX_CIRCUITS];
u_int32_t rexmit_queue[ISIS_MAX_CIRCUITS];
- int level; /* L1 or L2? */
- int purged; /* have purged this one */
- int scheduled; /* scheduled for sending */
+ int level; /* L1 or L2? */
+ int purged; /* have purged this one */
+ int scheduled; /* scheduled for sending */
time_t installed;
time_t last_generated;
time_t last_sent;
@@ -56,13 +57,13 @@ struct isis_lsp
struct thread *t_lsp_top_ref;
#endif
/* used for 60 second counting when rem_lifetime is zero */
- int age_out;
+ int age_out;
struct isis_adjacency *adj;
- struct tlvs tlv_data; /* Simplifies TLV access */
+ struct tlvs tlv_data; /* Simplifies TLV access */
};
dict_t *lsp_db_init (void);
-void lsp_db_destroy (dict_t *lspdb);
+void lsp_db_destroy (dict_t * lspdb);
int lsp_tick (struct thread *thread);
int lsp_l1_generate (struct isis_area *area);
@@ -73,31 +74,31 @@ int lsp_regenerate_schedule (struct isis_area *area);
int lsp_l1_pseudo_generate (struct isis_circuit *circuit);
int lsp_l2_pseudo_generate (struct isis_circuit *circuit);
-int lsp_l1_refresh_pseudo (struct thread *thread);
-int lsp_l2_refresh_pseudo (struct thread *thread);
+int lsp_l1_refresh_pseudo (struct thread *thread);
+int lsp_l2_refresh_pseudo (struct thread *thread);
int isis_lsp_authinfo_check (struct stream *stream, struct isis_area *area,
- int pdulen, struct isis_passwd *passwd);
-struct isis_lsp *lsp_new (u_char *lsp_id, u_int16_t rem_lifetime,
- u_int32_t seq_num, u_int8_t lsp_bits,
- u_int16_t checksum, int level);
-struct isis_lsp *lsp_new_from_stream_ptr (struct stream *stream,
- u_int16_t pdu_len,
- struct isis_lsp *lsp0,
- struct isis_area *area);
-void lsp_insert (struct isis_lsp *lsp, dict_t *lspdb);
-struct isis_lsp *lsp_search (u_char *id, dict_t *lspdb);
+ int pdulen, struct isis_passwd *passwd);
+struct isis_lsp *lsp_new (u_char * lsp_id, u_int16_t rem_lifetime,
+ u_int32_t seq_num, u_int8_t lsp_bits,
+ u_int16_t checksum, int level);
+struct isis_lsp *lsp_new_from_stream_ptr (struct stream *stream,
+ u_int16_t pdu_len,
+ struct isis_lsp *lsp0,
+ struct isis_area *area);
+void lsp_insert (struct isis_lsp *lsp, dict_t * lspdb);
+struct isis_lsp *lsp_search (u_char * id, dict_t * lspdb);
-void lsp_build_list (u_char *start_id, u_char *stop_id,
- struct list *list, dict_t *lspdb);
-void lsp_build_list_nonzero_ht (u_char *start_id, u_char *stop_id,
- struct list *list, dict_t *lspdb);
-void lsp_build_list_ssn (struct isis_circuit *circuit, struct list *list,
- dict_t *lspdb);
+void lsp_build_list (u_char * start_id, u_char * stop_id,
+ struct list *list, dict_t * lspdb);
+void lsp_build_list_nonzero_ht (u_char * start_id, u_char * stop_id,
+ struct list *list, dict_t * lspdb);
+void lsp_build_list_ssn (struct isis_circuit *circuit, struct list *list,
+ dict_t * lspdb);
-void lsp_search_and_destroy (u_char *id, dict_t *lspdb);
-void lsp_purge_dr (u_char *id, struct isis_circuit *circuit, int level);
-void lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
- struct isis_area *area);
+void lsp_search_and_destroy (u_char * id, dict_t * lspdb);
+void lsp_purge_dr (u_char * id, struct isis_circuit *circuit, int level);
+void lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
+ struct isis_area *area);
#define LSP_EQUAL 1
#define LSP_NEWER 2
@@ -109,24 +110,24 @@ void lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
memcpy ((I), isis->sysid, ISIS_SYS_ID_LEN);\
(I)[ISIS_SYS_ID_LEN] = 0;\
(I)[ISIS_SYS_ID_LEN + 1] = 0
-int lsp_id_cmp (u_char *id1, u_char *id2);
-int lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num,
- u_int16_t checksum, u_int16_t rem_lifetime);
+int lsp_id_cmp (u_char * id1, u_char * id2);
+int lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num,
+ u_int16_t checksum, u_int16_t rem_lifetime);
void lsp_update (struct isis_lsp *lsp, struct isis_link_state_hdr *lsp_hdr,
- struct stream *stream, struct isis_area *area);
+ struct stream *stream, struct isis_area *area);
void lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num);
-int lsp_print_all (struct vty *vty, dict_t *lspdb, char detail, char dynhost);
+int lsp_print_all (struct vty *vty, dict_t * lspdb, char detail,
+ char dynhost);
char *lsp_bits2string (u_char *);
/* staticly assigned vars for printing purposes */
-char lsp_bits_string[200]; /* FIXME: enough ? */
+char lsp_bits_string[200]; /* FIXME: enough ? */
#ifdef TOPOLOGY_GENERATE
void generate_topology_lsps (struct isis_area *area);
void remove_topology_lsps (struct isis_area *area);
void build_topology_lsp_data (struct isis_lsp *lsp,
- struct isis_area *area, int lsp_top_num);
+ struct isis_area *area, int lsp_top_num);
#endif /* TOPOLOGY_GENERATE */
#endif /* ISIS_LSP */
-
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index a2a7e51a9..d9bdd4766 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -50,14 +50,12 @@
#define ISISD_VTY_PORT 2608
/* isisd privileges */
-zebra_capabilities_t _caps_p [] =
-{
+zebra_capabilities_t _caps_p[] = {
ZCAP_RAW,
ZCAP_BIND
};
-struct zebra_privs_t isisd_privs =
-{
+struct zebra_privs_t isisd_privs = {
#if defined(QUAGGA_USER)
.user = QUAGGA_USER,
#endif
@@ -73,17 +71,16 @@ struct zebra_privs_t isisd_privs =
};
/* isisd options */
-struct option longopts[] =
-{
- { "daemon", no_argument, NULL, 'd'},
- { "config_file", required_argument, NULL, 'f'},
- { "pid_file", required_argument, NULL, 'i'},
- { "vty_addr", required_argument, NULL, 'A'},
- { "vty_port", required_argument, NULL, 'P'},
- { "user", required_argument, NULL, 'u'},
- { "version", no_argument, NULL, 'v'},
- { "help", no_argument, NULL, 'h'},
- { 0 }
+struct option longopts[] = {
+ {"daemon", no_argument, NULL, 'd'},
+ {"config_file", required_argument, NULL, 'f'},
+ {"pid_file", required_argument, NULL, 'i'},
+ {"vty_addr", required_argument, NULL, 'A'},
+ {"vty_port", required_argument, NULL, 'P'},
+ {"user", required_argument, NULL, 'u'},
+ {"version", no_argument, NULL, 'v'},
+ {"help", no_argument, NULL, 'h'},
+ {0}
};
/* Configuration file and directory. */
@@ -108,7 +105,6 @@ int _argc;
char **_argv;
char **_envp;
-
/* Help information display. */
static void
usage (int status)
@@ -116,7 +112,7 @@ usage (int status)
if (status != 0)
fprintf (stderr, "Try `%s --help' for more information.\n", progname);
else
- {
+ {
printf ("Usage : %s [OPTION...]\n\n\
Daemon which manages IS-IS routing\n\n\
-d, --daemon Runs in daemon mode\n\
@@ -154,7 +150,7 @@ terminate (int i)
* Signal handlers
*/
-void
+void
sighup (void)
{
zlog_info ("SIGHUP received");
@@ -168,7 +164,7 @@ sigint (void)
{
zlog_info ("SIGINT received");
terminate (0);
-
+
return;
}
@@ -187,29 +183,29 @@ sigusr1 (void)
}
struct quagga_signal_t isisd_signals[] =
-{
- {
- .signal = SIGHUP,
- .handler = &sighup,
- },
+{
+ {
+ .signal = SIGHUP,
+ .handler = &sighup,
+ },
{
- .signal = SIGUSR1,
- .handler = &sigusr1,
- },
+ .signal = SIGUSR1,
+ .handler = &sigusr1,
+ },
{
- .signal = SIGINT,
- .handler = &sigint,
- },
+ .signal = SIGINT,
+ .handler = &sigint,
+ },
{
- .signal = SIGTERM,
- .handler = &sigterm,
- },
+ .signal = SIGTERM,
+ .handler = &sigterm,
+ },
};
/*
* Main routine of isisd. Parse arguments and handle IS-IS state machine.
*/
-int
+int
main (int argc, char **argv, char **envp)
{
char *p;
@@ -222,9 +218,8 @@ main (int argc, char **argv, char **envp)
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_ISIS,
- LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
+ LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
-
/* for reload */
_argc = argc;
_argv = argv;
@@ -234,73 +229,73 @@ main (int argc, char **argv, char **envp)
snprintf (_progpath, sizeof (_progpath), "%s/%s", _cwd, _argv[0]);
else
snprintf (_progpath, sizeof (_progpath), "%s", argv[0]);
-
+
/* Command line argument treatment. */
- while (1)
+ while (1)
{
opt = getopt_long (argc, argv, "df:i:hA:p:P:u:v", longopts, 0);
-
+
if (opt == EOF)
- break;
-
- switch (opt)
- {
- case 0:
- break;
- case 'd':
- daemon_mode = 1;
- break;
- case 'f':
- config_file = optarg;
- break;
- case 'i':
- pid_file = optarg;
- break;
- case 'A':
- vty_addr = optarg;
- break;
- case 'P':
- /* Deal with atoi() returning 0 on failure, and isisd not
- listening on isisd port... */
- if (strcmp(optarg, "0") == 0)
- {
- vty_port = 0;
- break;
- }
- vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : ISISD_VTY_PORT);
+ break;
+
+ switch (opt)
+ {
+ case 0:
+ break;
+ case 'd':
+ daemon_mode = 1;
+ break;
+ case 'f':
+ config_file = optarg;
+ break;
+ case 'i':
+ pid_file = optarg;
+ break;
+ case 'A':
+ vty_addr = optarg;
+ break;
+ case 'P':
+ /* Deal with atoi() returning 0 on failure, and isisd not
+ listening on isisd port... */
+ if (strcmp (optarg, "0") == 0)
+ {
+ vty_port = 0;
+ break;
+ }
+ vty_port = atoi (optarg);
+ vty_port = (vty_port ? vty_port : ISISD_VTY_PORT);
break;
- case 'u':
- isisd_privs.user = isisd_privs.group = optarg;
- break;
- break;
- case 'v':
- printf("ISISd version %s\n", ISISD_VERSION);
- printf("Copyright (c) 2001-2002 Sampo Saaristo,"
- " Ofer Wald and Hannes Gredler\n");
- print_version ("Zebra");
- exit (0);
- break;
- case 'h':
- usage (0);
- break;
- default:
- usage (1);
- break;
- }
+ case 'u':
+ isisd_privs.user = isisd_privs.group = optarg;
+ break;
+ break;
+ case 'v':
+ printf ("ISISd version %s\n", ISISD_VERSION);
+ printf ("Copyright (c) 2001-2002 Sampo Saaristo,"
+ " Ofer Wald and Hannes Gredler\n");
+ print_version ("Zebra");
+ exit (0);
+ break;
+ case 'h':
+ usage (0);
+ break;
+ default:
+ usage (1);
+ break;
+ }
}
-
+
/* thread master */
master = thread_master_create ();
/* random seed from time */
- srand(time(NULL));
+ srand (time (NULL));
/*
* initializations
*/
zprivs_init (&isisd_privs);
- signal_init (master, Q_SIGC(isisd_signals), isisd_signals);
+ signal_init (master, Q_SIGC (isisd_signals), isisd_signals);
cmd_init (1);
vty_init (master);
memory_init ();
@@ -308,7 +303,7 @@ main (int argc, char **argv, char **envp)
dyn_cache_init ();
sort_node ();
- /* parse config file */
+ /* parse config file */
/* this is needed three times! because we have interfaces before the areas */
vty_read_config (config_file, config_default);
vty_read_config (config_file, config_default);
@@ -323,7 +318,7 @@ main (int argc, char **argv, char **envp)
/* Make isis vty socket. */
vty_serv_sock (vty_addr, vty_port, ISIS_VTYSH_PATH);
-
+
/* Print banner. */
#if defined(ZEBRA_VERSION)
zlog_info ("ISISd %s starting: vty@%d", ZEBRA_VERSION, vty_port);
@@ -340,13 +335,3 @@ main (int argc, char **argv, char **envp)
/* Not reached. */
exit (0);
}
-
-
-
-
-
-
-
-
-
-
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 709dbe4ff..7fe5286f7 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -21,7 +21,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
@@ -50,28 +49,37 @@
/*
* This converts the isonet to its printable format
*/
-char * isonet_print (u_char *from, int len) {
+char *
+isonet_print (u_char * from, int len)
+{
int i = 0;
char *pos = isonet;
- if(!from)
+ if (!from)
return "unknown";
- while (i < len) {
- if (i & 1) {
- sprintf ( pos, "%02x", *(from + i));
- pos += 2;
- } else {
- if (i == (len - 1)) { /* No dot at the end of address */
- sprintf ( pos, "%02x", *(from + i));
- pos += 2;
- } else {
- sprintf ( pos, "%02x.", *(from + i));
- pos += 3;
- }
+ while (i < len)
+ {
+ if (i & 1)
+ {
+ sprintf (pos, "%02x", *(from + i));
+ pos += 2;
+ }
+ else
+ {
+ if (i == (len - 1))
+ { /* No dot at the end of address */
+ sprintf (pos, "%02x", *(from + i));
+ pos += 2;
+ }
+ else
+ {
+ sprintf (pos, "%02x.", *(from + i));
+ pos += 3;
+ }
+ }
+ i++;
}
- i++;
- }
*(pos) = '\0';
return isonet;
}
@@ -81,7 +89,7 @@ char * 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, u_char * dotted)
{
int dotlen, len = 0;
u_char *pos = dotted;
@@ -89,80 +97,96 @@ dotformat2buff (u_char *buff, u_char *dotted)
int nextdotpos = 2;
number[2] = '\0';
- dotlen = strlen(dotted);
- if (dotlen > 50) {
- /* this can't be an iso net, its too long */
- return 0;
- }
-
- while ( (pos - dotted) < dotlen && len < 20 ) {
- if (*pos == '.') {
- /* we expect the . at 2, and than every 5 */
- if ((pos - dotted) != nextdotpos) {
- len = 0;
- break;
- }
- nextdotpos += 5;
- pos++;
- continue;
- }
- /* we must have at least two chars left here */
- if (dotlen - (pos - dotted) < 2) {
- len = 0;
- break;
+ dotlen = strlen (dotted);
+ if (dotlen > 50)
+ {
+ /* this can't be an iso net, its too long */
+ return 0;
}
- if ((isxdigit((int)*pos)) && (isxdigit((int)*(pos+1)))){
- memcpy (number, pos ,2);
- pos+=2;
- } else {
- len = 0;
- break;
+ while ((pos - dotted) < dotlen && len < 20)
+ {
+ if (*pos == '.')
+ {
+ /* we expect the . at 2, and than every 5 */
+ if ((pos - dotted) != nextdotpos)
+ {
+ len = 0;
+ break;
+ }
+ nextdotpos += 5;
+ pos++;
+ continue;
+ }
+ /* we must have at least two chars left here */
+ if (dotlen - (pos - dotted) < 2)
+ {
+ len = 0;
+ break;
+ }
+
+ if ((isxdigit ((int) *pos)) && (isxdigit ((int) *(pos + 1))))
+ {
+ memcpy (number, pos, 2);
+ pos += 2;
+ }
+ else
+ {
+ len = 0;
+ break;
+ }
+
+ *(buff + len) = (char) strtol (number, NULL, 16);
+ len++;
}
- *(buff + len) = (char)strtol(number, NULL, 16);
- len++;
- }
-
return len;
}
+
/*
* conversion of XXXX.XXXX.XXXX to memory
*/
int
-sysid2buff (u_char *buff, u_char *dotted)
- {
+sysid2buff (u_char * buff, u_char * dotted)
+{
int len = 0;
u_char *pos = dotted;
u_char number[3];
number[2] = '\0';
// surely not a sysid_string if not 14 length
- if (strlen(dotted) != 14) {
- return 0;
- }
-
- while ( len < ISIS_SYS_ID_LEN ) {
- if (*pos == '.') {
- /* the . is not positioned correctly */
- if (((pos - dotted) !=4) && ((pos - dotted) != 9)) {
- len = 0;
- break;
- }
- pos++;
- continue;
- }
- if ((isxdigit((int)*pos)) && (isxdigit((int)*(pos+1)))){
- memcpy (number, pos ,2);
- pos+=2;
- } else {
- len = 0;
- break;
+ if (strlen (dotted) != 14)
+ {
+ return 0;
}
- *(buff + len) = (char)strtol(number, NULL, 16);
- len++;
- }
+ while (len < ISIS_SYS_ID_LEN)
+ {
+ if (*pos == '.')
+ {
+ /* the . is not positioned correctly */
+ if (((pos - dotted) != 4) && ((pos - dotted) != 9))
+ {
+ len = 0;
+ break;
+ }
+ pos++;
+ continue;
+ }
+ if ((isxdigit ((int) *pos)) && (isxdigit ((int) *(pos + 1))))
+ {
+ memcpy (number, pos, 2);
+ pos += 2;
+ }
+ else
+ {
+ len = 0;
+ break;
+ }
+
+ *(buff + len) = (char) strtol (number, NULL, 16);
+ len++;
+ }
return len;
@@ -174,79 +198,82 @@ sysid2buff (u_char *buff, u_char *dotted)
*/
char *
-nlpid2string (struct nlpids *nlpids) {
+nlpid2string (struct nlpids *nlpids)
+{
char *pos = nlpidstring;
int i;
- for (i=0;i<nlpids->count;i++) {
- switch (nlpids->nlpids[i]) {
- case NLPID_IP:
- pos += sprintf (pos, "IPv4");
- break;
- case NLPID_IPV6:
- pos += sprintf (pos, "IPv6");
- break;
- case NLPID_SNAP:
- pos += sprintf (pos, "SNAP");
- break;
- case NLPID_CLNP:
- pos += sprintf (pos, "CLNP");
- break;
- case NLPID_ESIS:
- pos += sprintf (pos, "ES-IS");
- break;
- default:
- pos += sprintf (pos, "unknown");
- break;
+ for (i = 0; i < nlpids->count; i++)
+ {
+ switch (nlpids->nlpids[i])
+ {
+ case NLPID_IP:
+ pos += sprintf (pos, "IPv4");
+ break;
+ case NLPID_IPV6:
+ pos += sprintf (pos, "IPv6");
+ break;
+ case NLPID_SNAP:
+ pos += sprintf (pos, "SNAP");
+ break;
+ case NLPID_CLNP:
+ pos += sprintf (pos, "CLNP");
+ break;
+ case NLPID_ESIS:
+ pos += sprintf (pos, "ES-IS");
+ break;
+ default:
+ pos += sprintf (pos, "unknown");
+ break;
+ }
+ if (nlpids->count - i > 1)
+ pos += sprintf (pos, ", ");
+
}
- if (nlpids->count-i>1)
- pos += sprintf (pos, ", ");
-
- }
*(pos) = '\0';
-
+
return nlpidstring;
}
/*
* supports the given af ?
*/
-int
+int
speaks (struct nlpids *nlpids, int family)
{
int i, speaks = 0;
-
- if (nlpids == (struct nlpids*)NULL)
+
+ if (nlpids == (struct nlpids *) NULL)
return speaks;
- for (i = 0;i < nlpids->count; i++) {
- if (family == AF_INET && nlpids->nlpids[i] == NLPID_IP)
- speaks = 1;
- if (family == AF_INET6 && nlpids->nlpids[i] == NLPID_IPV6)
- speaks = 1;
- }
+ for (i = 0; i < nlpids->count; i++)
+ {
+ if (family == AF_INET && nlpids->nlpids[i] == NLPID_IP)
+ speaks = 1;
+ if (family == AF_INET6 && nlpids->nlpids[i] == NLPID_IPV6)
+ speaks = 1;
+ }
return speaks;
}
-
/*
* Returns 0 on error, IS-IS Circuit Type on ok
*/
-int
-string2circuit_t (u_char *str)
+int
+string2circuit_t (u_char * str)
{
-
+
if (!str)
return 0;
-
- if (!strcmp(str,"level-1"))
+
+ if (!strcmp (str, "level-1"))
return IS_LEVEL_1;
- if (!strcmp(str,"level-2-only") || !strcmp(str,"level-2"))
+ if (!strcmp (str, "level-2-only") || !strcmp (str, "level-2"))
return IS_LEVEL_2;
-
- if (!strcmp(str,"level-1-2"))
+
+ if (!strcmp (str, "level-1-2"))
return IS_LEVEL_1_AND_2;
return 0;
@@ -255,62 +282,68 @@ string2circuit_t (u_char *str)
const char *
circuit_t2string (int circuit_t)
{
- switch (circuit_t) {
- case IS_LEVEL_1:
- return "L1";
- case IS_LEVEL_2:
- return "L2";
- case IS_LEVEL_1_AND_2:
- return "L1L2";
- default:
- return "??";
- }
-
- return NULL; /* not reached */
+ switch (circuit_t)
+ {
+ case IS_LEVEL_1:
+ return "L1";
+ case IS_LEVEL_2:
+ return "L2";
+ case IS_LEVEL_1_AND_2:
+ return "L1L2";
+ default:
+ return "??";
+ }
+
+ return NULL; /* not reached */
}
const char *
syst2string (int type)
{
- switch (type) {
- case ISIS_SYSTYPE_ES:
- return "ES";
- case ISIS_SYSTYPE_IS:
- return "IS";
- case ISIS_SYSTYPE_L1_IS:
- return "1";
- case ISIS_SYSTYPE_L2_IS:
- return "2";
- default:
- return "??";
- }
-
- return NULL; /* not reached */
+ switch (type)
+ {
+ case ISIS_SYSTYPE_ES:
+ return "ES";
+ case ISIS_SYSTYPE_IS:
+ return "IS";
+ case ISIS_SYSTYPE_L1_IS:
+ return "1";
+ case ISIS_SYSTYPE_L2_IS:
+ return "2";
+ default:
+ return "??";
+ }
+
+ return NULL; /* not reached */
}
/*
* Print functions - we print to static vars
*/
char *
-snpa_print (u_char *from)
+snpa_print (u_char * from)
{
int i = 0;
u_char *pos = snpa;
- if(!from)
+ if (!from)
return "unknown";
-
- while (i < ETH_ALEN - 1) {
- if (i & 1) {
- sprintf ( pos, "%02x.", *(from + i));
- pos += 3;
- } else {
- sprintf ( pos, "%02x", *(from + i));
- pos += 2;
+ while (i < ETH_ALEN - 1)
+ {
+ if (i & 1)
+ {
+ sprintf (pos, "%02x.", *(from + i));
+ pos += 3;
+ }
+ else
+ {
+ sprintf (pos, "%02x", *(from + i));
+ pos += 2;
+
+ }
+ i++;
}
- i++;
- }
sprintf (pos, "%02x", *(from + (ISIS_SYS_ID_LEN - 1)));
pos += 2;
@@ -320,44 +353,48 @@ snpa_print (u_char *from)
}
char *
-sysid_print (u_char *from)
+sysid_print (u_char * from)
{
int i = 0;
char *pos = sysid;
- if(!from)
+ if (!from)
return "unknown";
- while (i < ISIS_SYS_ID_LEN - 1) {
- if (i & 1) {
- sprintf ( pos, "%02x.", *(from + i));
- pos += 3;
- } else {
- sprintf ( pos, "%02x", *(from + i));
- pos += 2;
-
- }
- i++;
- }
+ while (i < ISIS_SYS_ID_LEN - 1)
+ {
+ if (i & 1)
+ {
+ sprintf (pos, "%02x.", *(from + i));
+ pos += 3;
+ }
+ else
+ {
+ sprintf (pos, "%02x", *(from + i));
+ pos += 2;
+
+ }
+ i++;
+ }
sprintf (pos, "%02x", *(from + (ISIS_SYS_ID_LEN - 1)));
pos += 2;
*(pos) = '\0';
-
+
return sysid;
}
char *
-rawlspid_print (u_char *from)
+rawlspid_print (u_char * from)
{
char *pos = lspid;
- if(!from)
+ if (!from)
return "unknown";
- memcpy(pos, sysid_print(from), 15);
+ memcpy (pos, sysid_print (from), 15);
pos += 14;
- sprintf (pos, ".%02x", LSP_PSEUDO_ID(from));
+ sprintf (pos, ".%02x", LSP_PSEUDO_ID (from));
pos += 3;
- sprintf (pos, "-%02x", LSP_FRAGMENT(from));
+ sprintf (pos, "-%02x", LSP_FRAGMENT (from));
pos += 3;
*(pos) = '\0';
@@ -366,34 +403,35 @@ rawlspid_print (u_char *from)
}
char *
-time2string (u_int32_t time) {
- char *pos = datestring;
+time2string (u_int32_t time)
+{
+ char *pos = datestring;
u_int32_t rest;
- if (time==0)
+ if (time == 0)
return "-";
- if(time/SECS_PER_YEAR)
- pos += sprintf (pos, "%uY",time/SECS_PER_YEAR);
- rest=time%SECS_PER_YEAR;
- if(rest/SECS_PER_MONTH)
- pos += sprintf (pos, "%uM",rest/SECS_PER_MONTH);
- rest=rest%SECS_PER_MONTH;
- if(rest/SECS_PER_WEEK)
- pos += sprintf (pos, "%uw",rest/SECS_PER_WEEK);
- rest=rest%SECS_PER_WEEK;
- if(rest/SECS_PER_DAY)
- pos += sprintf (pos, "%ud",rest/SECS_PER_DAY);
- rest=rest%SECS_PER_DAY;
- if(rest/SECS_PER_HOUR)
- pos += sprintf (pos, "%uh",rest/SECS_PER_HOUR);
- rest=rest%SECS_PER_HOUR;
- if(rest/SECS_PER_MINUTE)
- pos += sprintf (pos, "%um",rest/SECS_PER_MINUTE);
- rest=rest%SECS_PER_MINUTE;
- if(rest)
- pos += sprintf (pos, "%us",rest);
-
+ if (time / SECS_PER_YEAR)
+ pos += sprintf (pos, "%uY", time / SECS_PER_YEAR);
+ rest = time % SECS_PER_YEAR;
+ if (rest / SECS_PER_MONTH)
+ pos += sprintf (pos, "%uM", rest / SECS_PER_MONTH);
+ rest = rest % SECS_PER_MONTH;
+ if (rest / SECS_PER_WEEK)
+ pos += sprintf (pos, "%uw", rest / SECS_PER_WEEK);
+ rest = rest % SECS_PER_WEEK;
+ if (rest / SECS_PER_DAY)
+ pos += sprintf (pos, "%ud", rest / SECS_PER_DAY);
+ rest = rest % SECS_PER_DAY;
+ if (rest / SECS_PER_HOUR)
+ pos += sprintf (pos, "%uh", rest / SECS_PER_HOUR);
+ rest = rest % SECS_PER_HOUR;
+ if (rest / SECS_PER_MINUTE)
+ pos += sprintf (pos, "%um", rest / SECS_PER_MINUTE);
+ rest = rest % SECS_PER_MINUTE;
+ if (rest)
+ pos += sprintf (pos, "%us", rest);
+
*(pos) = 0;
return datestring;
@@ -406,12 +444,12 @@ time2string (u_int32_t time) {
* first argument is the timer and the second is
* the jitter
*/
-unsigned long
+unsigned long
isis_jitter (unsigned long timer, unsigned long jitter)
{
- int j,k;
+ int j, k;
- if (jitter>=100)
+ if (jitter >= 100)
return timer;
if (timer == 1)
@@ -423,9 +461,9 @@ isis_jitter (unsigned long timer, unsigned long jitter)
* most IS-IS timers are no longer than 16 bit
*/
- j = 1 + (int) ((RANDOM_SPREAD * rand()) / (RAND_MAX + 1.0 ));
+ j = 1 + (int) ((RANDOM_SPREAD * rand ()) / (RAND_MAX + 1.0));
- k = timer - (timer * (100 - jitter))/100;
+ k = timer - (timer * (100 - jitter)) / 100;
timer = timer - (k * j / RANDOM_SPREAD);
@@ -433,11 +471,11 @@ isis_jitter (unsigned long timer, unsigned long jitter)
}
struct in_addr
-newprefix2inaddr (u_char *prefix_start, u_char prefix_masklen)
+newprefix2inaddr (u_char * prefix_start, u_char prefix_masklen)
{
- memset(&new_prefix, 0, sizeof (new_prefix));
- memcpy(&new_prefix, prefix_start, (prefix_masklen & 0x3F) ?
- ((((prefix_masklen & 0x3F)-1)>>3)+1) : 0);
+ memset (&new_prefix, 0, sizeof (new_prefix));
+ memcpy (&new_prefix, prefix_start, (prefix_masklen & 0x3F) ?
+ ((((prefix_masklen & 0x3F) - 1) >> 3) + 1) : 0);
return new_prefix;
}
@@ -446,17 +484,18 @@ newprefix2inaddr (u_char *prefix_start, u_char prefix_masklen)
* it returns the system hostname.
*/
const char *
-unix_hostname(void)
+unix_hostname (void)
{
static struct utsname names;
const char *hostname;
extern struct host host;
hostname = host.name;
- if (!hostname) {
- uname(&names);
- hostname = names.nodename;
- }
+ if (!hostname)
+ {
+ uname (&names);
+ hostname = names.nodename;
+ }
return hostname;
}
diff --git a/isisd/isis_misc.h b/isisd/isis_misc.h
index ca0c0ae3b..75c8d8b48 100644
--- a/isisd/isis_misc.h
+++ b/isisd/isis_misc.h
@@ -28,7 +28,8 @@ int dotformat2buff (u_char *, u_char *);
int string2circuit_t (u_char *);
const char *circuit_t2string (int);
const char *syst2string (int);
-struct in_addr newprefix2inaddr (u_char *prefix_start, u_char prefix_masklen);
+struct in_addr newprefix2inaddr (u_char * prefix_start,
+ u_char prefix_masklen);
/*
* Converting input to memory stored format
* return value of 0 indicates wrong input
@@ -41,41 +42,38 @@ int sysid2buff (u_char *, u_char *);
*/
char *isonet_print (u_char *, int len);
char *sysid_print (u_char *);
-char *snpa_print (u_char *);
+char *snpa_print (u_char *);
char *rawlspid_print (u_char *);
char *time2string (u_int32_t);
/* typedef struct nlpids nlpids; */
char *nlpid2string (struct nlpids *);
-
/*
* misc functions
*/
-int speaks (struct nlpids *nlpids, int family);
+int speaks (struct nlpids *nlpids, int family);
unsigned long isis_jitter (unsigned long timer, unsigned long jitter);
-const char * unix_hostname(void);
-
+const char *unix_hostname (void);
/*
* macros
*/
#define GETSYSID(A,L) (A->area_addr + (A->addr_len - (L + 1)))
-
/* staticly assigned vars for printing purposes */
-struct in_addr new_prefix;
+struct in_addr new_prefix;
/* len of xxxx.xxxx.xxxx + place for #0 termination */
-char sysid[15];
+char sysid[15];
/* len of xxxx.xxxx.xxxx + place for #0 termination */
-char snpa[15];
+char snpa[15];
/* len of xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx */
-char isonet[51];
+char isonet[51];
/* + place for #0 termination */
/* len of xxxx.xxxx.xxxx.xx.xx + place for #0 termination */
-char lspid[21];
+char lspid[21];
/* len of xxYxxMxWxdxxhxxmxxs + place for #0 termination */
-char datestring[20];
-char nlpidstring[30];
+char datestring[20];
+char nlpidstring[30];
/* used for calculating nice string representation instead of plain seconds */
@@ -86,11 +84,11 @@ char nlpidstring[30];
#define SECS_PER_MONTH 2628000
#define SECS_PER_YEAR 31536000
-enum {
+enum
+{
ISIS_UI_LEVEL_BRIEF,
ISIS_UI_LEVEL_DETAIL,
ISIS_UI_LEVEL_EXTENSIVE,
};
-
-#endif
+#endif
diff --git a/isisd/isis_network.c b/isisd/isis_network.c
index 4f9af61ef..080863bda 100644
--- a/isisd/isis_network.c
+++ b/isisd/isis_network.c
@@ -25,18 +25,16 @@
#include <errno.h>
#include <zebra.h>
#ifdef GNU_LINUX
-#include <net/ethernet.h> /* the L2 protocols */
+#include <net/ethernet.h> /* the L2 protocols */
#else
#include <net/if.h>
#include <netinet/if_ether.h>
#endif
-
#include "log.h"
#include "stream.h"
#include "if.h"
-
#include "isisd/dict.h"
#include "isisd/include-netbsd/iso.h"
#include "isisd/isis_constants.h"
@@ -59,19 +57,19 @@ extern struct zebra_privs_t isisd_privs;
*/
#ifdef GNU_LINUX
#include <netpacket/packet.h>
-#else
+#else
#include <sys/time.h>
#include <sys/ioctl.h>
#include <net/bpf.h>
struct bpf_insn llcfilter[] = {
- BPF_STMT(BPF_LD+BPF_B+BPF_ABS, ETHER_HDR_LEN), /* check first byte */
- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ISO_SAP, 0, 5),
- BPF_STMT(BPF_LD+BPF_B+BPF_ABS, ETHER_HDR_LEN+1),
- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, ISO_SAP, 0, 3), /* check second byte */
- BPF_STMT(BPF_LD+BPF_B+BPF_ABS, ETHER_HDR_LEN+2),
- BPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, 0x03, 0, 1), /* check third byte */
- BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
- BPF_STMT(BPF_RET+BPF_K, 0)
+ BPF_STMT (BPF_LD + BPF_B + BPF_ABS, ETHER_HDR_LEN), /* check first byte */
+ BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ISO_SAP, 0, 5),
+ BPF_STMT (BPF_LD + BPF_B + BPF_ABS, ETHER_HDR_LEN + 1),
+ BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, ISO_SAP, 0, 3), /* check second byte */
+ BPF_STMT (BPF_LD + BPF_B + BPF_ABS, ETHER_HDR_LEN + 2),
+ BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, 0x03, 0, 1), /* check third byte */
+ BPF_STMT (BPF_RET + BPF_K, (u_int) - 1),
+ BPF_STMT (BPF_RET + BPF_K, 0)
};
int readblen = 0;
u_char *readbuff = NULL;
@@ -82,10 +80,10 @@ u_char *readbuff = NULL;
* ISO 10589 - 8.4.8
*/
-u_char ALL_L1_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x14};
-u_char ALL_L2_ISS[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x15};
-u_char ALL_ISS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x05};
-u_char ALL_ESS[6] = {0x09, 0x00, 0x2B, 0x00, 0x00, 0x04};
+u_char ALL_L1_ISS[6] = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x14 };
+u_char ALL_L2_ISS[6] = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x15 };
+u_char ALL_ISS[6] = { 0x09, 0x00, 0x2B, 0x00, 0x00, 0x05 };
+u_char ALL_ESS[6] = { 0x09, 0x00, 0x2B, 0x00, 0x00, 0x04 };
#ifdef GNU_LINUX
static char discard_buff[8192];
@@ -102,89 +100,101 @@ isis_multicast_join (int fd, int registerto, int if_num)
{
struct packet_mreq mreq;
- memset(&mreq, 0, sizeof(mreq));
+ memset (&mreq, 0, sizeof (mreq));
mreq.mr_ifindex = if_num;
- if (registerto) {
- mreq.mr_type = PACKET_MR_MULTICAST;
- mreq.mr_alen = ETH_ALEN;
- if (registerto == 1)
- memcpy (&mreq.mr_address, ALL_L1_ISS, ETH_ALEN);
- else if (registerto == 2)
- memcpy (&mreq.mr_address, ALL_L2_ISS, ETH_ALEN);
- else if (registerto == 3)
- memcpy (&mreq.mr_address, ALL_ISS, ETH_ALEN);
- else
- memcpy (&mreq.mr_address, ALL_ESS, ETH_ALEN);
-
- } else {
- mreq.mr_type = PACKET_MR_ALLMULTI;
- }
+ if (registerto)
+ {
+ mreq.mr_type = PACKET_MR_MULTICAST;
+ mreq.mr_alen = ETH_ALEN;
+ if (registerto == 1)
+ memcpy (&mreq.mr_address, ALL_L1_ISS, ETH_ALEN);
+ else if (registerto == 2)
+ memcpy (&mreq.mr_address, ALL_L2_ISS, ETH_ALEN);
+ else if (registerto == 3)
+ memcpy (&mreq.mr_address, ALL_ISS, ETH_ALEN);
+ else
+ memcpy (&mreq.mr_address, ALL_ESS, ETH_ALEN);
+
+ }
+ else
+ {
+ mreq.mr_type = PACKET_MR_ALLMULTI;
+ }
#ifdef EXTREME_DEBUG
zlog_info ("isis_multicast_join(): fd=%d, reg_to=%d, if_num=%d, "
- "address = %02x:%02x:%02x:%02x:%02x:%02x",
- fd, registerto, if_num, mreq.mr_address[0], mreq.mr_address[1],
- mreq.mr_address[2], mreq.mr_address[3],mreq.mr_address[4],
- mreq.mr_address[5]);
+ "address = %02x:%02x:%02x:%02x:%02x:%02x",
+ fd, registerto, if_num, mreq.mr_address[0], mreq.mr_address[1],
+ mreq.mr_address[2], mreq.mr_address[3], mreq.mr_address[4],
+ mreq.mr_address[5]);
#endif /* EXTREME_DEBUG */
- if (setsockopt (fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq,
- sizeof (struct packet_mreq))) {
- zlog_warn ("isis_multicast_join(): setsockopt(): %s", strerror (errno));
- return ISIS_WARNING;
- }
-
+ if (setsockopt (fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq,
+ sizeof (struct packet_mreq)))
+ {
+ zlog_warn ("isis_multicast_join(): setsockopt(): %s", strerror (errno));
+ return ISIS_WARNING;
+ }
+
return ISIS_OK;
}
-int
+int
open_packet_socket (struct isis_circuit *circuit)
{
struct sockaddr_ll s_addr;
int fd, retval = ISIS_OK;
-
+
fd = socket (PF_PACKET, SOCK_DGRAM, htons (ETH_P_ALL));
- if (fd < 0) {
- zlog_warn ("open_packet_socket(): socket() failed %s", strerror (errno));
- return ISIS_WARNING;
- }
+ if (fd < 0)
+ {
+ zlog_warn ("open_packet_socket(): socket() failed %s",
+ strerror (errno));
+ return ISIS_WARNING;
+ }
/*
* Bind to the physical interface
*/
- memset(&s_addr, 0, sizeof (struct sockaddr_ll));
+ memset (&s_addr, 0, sizeof (struct sockaddr_ll));
s_addr.sll_family = AF_PACKET;
s_addr.sll_protocol = htons (ETH_P_ALL);
s_addr.sll_ifindex = circuit->interface->ifindex;
-
- if (bind (fd, (struct sockaddr*) (&s_addr),
- sizeof(struct sockaddr_ll)) < 0) {
- zlog_warn ("open_packet_socket(): bind() failed: %s", strerror(errno));
- return ISIS_WARNING;
- }
-
+
+ if (bind (fd, (struct sockaddr *) (&s_addr),
+ sizeof (struct sockaddr_ll)) < 0)
+ {
+ zlog_warn ("open_packet_socket(): bind() failed: %s", strerror (errno));
+ return ISIS_WARNING;
+ }
+
circuit->fd = fd;
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- /*
- * Join to multicast groups
- * according to
- * 8.4.2 - Broadcast subnetwork IIH PDUs
- * FIXME: is there a case only one will fail??
- */
- if (circuit->circuit_is_type & IS_LEVEL_1) {
- /* joining ALL_L1_ISS */
- retval = isis_multicast_join (circuit->fd, 1,
- circuit->interface->ifindex);
- /* joining ALL_ISS */
- retval = isis_multicast_join (circuit->fd, 3,
- circuit->interface->ifindex);
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ /*
+ * Join to multicast groups
+ * according to
+ * 8.4.2 - Broadcast subnetwork IIH PDUs
+ * FIXME: is there a case only one will fail??
+ */
+ if (circuit->circuit_is_type & IS_LEVEL_1)
+ {
+ /* joining ALL_L1_ISS */
+ retval = isis_multicast_join (circuit->fd, 1,
+ circuit->interface->ifindex);
+ /* joining ALL_ISS */
+ retval = isis_multicast_join (circuit->fd, 3,
+ circuit->interface->ifindex);
+ }
+ if (circuit->circuit_is_type & IS_LEVEL_2)
+ /* joining ALL_L2_ISS */
+ retval = isis_multicast_join (circuit->fd, 2,
+ circuit->interface->ifindex);
+ }
+ else
+ {
+ retval =
+ isis_multicast_join (circuit->fd, 0, circuit->interface->ifindex);
}
- if (circuit->circuit_is_type & IS_LEVEL_2)
- /* joining ALL_L2_ISS */
- retval = isis_multicast_join (circuit->fd, 2,
- circuit->interface->ifindex);
- } else {
- retval = isis_multicast_join (circuit->fd, 0, circuit->interface->ifindex);
- }
return retval;
}
@@ -201,101 +211,110 @@ open_bpf_dev (struct isis_circuit *circuit)
int true = 1, false = 0;
struct timeval timeout;
struct bpf_program bpf_prog;
-
- do {
- (void)snprintf(bpfdev, sizeof(bpfdev), "/dev/bpf%d", i++);
- fd = open(bpfdev, O_RDWR);
- } while (fd < 0 && errno == EBUSY);
-
- if (fd < 0) {
- zlog_warn ("open_bpf_dev(): failed to create bpf socket: %s",
- strerror (errno));
- return ISIS_WARNING;
- }
-
+
+ do
+ {
+ (void) snprintf (bpfdev, sizeof (bpfdev), "/dev/bpf%d", i++);
+ fd = open (bpfdev, O_RDWR);
+ }
+ while (fd < 0 && errno == EBUSY);
+
+ if (fd < 0)
+ {
+ zlog_warn ("open_bpf_dev(): failed to create bpf socket: %s",
+ strerror (errno));
+ return ISIS_WARNING;
+ }
+
zlog_info ("Opened BPF device %s", bpfdev);
- memcpy (ifr.ifr_name, circuit->interface->name, sizeof(ifr.ifr_name));
- if (ioctl (fd, BIOCSETIF, (caddr_t)&ifr) < 0 ) {
- zlog_warn ("open_bpf_dev(): failed to bind to interface: %s",
- strerror (errno));
- return ISIS_WARNING;
- }
+ memcpy (ifr.ifr_name, circuit->interface->name, sizeof (ifr.ifr_name));
+ if (ioctl (fd, BIOCSETIF, (caddr_t) & ifr) < 0)
+ {
+ zlog_warn ("open_bpf_dev(): failed to bind to interface: %s",
+ strerror (errno));
+ return ISIS_WARNING;
+ }
+ if (ioctl (fd, BIOCGBLEN, (caddr_t) & blen) < 0)
+ {
+ zlog_warn ("failed to get BPF buffer len");
+ blen = circuit->interface->mtu;
+ }
- if (ioctl (fd, BIOCGBLEN, (caddr_t)&blen) < 0) {
- zlog_warn ("failed to get BPF buffer len");
- blen = circuit->interface->mtu;
- }
-
readblen = blen;
if (readbuff == NULL)
readbuff = malloc (blen);
-
+
zlog_info ("BPF buffer len = %u", blen);
/* BPF(4): reads return immediately upon packet reception.
* Otherwise, a read will block until either the kernel
* buffer becomes full or a timeout occurs.
*/
- if (ioctl (fd, BIOCIMMEDIATE, (caddr_t)&true) < 0) {
- zlog_warn ("failed to set BPF dev to immediate mode");
- }
+ if (ioctl (fd, BIOCIMMEDIATE, (caddr_t) & true) < 0)
+ {
+ zlog_warn ("failed to set BPF dev to immediate mode");
+ }
#ifdef BIOCSSEESENT
/*
* We want to see only incoming packets
*/
- if (ioctl (fd, BIOCSSEESENT, (caddr_t)&false) < 0) {
- zlog_warn ("failed to set BPF dev to incoming only mode");
- }
+ if (ioctl (fd, BIOCSSEESENT, (caddr_t) & false) < 0)
+ {
+ zlog_warn ("failed to set BPF dev to incoming only mode");
+ }
#endif
/*
* ...but all of them
*/
- if (ioctl (fd, BIOCPROMISC, (caddr_t)&true) < 0) {
- zlog_warn ("failed to set BPF dev to promiscuous mode");
- }
-
+ if (ioctl (fd, BIOCPROMISC, (caddr_t) & true) < 0)
+ {
+ zlog_warn ("failed to set BPF dev to promiscuous mode");
+ }
/*
* If the buffer length is smaller than our mtu, lets try to increase it
*/
- if (blen < circuit->interface->mtu) {
- if (ioctl (fd, BIOCSBLEN, &circuit->interface->mtu) < 0) {
- zlog_warn ("failed to set BPF buffer len (%u to %u)", blen,
- circuit->interface->mtu);
+ if (blen < circuit->interface->mtu)
+ {
+ if (ioctl (fd, BIOCSBLEN, &circuit->interface->mtu) < 0)
+ {
+ zlog_warn ("failed to set BPF buffer len (%u to %u)", blen,
+ circuit->interface->mtu);
+ }
}
- }
/*
* Set a timeout parameter - hope this helps select()
*/
timeout.tv_sec = 600;
timeout.tv_usec = 0;
- if (ioctl (fd, BIOCSRTIMEOUT, (caddr_t)&timeout) < 0) {
- zlog_warn ("failed to set BPF device timeout");
- }
-
+ if (ioctl (fd, BIOCSRTIMEOUT, (caddr_t) & timeout) < 0)
+ {
+ zlog_warn ("failed to set BPF device timeout");
+ }
+
/*
* And set the filter
*/
memset (&bpf_prog, 0, sizeof (struct bpf_program));
bpf_prog.bf_len = 8;
bpf_prog.bf_insns = &(llcfilter[0]);
- if (ioctl (fd, BIOCSETF, (caddr_t)&bpf_prog) < 0) {
- zlog_warn ("open_bpf_dev(): failed to install filter: %s",
- strerror (errno));
- return ISIS_WARNING;
- }
-
+ if (ioctl (fd, BIOCSETF, (caddr_t) & bpf_prog) < 0)
+ {
+ zlog_warn ("open_bpf_dev(): failed to install filter: %s",
+ strerror (errno));
+ return ISIS_WARNING;
+ }
assert (fd > 0);
circuit->fd = fd;
-
+
return ISIS_OK;
}
@@ -309,9 +328,8 @@ isis_sock_init (struct isis_circuit *circuit)
{
int retval = ISIS_OK;
- if ( isisd_privs.change (ZPRIVS_RAISE) )
- zlog_err ("%s: could not raise privs, %s", __func__,
- strerror (errno) );
+ if (isisd_privs.change (ZPRIVS_RAISE))
+ zlog_err ("%s: could not raise privs, %s", __func__, strerror (errno));
#ifdef GNU_LINUX
retval = open_packet_socket (circuit);
@@ -319,46 +337,48 @@ isis_sock_init (struct isis_circuit *circuit)
retval = open_bpf_dev (circuit);
#endif
- if (retval != ISIS_OK) {
- zlog_warn("%s: could not initialize the socket",
- __func__);
- goto end;
- }
-
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- circuit->tx = isis_send_pdu_bcast;
- circuit->rx = isis_recv_pdu_bcast;
- } else if (circuit->circ_type == CIRCUIT_T_P2P) {
- circuit->tx = isis_send_pdu_p2p;
- circuit->rx = isis_recv_pdu_p2p;
- } else {
- zlog_warn ("isis_sock_init(): unknown circuit type");
- retval = ISIS_WARNING;
- goto end;
- }
-
+ if (retval != ISIS_OK)
+ {
+ zlog_warn ("%s: could not initialize the socket", __func__);
+ goto end;
+ }
+
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ circuit->tx = isis_send_pdu_bcast;
+ circuit->rx = isis_recv_pdu_bcast;
+ }
+ else if (circuit->circ_type == CIRCUIT_T_P2P)
+ {
+ circuit->tx = isis_send_pdu_p2p;
+ circuit->rx = isis_recv_pdu_p2p;
+ }
+ else
+ {
+ zlog_warn ("isis_sock_init(): unknown circuit type");
+ retval = ISIS_WARNING;
+ goto end;
+ }
+
end:
- if ( isisd_privs.change (ZPRIVS_LOWER) )
- zlog_err ("%s: could not lower privs, %s", __func__,
- strerror (errno) );
+ if (isisd_privs.change (ZPRIVS_LOWER))
+ zlog_err ("%s: could not lower privs, %s", __func__, strerror (errno));
return retval;
}
-
-static inline int
-llc_check (u_char *llc)
+static inline int
+llc_check (u_char * llc)
{
-
- if(*llc != ISO_SAP || *(llc + 1) != ISO_SAP || *(llc +2) != 3)
+ if (*llc != ISO_SAP || *(llc + 1) != ISO_SAP || *(llc + 2) != 3)
return 0;
-
+
return 1;
}
#ifdef GNU_LINUX
int
-isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char *ssnpa)
+isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
{
int bytesread, addr_len;
struct sockaddr_ll s_addr;
@@ -368,50 +388,51 @@ isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char *ssnpa)
memset (&s_addr, 0, sizeof (struct sockaddr_ll));
- bytesread = recvfrom (circuit->fd, (void *)&llc,
- LLC_LEN, MSG_PEEK,
- (struct sockaddr *)&s_addr, &addr_len);
-
- if (bytesread < 0) {
- zlog_warn ("isis_recv_packet_bcast(): fd %d, recvfrom (): %s",
- circuit->fd, strerror (errno));
- zlog_warn ("circuit is %s", circuit->interface->name);
- zlog_warn ("circuit fd %d", circuit->fd);
- zlog_warn ("bytesread %d", bytesread);
- /* get rid of the packet */
- bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff));
- return ISIS_WARNING;
- }
+ bytesread = recvfrom (circuit->fd, (void *) &llc,
+ LLC_LEN, MSG_PEEK,
+ (struct sockaddr *) &s_addr, &addr_len);
+
+ if (bytesread < 0)
+ {
+ zlog_warn ("isis_recv_packet_bcast(): fd %d, recvfrom (): %s",
+ circuit->fd, strerror (errno));
+ zlog_warn ("circuit is %s", circuit->interface->name);
+ zlog_warn ("circuit fd %d", circuit->fd);
+ zlog_warn ("bytesread %d", bytesread);
+ /* get rid of the packet */
+ bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff));
+ return ISIS_WARNING;
+ }
/*
* Filtering by llc field, discard packets sent by this host (other circuit)
*/
- if (!llc_check (llc) || s_addr.sll_pkttype == PACKET_OUTGOING) {
- /* Read the packet into discard buff */
- bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff));
- if (bytesread < 0)
- zlog_warn ("isis_recv_pdu_bcast(): read() failed");
- return ISIS_WARNING;
- }
-
+ if (!llc_check (llc) || s_addr.sll_pkttype == PACKET_OUTGOING)
+ {
+ /* Read the packet into discard buff */
+ bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff));
+ if (bytesread < 0)
+ zlog_warn ("isis_recv_pdu_bcast(): read() failed");
+ return ISIS_WARNING;
+ }
+
/* on lan we have to read to the static buff first */
bytesread = recvfrom (circuit->fd, sock_buff, circuit->interface->mtu, 0,
- (struct sockaddr *)&s_addr, &addr_len);
-
+ (struct sockaddr *) &s_addr, &addr_len);
+
/* then we lose the LLC */
- memcpy (STREAM_DATA (circuit->rcv_stream),
- sock_buff + LLC_LEN, bytesread - LLC_LEN);
+ memcpy (STREAM_DATA (circuit->rcv_stream),
+ sock_buff + LLC_LEN, bytesread - LLC_LEN);
circuit->rcv_stream->putp = bytesread - LLC_LEN;
circuit->rcv_stream->endp = bytesread - LLC_LEN;
-
- memcpy (ssnpa, &s_addr.sll_addr, s_addr.sll_halen);
-
+
+ memcpy (ssnpa, &s_addr.sll_addr, s_addr.sll_halen);
+
return ISIS_OK;
}
int
-isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char *ssnpa)
+isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
{
-
int bytesread, addr_len;
struct sockaddr_ll s_addr;
@@ -420,16 +441,17 @@ isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char *ssnpa)
/* we can read directly to the stream */
bytesread = recvfrom (circuit->fd, STREAM_DATA (circuit->rcv_stream),
- circuit->interface->mtu, 0,
- (struct sockaddr *)&s_addr, &addr_len);
-
- if(s_addr.sll_pkttype == PACKET_OUTGOING) {
- /* Read the packet into discard buff */
- bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff));
- if (bytesread < 0)
- zlog_warn ("isis_recv_pdu_p2p(): read() failed");
- return ISIS_WARNING;
- }
+ circuit->interface->mtu, 0,
+ (struct sockaddr *) &s_addr, &addr_len);
+
+ if (s_addr.sll_pkttype == PACKET_OUTGOING)
+ {
+ /* Read the packet into discard buff */
+ bytesread = read (circuit->fd, discard_buff, sizeof (discard_buff));
+ if (bytesread < 0)
+ zlog_warn ("isis_recv_pdu_p2p(): read() failed");
+ return ISIS_WARNING;
+ }
circuit->rcv_stream->putp = bytesread;
circuit->rcv_stream->endp = bytesread;
@@ -437,32 +459,31 @@ isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char *ssnpa)
/* If we don't have protocol type 0x00FE which is
* ISO over GRE we exit with pain :)
*/
- if (ntohs(s_addr.sll_protocol) != 0x00FE) {
- zlog_warn ("isis_recv_pdu_p2p(): protocol mismatch(): %X",
- ntohs(s_addr.sll_protocol));
- return ISIS_WARNING;
- }
-
- memcpy (ssnpa, &s_addr.sll_addr, s_addr.sll_halen);
-
+ if (ntohs (s_addr.sll_protocol) != 0x00FE)
+ {
+ zlog_warn ("isis_recv_pdu_p2p(): protocol mismatch(): %X",
+ ntohs (s_addr.sll_protocol));
+ return ISIS_WARNING;
+ }
+
+ memcpy (ssnpa, &s_addr.sll_addr, s_addr.sll_halen);
+
return ISIS_OK;
}
-
-
-int
+int
isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
{
/* we need to do the LLC in here because of P2P circuits, which will
* not need it
*/
- int written = 1;
+ int written = 1;
struct sockaddr_ll sa;
stream_set_getp (circuit->snd_stream, 0);
memset (&sa, 0, sizeof (struct sockaddr_ll));
sa.sll_family = AF_PACKET;
- sa.sll_protocol = htons (stream_get_endp(circuit->snd_stream)+LLC_LEN);
+ sa.sll_protocol = htons (stream_get_endp (circuit->snd_stream) + LLC_LEN);
sa.sll_ifindex = circuit->interface->ifindex;
sa.sll_halen = ETH_ALEN;
if (level == 1)
@@ -477,29 +498,28 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
sock_buff[2] = 0x03;
/* then we copy the data */
- memcpy (sock_buff + LLC_LEN, circuit->snd_stream->data,
- stream_get_endp (circuit->snd_stream));
+ memcpy (sock_buff + LLC_LEN, circuit->snd_stream->data,
+ stream_get_endp (circuit->snd_stream));
/* now we can send this */
written = sendto (circuit->fd, sock_buff,
- circuit->snd_stream->putp + LLC_LEN, 0,
- (struct sockaddr *)&sa, sizeof (struct sockaddr_ll));
-
+ circuit->snd_stream->putp + LLC_LEN, 0,
+ (struct sockaddr *) &sa, sizeof (struct sockaddr_ll));
return ISIS_OK;
}
-int
+int
isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
{
- int written = 1;
+ int written = 1;
struct sockaddr_ll sa;
stream_set_getp (circuit->snd_stream, 0);
memset (&sa, 0, sizeof (struct sockaddr_ll));
sa.sll_family = AF_PACKET;
- sa.sll_protocol = htons (stream_get_endp(circuit->snd_stream)+LLC_LEN);
+ sa.sll_protocol = htons (stream_get_endp (circuit->snd_stream) + LLC_LEN);
sa.sll_ifindex = circuit->interface->ifindex;
sa.sll_halen = ETH_ALEN;
if (level == 1)
@@ -509,86 +529,87 @@ isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
/* lets try correcting the protocol */
- sa.sll_protocol = htons(0x00FE);
- written = sendto (circuit->fd, circuit->snd_stream->data,
- circuit->snd_stream->putp, 0, (struct sockaddr *)&sa,
- sizeof (struct sockaddr_ll));
-
+ sa.sll_protocol = htons (0x00FE);
+ written = sendto (circuit->fd, circuit->snd_stream->data,
+ circuit->snd_stream->putp, 0, (struct sockaddr *) &sa,
+ sizeof (struct sockaddr_ll));
+
return ISIS_OK;
}
-
#else
int
-isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char *ssnpa)
+isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa)
{
int bytesread = 0, bytestoread, offset, one = 1;
struct bpf_hdr *bpf_hdr;
assert (circuit->fd > 0);
- if (ioctl (circuit->fd, FIONREAD, (caddr_t)&bytestoread) < 0 ) {
- zlog_warn ("ioctl() FIONREAD failed: %s", strerror (errno));
- }
+ if (ioctl (circuit->fd, FIONREAD, (caddr_t) & bytestoread) < 0)
+ {
+ zlog_warn ("ioctl() FIONREAD failed: %s", strerror (errno));
+ }
- if (bytestoread) {
- bytesread = read (circuit->fd, readbuff, readblen);
- }
- if (bytesread < 0) {
- zlog_warn ("isis_recv_pdu_bcast(): read() failed: %s", strerror (errno));
- return ISIS_WARNING;
- }
+ if (bytestoread)
+ {
+ bytesread = read (circuit->fd, readbuff, readblen);
+ }
+ if (bytesread < 0)
+ {
+ zlog_warn ("isis_recv_pdu_bcast(): read() failed: %s",
+ strerror (errno));
+ return ISIS_WARNING;
+ }
if (bytesread == 0)
return ISIS_WARNING;
- bpf_hdr = (struct bpf_hdr*)readbuff;
+ bpf_hdr = (struct bpf_hdr *) readbuff;
assert (bpf_hdr->bh_caplen == bpf_hdr->bh_datalen);
-
+
offset = bpf_hdr->bh_hdrlen + LLC_LEN + ETHER_HDR_LEN;
-
+
/* then we lose the BPF, LLC and ethernet headers */
- memcpy (STREAM_DATA (circuit->rcv_stream),
- readbuff + offset,
- bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN);
+ memcpy (STREAM_DATA (circuit->rcv_stream),
+ readbuff + offset, bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN);
circuit->rcv_stream->putp = bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN;
circuit->rcv_stream->endp = bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN;
circuit->rcv_stream->getp = 0;
- memcpy (ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETHER_ADDR_LEN,
- ETHER_ADDR_LEN);
-
+ memcpy (ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETHER_ADDR_LEN,
+ ETHER_ADDR_LEN);
+
if (ioctl (circuit->fd, BIOCFLUSH, &one) < 0)
zlog_warn ("Flushing failed: %s", strerror (errno));
-
+
return ISIS_OK;
}
int
-isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char *ssnpa)
+isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa)
{
int bytesread;
-
- bytesread = read (circuit->fd, STREAM_DATA(circuit->rcv_stream),
- circuit->interface->mtu);
- if (bytesread < 0) {
- zlog_warn ("isis_recv_pdu_p2p(): read () failed: %s", strerror (errno));
- return ISIS_WARNING;
- }
+ bytesread = read (circuit->fd, STREAM_DATA (circuit->rcv_stream),
+ circuit->interface->mtu);
+
+ if (bytesread < 0)
+ {
+ zlog_warn ("isis_recv_pdu_p2p(): read () failed: %s", strerror (errno));
+ return ISIS_WARNING;
+ }
circuit->rcv_stream->putp = bytesread;
circuit->rcv_stream->endp = bytesread;
-
+
return ISIS_OK;
}
-
-
-int
+int
isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
{
struct ether_header *eth;
@@ -599,7 +620,7 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
/*
* First the eth header
*/
- eth = (struct ether_header *)sock_buff;
+ eth = (struct ether_header *) sock_buff;
if (level == 1)
memcpy (eth->ether_dhost, ALL_L1_ISS, ETHER_ADDR_LEN);
else
@@ -610,36 +631,25 @@ isis_send_pdu_bcast (struct isis_circuit *circuit, int level)
/*
* Then the LLC
*/
- sock_buff[ETHER_HDR_LEN] = ISO_SAP;
- sock_buff[ETHER_HDR_LEN + 1] = ISO_SAP;
- sock_buff[ETHER_HDR_LEN + 2] = 0x03;
+ sock_buff[ETHER_HDR_LEN] = ISO_SAP;
+ sock_buff[ETHER_HDR_LEN + 1] = ISO_SAP;
+ sock_buff[ETHER_HDR_LEN + 2] = 0x03;
/* then we copy the data */
- memcpy (sock_buff + (LLC_LEN + ETHER_HDR_LEN), circuit->snd_stream->data,
- stream_get_endp (circuit->snd_stream));
+ memcpy (sock_buff + (LLC_LEN + ETHER_HDR_LEN), circuit->snd_stream->data,
+ stream_get_endp (circuit->snd_stream));
/* now we can send this */
written = write (circuit->fd, sock_buff,
- circuit->snd_stream->putp + LLC_LEN + ETHER_HDR_LEN);
-
+ circuit->snd_stream->putp + LLC_LEN + ETHER_HDR_LEN);
return ISIS_OK;
}
-int
+int
isis_send_pdu_p2p (struct isis_circuit *circuit, int level)
{
-
-
return ISIS_OK;
}
-
-
-
#endif /* GNU_LINUX */
-
-
-
-
-
diff --git a/isisd/isis_network.h b/isisd/isis_network.h
index 7633f9e01..e1e10dfdb 100644
--- a/isisd/isis_network.h
+++ b/isisd/isis_network.h
@@ -29,8 +29,8 @@ extern u_char ALL_L2_ISYSTEMS[];
int isis_sock_init (struct isis_circuit *circuit);
-int isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char *ssnpa);
-int isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char *ssnpa);
+int isis_recv_pdu_bcast (struct isis_circuit *circuit, u_char * ssnpa);
+int isis_recv_pdu_p2p (struct isis_circuit *circuit, u_char * ssnpa);
int isis_send_pdu_bcast (struct isis_circuit *circuit, int level);
int isis_send_pdu_p2p (struct isis_circuit *circuit, int level);
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index f93025db0..cae346109 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -58,15 +58,14 @@ extern struct thread_master *master;
extern struct isis *isis;
#define ISIS_MINIMUM_FIXED_HDR_LEN 15
-#define ISIS_MIN_PDU_LEN 13 /* partial seqnum pdu with id_len=2 */
+#define ISIS_MIN_PDU_LEN 13 /* partial seqnum pdu with id_len=2 */
#ifndef PNBBY
#define PNBBY 8
#endif /* PNBBY */
/* Utility mask array. */
-static u_char maskbit[] =
-{
+static u_char maskbit[] = {
0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff
};
@@ -77,21 +76,23 @@ static u_char maskbit[] =
/*
* Compares two sets of area addresses
*/
-static int
+static int
area_match (struct list *left, struct list *right)
{
struct area_addr *addr1, *addr2;
struct listnode *node1, *node2;
- LIST_LOOP (left, addr1, node1) {
- LIST_LOOP (right, addr2, node2) {
- if (addr1->addr_len == addr2->addr_len &&
- !memcmp (addr1->area_addr, addr2->area_addr, (int)addr1->addr_len))
- return 1; /* match */
+ LIST_LOOP (left, addr1, node1)
+ {
+ LIST_LOOP (right, addr2, node2)
+ {
+ if (addr1->addr_len == addr2->addr_len &&
+ !memcmp (addr1->area_addr, addr2->area_addr, (int) addr1->addr_len))
+ return 1; /* match */
}
}
- return 0; /* mismatch */
+ return 0; /* mismatch */
}
/*
@@ -102,34 +103,37 @@ area_match (struct list *left, struct list *right)
* 1 the IIH's IP is in the IS's subnetwork
*/
int
-ip_same_subnet (struct prefix_ipv4 *ip1, struct in_addr *ip2)
+ip_same_subnet (struct prefix_ipv4 *ip1, struct in_addr *ip2)
{
u_char *addr1, *addr2;
int shift, offset;
int len;
-
- addr1 = (u_char *) &ip1->prefix.s_addr;
- addr2 = (u_char *) &ip2->s_addr;
+
+ addr1 = (u_char *) & ip1->prefix.s_addr;
+ addr2 = (u_char *) & ip2->s_addr;
len = ip1->prefixlen;
shift = len % PNBBY;
offset = len / PNBBY;
- while (offset--) {
- if (addr1[offset] != addr2[offset]) {
- return 0;
+ while (offset--)
+ {
+ if (addr1[offset] != addr2[offset])
+ {
+ return 0;
+ }
}
- }
- if (shift) {
- if (maskbit[shift] & (addr1[offset] ^ addr2[offset])) {
- return 0;
+ if (shift)
+ {
+ if (maskbit[shift] & (addr1[offset] ^ addr2[offset]))
+ {
+ return 0;
+ }
}
- }
-
- return 1; /* match */
-}
+ return 1; /* match */
+}
/*
* Compares two set of ip addresses
@@ -138,20 +142,23 @@ ip_same_subnet (struct prefix_ipv4 *ip1, struct in_addr *ip2)
* return 0 no match;
* 1 match;
*/
-static int
+static int
ip_match (struct list *left, struct list *right)
{
struct prefix_ipv4 *ip1;
struct in_addr *ip2;
struct listnode *node1, *node2;
- LIST_LOOP (left, ip1, node1) {
- LIST_LOOP (right, ip2, node2) {
- if (ip_same_subnet(ip1, ip2)) {
- return 1; /* match */
- }
+ LIST_LOOP (left, ip1, node1)
+ {
+ LIST_LOOP (right, ip2, node2)
+ {
+ if (ip_same_subnet (ip1, ip2))
+ {
+ return 1; /* match */
+ }
}
-
+
}
return 0;
}
@@ -162,103 +169,111 @@ ip_match (struct list *left, struct list *right)
static int
accept_level (int level, int circuit_t)
{
- int retval = ((circuit_t & level) == level); /* simple approach */
+ int retval = ((circuit_t & level) == level); /* simple approach */
return retval;
}
-int
+int
authentication_check (struct isis_passwd *one, struct isis_passwd *theother)
{
- if (one->type != theother->type) {
- zlog_warn ("Unsupported authentication type %d", theother->type );
- return 1; /* Auth fail (different authentication types)*/
- }
- switch (one->type) {
- case ISIS_PASSWD_TYPE_CLEARTXT:
- if (one->len != theother->len)
- return 1; /* Auth fail () - passwd len mismatch */
- return memcmp (one->passwd, theother->passwd, one->len);
- break;
- default:
- zlog_warn ("Unsupported authentication type");
- break;
- }
- return 0; /* Auth pass */
+ if (one->type != theother->type)
+ {
+ zlog_warn ("Unsupported authentication type %d", theother->type);
+ return 1; /* Auth fail (different authentication types) */
+ }
+ switch (one->type)
+ {
+ case ISIS_PASSWD_TYPE_CLEARTXT:
+ if (one->len != theother->len)
+ return 1; /* Auth fail () - passwd len mismatch */
+ return memcmp (one->passwd, theother->passwd, one->len);
+ break;
+ default:
+ zlog_warn ("Unsupported authentication type");
+ break;
+ }
+ return 0; /* Auth pass */
}
/*
* Processing helper functions
*/
void
-tlvs_to_adj_nlpids (struct tlvs *tlvs, struct isis_adjacency *adj)
+tlvs_to_adj_nlpids (struct tlvs *tlvs, struct isis_adjacency *adj)
{
int i;
struct nlpids *tlv_nlpids;
- if (tlvs->nlpids) {
+ if (tlvs->nlpids)
+ {
- tlv_nlpids = tlvs->nlpids;
+ tlv_nlpids = tlvs->nlpids;
- adj->nlpids.count = tlv_nlpids->count;
+ adj->nlpids.count = tlv_nlpids->count;
- for (i=0;i<tlv_nlpids->count;i++) {
- adj->nlpids.nlpids[i] = tlv_nlpids->nlpids[i];
+ for (i = 0; i < tlv_nlpids->count; i++)
+ {
+ adj->nlpids.nlpids[i] = tlv_nlpids->nlpids[i];
+ }
}
- }
}
-void
+void
del_ip_addr (void *val)
{
XFREE (MTYPE_ISIS_TMP, val);
}
void
-tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
+tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
{
struct listnode *node;
struct in_addr *ipv4_addr, *malloced;
- if (adj->ipv4_addrs) {
- adj->ipv4_addrs->del = del_ip_addr;
- list_delete (adj->ipv4_addrs);
- }
+ if (adj->ipv4_addrs)
+ {
+ adj->ipv4_addrs->del = del_ip_addr;
+ list_delete (adj->ipv4_addrs);
+ }
adj->ipv4_addrs = list_new ();
- if (tlvs->ipv4_addrs) {
- LIST_LOOP (tlvs->ipv4_addrs, ipv4_addr, node) {
- malloced = XMALLOC (MTYPE_ISIS_TMP, sizeof (struct in_addr));
- memcpy (malloced, ipv4_addr, sizeof (struct in_addr));
- listnode_add (adj->ipv4_addrs, malloced);
+ if (tlvs->ipv4_addrs)
+ {
+ LIST_LOOP (tlvs->ipv4_addrs, ipv4_addr, node)
+ {
+ malloced = XMALLOC (MTYPE_ISIS_TMP, sizeof (struct in_addr));
+ memcpy (malloced, ipv4_addr, sizeof (struct in_addr));
+ listnode_add (adj->ipv4_addrs, malloced);
+ }
}
- }
}
#ifdef HAVE_IPV6
void
-tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
+tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
{
struct listnode *node;
struct in6_addr *ipv6_addr, *malloced;
- if (adj->ipv6_addrs) {
- adj->ipv6_addrs->del = del_ip_addr;
- list_delete (adj->ipv6_addrs);
- }
+ if (adj->ipv6_addrs)
+ {
+ adj->ipv6_addrs->del = del_ip_addr;
+ list_delete (adj->ipv6_addrs);
+ }
adj->ipv6_addrs = list_new ();
- if (tlvs->ipv6_addrs) {
- LIST_LOOP (tlvs->ipv6_addrs, ipv6_addr, node) {
- malloced = XMALLOC (MTYPE_ISIS_TMP, sizeof (struct in6_addr));
- memcpy (malloced, ipv6_addr, sizeof (struct in6_addr));
- listnode_add (adj->ipv6_addrs, malloced);
+ if (tlvs->ipv6_addrs)
+ {
+ LIST_LOOP (tlvs->ipv6_addrs, ipv6_addr, node)
+ {
+ malloced = XMALLOC (MTYPE_ISIS_TMP, sizeof (struct in6_addr));
+ memcpy (malloced, ipv6_addr, sizeof (struct in6_addr));
+ listnode_add (adj->ipv6_addrs, malloced);
+ }
}
- }
}
#endif /* HAVE_IPV6 */
-
-
/*
* RECEIVE SIDE
*/
@@ -278,12 +293,12 @@ process_p2p_hello (struct isis_circuit *circuit)
u_int32_t expected = 0, found;
struct tlvs tlvs;
- if ((stream_get_endp (circuit->rcv_stream) -
- stream_get_getp (circuit->rcv_stream)) <
- ISIS_P2PHELLO_HDRLEN) {
- zlog_warn ("Packet too short");
- return ISIS_WARNING;
- }
+ if ((stream_get_endp (circuit->rcv_stream) -
+ stream_get_getp (circuit->rcv_stream)) < ISIS_P2PHELLO_HDRLEN)
+ {
+ zlog_warn ("Packet too short");
+ return ISIS_WARNING;
+ }
/* 8.2.5.1 PDU acceptance tests */
@@ -301,41 +316,43 @@ process_p2p_hello (struct isis_circuit *circuit)
/*
* Get the header
*/
- hdr = (struct isis_p2p_hello_hdr*) STREAM_PNT(circuit->rcv_stream);
+ hdr = (struct isis_p2p_hello_hdr *) STREAM_PNT (circuit->rcv_stream);
circuit->rcv_stream->getp += ISIS_P2PHELLO_HDRLEN;
/* hdr.circuit_t = stream_getc (stream);
- stream_get (hdr.source_id, stream, ISIS_SYS_ID_LEN);
- hdr.hold_time = stream_getw (stream);
- hdr.pdu_len = stream_getw (stream);
- hdr.local_id = stream_getc (stream); */
+ stream_get (hdr.source_id, stream, ISIS_SYS_ID_LEN);
+ hdr.hold_time = stream_getw (stream);
+ hdr.pdu_len = stream_getw (stream);
+ hdr.local_id = stream_getc (stream); */
/*
* My interpertation of the ISO, if no adj exists we will create one for
* the circuit
*/
- if (isis->debugs & DEBUG_ADJ_PACKETS) {
- zlog_info("ISIS-Adj (%s): Rcvd P2P IIH from (%s), cir type %s,"
- " cir id %02d, length %d",
- circuit->area->area_tag, circuit->interface->name,
- circuit_t2string(circuit->circuit_is_type),
- circuit->circuit_id,ntohs(hdr->pdu_len));
- }
+ if (isis->debugs & DEBUG_ADJ_PACKETS)
+ {
+ zlog_info ("ISIS-Adj (%s): Rcvd P2P IIH from (%s), cir type %s,"
+ " cir id %02d, length %d",
+ circuit->area->area_tag, circuit->interface->name,
+ circuit_t2string (circuit->circuit_is_type),
+ circuit->circuit_id, ntohs (hdr->pdu_len));
+ }
adj = circuit->u.p2p.neighbor;
- if ( !adj ) {
- adj = isis_new_adj (hdr->source_id," ", 0, circuit);
- if (adj == NULL)
- return ISIS_ERROR;
- circuit->u.p2p.neighbor = adj;
- isis_adj_state_change(adj, ISIS_ADJ_INITIALIZING, NULL);
- adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
- }
+ if (!adj)
+ {
+ adj = isis_new_adj (hdr->source_id, " ", 0, circuit);
+ if (adj == NULL)
+ return ISIS_ERROR;
+ circuit->u.p2p.neighbor = adj;
+ isis_adj_state_change (adj, ISIS_ADJ_INITIALIZING, NULL);
+ adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
+ }
/* 8.2.6 Monitoring point-to-point adjacencies */
adj->hold_time = ntohs (hdr->hold_time);
- adj->last_upd = time (NULL);
+ adj->last_upd = time (NULL);
/*
* Lets get the TLVS now
@@ -348,214 +365,273 @@ process_p2p_hello (struct isis_circuit *circuit)
retval = parse_tlvs (circuit->area->area_tag,
STREAM_PNT (circuit->rcv_stream),
- ntohs (hdr->pdu_len) - ISIS_P2PHELLO_HDRLEN
- - ISIS_FIXED_HDR_LEN,
- &expected,
- &found,
- &tlvs);
-
- if (retval > ISIS_WARNING) {
- free_tlvs (&tlvs);
- return retval;
- };
+ ntohs (hdr->pdu_len) - ISIS_P2PHELLO_HDRLEN
+ - ISIS_FIXED_HDR_LEN, &expected, &found, &tlvs);
+
+ if (retval > ISIS_WARNING)
+ {
+ free_tlvs (&tlvs);
+ return retval;
+ };
/* 8.2.5.1 c) Authentication */
- if (circuit->passwd.type) {
- if (!(found & TLVFLAG_AUTH_INFO) ||
- authentication_check (&circuit->passwd, &tlvs.auth_info)) {
- isis_event_auth_failure (circuit->area->area_tag,
- "P2P hello authentication failure",
- hdr->source_id);
- return ISIS_OK;
+ if (circuit->passwd.type)
+ {
+ if (!(found & TLVFLAG_AUTH_INFO) ||
+ authentication_check (&circuit->passwd, &tlvs.auth_info))
+ {
+ isis_event_auth_failure (circuit->area->area_tag,
+ "P2P hello authentication failure",
+ hdr->source_id);
+ return ISIS_OK;
+ }
}
- }
/* we do this now because the adj may not survive till the end... */
/* we need to copy addresses to the adj */
- tlvs_to_adj_ipv4_addrs (&tlvs,adj);
+ tlvs_to_adj_ipv4_addrs (&tlvs, adj);
#ifdef HAVE_IPV6
- tlvs_to_adj_ipv6_addrs (&tlvs,adj);
+ tlvs_to_adj_ipv6_addrs (&tlvs, adj);
#endif /* HAVE_IPV6 */
/* lets take care of the expiry */
- THREAD_TIMER_OFF(adj->t_expire);
- THREAD_TIMER_ON(master, adj->t_expire, isis_adj_expire, adj,
- (long)adj->hold_time);
+ THREAD_TIMER_OFF (adj->t_expire);
+ THREAD_TIMER_ON (master, adj->t_expire, isis_adj_expire, adj,
+ (long) adj->hold_time);
/* 8.2.5.2 a) a match was detected */
- if (area_match (circuit->area->area_addrs, tlvs.area_addrs)) {
- /* 8.2.5.2 a) 2) If the system is L1 - table 5 */
- if (circuit->area->is_type == IS_LEVEL_1) {
- switch (hdr->circuit_t) {
- case IS_LEVEL_1:
- case IS_LEVEL_1_AND_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (4) adj state up */
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
- /* (5) adj usage level 1 */
- adj->adj_usage = ISIS_ADJ_LEVEL1;
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
- ; /* accept */
- }
- break;
- case IS_LEVEL_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (7) reject - wrong system type event */
- zlog_warn ("wrongSystemType");
- return ISIS_WARNING; /* Reject */
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
- /* (6) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- }
- break;
- }
- }
+ if (area_match (circuit->area->area_addrs, tlvs.area_addrs))
+ {
+ /* 8.2.5.2 a) 2) If the system is L1 - table 5 */
+ if (circuit->area->is_type == IS_LEVEL_1)
+ {
+ switch (hdr->circuit_t)
+ {
+ case IS_LEVEL_1:
+ case IS_LEVEL_1_AND_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (4) adj state up */
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
+ /* (5) adj usage level 1 */
+ adj->adj_usage = ISIS_ADJ_LEVEL1;
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1)
+ {
+ ; /* accept */
+ }
+ break;
+ case IS_LEVEL_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (7) reject - wrong system type event */
+ zlog_warn ("wrongSystemType");
+ return ISIS_WARNING; /* Reject */
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1)
+ {
+ /* (6) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ break;
+ }
+ }
- /* 8.2.5.2 a) 3) If the system is L1L2 - table 6 */
- if (circuit->area->is_type == IS_LEVEL_1_AND_2) {
- switch (hdr->circuit_t) {
- case IS_LEVEL_1:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (6) adj state up */
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
- /* (7) adj usage level 1 */
- adj->adj_usage = ISIS_ADJ_LEVEL1;
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
- ; /* accept */
- } else if ((adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
- (adj->adj_usage == ISIS_ADJ_LEVEL2)) {
- /* (8) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- }
- break;
- case IS_LEVEL_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (6) adj state up */
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
- /* (9) adj usage level 2 */
- adj->adj_usage = ISIS_ADJ_LEVEL2;
- } else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) ||
- (adj->adj_usage == ISIS_ADJ_LEVEL1AND2)) {
- /* (8) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL2) {
- ; /* Accept */
- }
- break;
- case IS_LEVEL_1_AND_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (6) adj state up */
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
- /* (10) adj usage level 1 */
- adj->adj_usage = ISIS_ADJ_LEVEL1AND2;
- } else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) ||
- (adj->adj_usage == ISIS_ADJ_LEVEL2)) {
- /* (8) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2) {
- ; /* Accept */
- }
- break;
- }
- }
+ /* 8.2.5.2 a) 3) If the system is L1L2 - table 6 */
+ if (circuit->area->is_type == IS_LEVEL_1_AND_2)
+ {
+ switch (hdr->circuit_t)
+ {
+ case IS_LEVEL_1:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (6) adj state up */
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
+ /* (7) adj usage level 1 */
+ adj->adj_usage = ISIS_ADJ_LEVEL1;
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1)
+ {
+ ; /* accept */
+ }
+ else if ((adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
+ (adj->adj_usage == ISIS_ADJ_LEVEL2))
+ {
+ /* (8) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ break;
+ case IS_LEVEL_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (6) adj state up */
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
+ /* (9) adj usage level 2 */
+ adj->adj_usage = ISIS_ADJ_LEVEL2;
+ }
+ else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) ||
+ (adj->adj_usage == ISIS_ADJ_LEVEL1AND2))
+ {
+ /* (8) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL2)
+ {
+ ; /* Accept */
+ }
+ break;
+ case IS_LEVEL_1_AND_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (6) adj state up */
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
+ /* (10) adj usage level 1 */
+ adj->adj_usage = ISIS_ADJ_LEVEL1AND2;
+ }
+ else if ((adj->adj_usage == ISIS_ADJ_LEVEL1) ||
+ (adj->adj_usage == ISIS_ADJ_LEVEL2))
+ {
+ /* (8) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2)
+ {
+ ; /* Accept */
+ }
+ break;
+ }
+ }
- /* 8.2.5.2 a) 4) If the system is L2 - table 7 */
- if (circuit->area->is_type == IS_LEVEL_2) {
- switch (hdr->circuit_t) {
- case IS_LEVEL_1:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (5) reject - wrong system type event */
- zlog_warn ("wrongSystemType");
- return ISIS_WARNING; /* Reject */
- } else if ((adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
- (adj->adj_usage == ISIS_ADJ_LEVEL2)) {
- /* (6) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- }
- break;
- case IS_LEVEL_1_AND_2:
- case IS_LEVEL_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (7) adj state up */
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
- /* (8) adj usage level 2 */
- adj->adj_usage = ISIS_ADJ_LEVEL2;
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2) {
- /* (6) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL2) {
- ; /* Accept */
- }
- break;
- }
+ /* 8.2.5.2 a) 4) If the system is L2 - table 7 */
+ if (circuit->area->is_type == IS_LEVEL_2)
+ {
+ switch (hdr->circuit_t)
+ {
+ case IS_LEVEL_1:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (5) reject - wrong system type event */
+ zlog_warn ("wrongSystemType");
+ return ISIS_WARNING; /* Reject */
+ }
+ else if ((adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
+ (adj->adj_usage == ISIS_ADJ_LEVEL2))
+ {
+ /* (6) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ break;
+ case IS_LEVEL_1_AND_2:
+ case IS_LEVEL_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (7) adj state up */
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
+ /* (8) adj usage level 2 */
+ adj->adj_usage = ISIS_ADJ_LEVEL2;
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2)
+ {
+ /* (6) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL2)
+ {
+ ; /* Accept */
+ }
+ break;
+ }
+ }
}
- }
/* 8.2.5.2 b) if no match was detected */
else
- {
- if (circuit->area->is_type == IS_LEVEL_1) {
- /* 8.2.5.2 b) 1) is_type L1 and adj is not up */
- if (adj->adj_state != ISIS_ADJ_UP) {
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch");
- /* 8.2.5.2 b) 2)is_type L1 and adj is up */
- } else {
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Down - Area Mismatch");
- }
- }
- /* 8.2.5.2 b 3 If the system is L2 or L1L2 - table 8 */
- else
{
- switch (hdr->circuit_t) {
- case IS_LEVEL_1:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (6) reject - Area Mismatch event */
- zlog_warn ("AreaMismatch");
- return ISIS_WARNING; /* Reject */
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
- /* (7) down - area mismatch */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch");
-
- } else if ((adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
- (adj->adj_usage == ISIS_ADJ_LEVEL2)) {
- /* (7) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- }
- break;
- case IS_LEVEL_1_AND_2:
- case IS_LEVEL_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* (8) adj state up */
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
- /* (9) adj usage level 2 */
- adj->adj_usage = ISIS_ADJ_LEVEL2;
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
- /* (7) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2) {
- if (hdr->circuit_t == IS_LEVEL_2) {
- /* (7) down - wrong system */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
- } else {
- /* (7) down - area mismatch */
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch");
- }
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL2) {
- ; /* Accept */
- }
- break;
- }
+ if (circuit->area->is_type == IS_LEVEL_1)
+ {
+ /* 8.2.5.2 b) 1) is_type L1 and adj is not up */
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch");
+ /* 8.2.5.2 b) 2)is_type L1 and adj is up */
+ }
+ else
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN,
+ "Down - Area Mismatch");
+ }
+ }
+ /* 8.2.5.2 b 3 If the system is L2 or L1L2 - table 8 */
+ else
+ {
+ switch (hdr->circuit_t)
+ {
+ case IS_LEVEL_1:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (6) reject - Area Mismatch event */
+ zlog_warn ("AreaMismatch");
+ return ISIS_WARNING; /* Reject */
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1)
+ {
+ /* (7) down - area mismatch */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch");
+
+ }
+ else if ((adj->adj_usage == ISIS_ADJ_LEVEL1AND2) ||
+ (adj->adj_usage == ISIS_ADJ_LEVEL2))
+ {
+ /* (7) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ break;
+ case IS_LEVEL_1_AND_2:
+ case IS_LEVEL_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* (8) adj state up */
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL);
+ /* (9) adj usage level 2 */
+ adj->adj_usage = ISIS_ADJ_LEVEL2;
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1)
+ {
+ /* (7) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System");
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2)
+ {
+ if (hdr->circuit_t == IS_LEVEL_2)
+ {
+ /* (7) down - wrong system */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN,
+ "Wrong System");
+ }
+ else
+ {
+ /* (7) down - area mismatch */
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN,
+ "Area Mismatch");
+ }
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL2)
+ {
+ ; /* Accept */
+ }
+ break;
+ }
+ }
}
- }
/* 8.2.5.2 c) if the action was up - comparing circuit IDs */
/* FIXME - Missing parts */
-
/* some of my own understanding of the ISO, why the heck does
* it not say what should I change the system_type to...
*/
- switch (adj->adj_usage) {
+ switch (adj->adj_usage)
+ {
case ISIS_ADJ_LEVEL1:
adj->sys_type = ISIS_SYSTYPE_L1_IS;
break;
@@ -568,7 +644,7 @@ process_p2p_hello (struct isis_circuit *circuit)
case ISIS_ADJ_NONE:
adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
break;
- }
+ }
adj->circuit_t = hdr->circuit_t;
adj->level = hdr->circuit_t;
@@ -578,12 +654,11 @@ process_p2p_hello (struct isis_circuit *circuit)
return retval;
}
-
/*
* Process IS-IS LAN Level 1/2 Hello PDU
*/
-static int
-process_lan_hello (int level, struct isis_circuit *circuit, u_char *ssnpa)
+static int
+process_lan_hello (int level, struct isis_circuit *circuit, u_char * ssnpa)
{
int retval = ISIS_OK;
struct isis_lan_hello_hdr hdr;
@@ -593,35 +668,41 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char *ssnpa)
u_char *snpa;
struct listnode *node;
- if ((stream_get_endp (circuit->rcv_stream) -
- stream_get_getp (circuit->rcv_stream)) < ISIS_LANHELLO_HDRLEN) {
- zlog_warn ("Packet too short");
- return ISIS_WARNING;
- }
+ if ((stream_get_endp (circuit->rcv_stream) -
+ stream_get_getp (circuit->rcv_stream)) < ISIS_LANHELLO_HDRLEN)
+ {
+ zlog_warn ("Packet too short");
+ return ISIS_WARNING;
+ }
- if (circuit->ext_domain) {
- zlog_info ("level %d LAN Hello received over circuit with "
- "externalDomain = true", level);
- return ISIS_WARNING;
- }
+ if (circuit->ext_domain)
+ {
+ zlog_info ("level %d LAN Hello received over circuit with "
+ "externalDomain = true", level);
+ return ISIS_WARNING;
+ }
- if (!accept_level (level, circuit->circuit_is_type)) {
- if (isis->debugs & DEBUG_ADJ_PACKETS) {
- zlog_info ("ISIS-Adj (%s): Interface level mismatch, %s",
- circuit->area->area_tag, circuit->interface->name);
+ if (!accept_level (level, circuit->circuit_is_type))
+ {
+ if (isis->debugs & DEBUG_ADJ_PACKETS)
+ {
+ zlog_info ("ISIS-Adj (%s): Interface level mismatch, %s",
+ circuit->area->area_tag, circuit->interface->name);
+ }
+ return ISIS_WARNING;
}
- return ISIS_WARNING;
- }
#if 0
/* Cisco's debug message compatability */
- if (!accept_level (level, circuit->area->is_type)) {
- if (isis->debugs & DEBUG_ADJ_PACKETS) {
- zlog_info ("ISIS-Adj (%s): is type mismatch",
- circuit->area->area_tag);
+ if (!accept_level (level, circuit->area->is_type))
+ {
+ if (isis->debugs & DEBUG_ADJ_PACKETS)
+ {
+ zlog_info ("ISIS-Adj (%s): is type mismatch",
+ circuit->area->area_tag);
+ }
+ return ISIS_WARNING;
}
- return ISIS_WARNING;
- }
#endif
/*
* Fill the header
@@ -629,16 +710,17 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char *ssnpa)
hdr.circuit_t = stream_getc (circuit->rcv_stream);
stream_get (hdr.source_id, circuit->rcv_stream, ISIS_SYS_ID_LEN);
hdr.hold_time = stream_getw (circuit->rcv_stream);
- hdr.pdu_len = stream_getw (circuit->rcv_stream);
- hdr.prio = stream_getc (circuit->rcv_stream);
+ hdr.pdu_len = stream_getw (circuit->rcv_stream);
+ hdr.prio = stream_getc (circuit->rcv_stream);
stream_get (hdr.lan_id, circuit->rcv_stream, ISIS_SYS_ID_LEN + 1);
if (hdr.circuit_t != IS_LEVEL_1 && hdr.circuit_t != IS_LEVEL_2 &&
- hdr.circuit_t != IS_LEVEL_1_AND_2 ) {
- zlog_warn ("Level %d LAN Hello with Circuit Type %d", level,
- hdr.circuit_t);
- return ISIS_ERROR;
- }
+ hdr.circuit_t != IS_LEVEL_1_AND_2)
+ {
+ zlog_warn ("Level %d LAN Hello with Circuit Type %d", level,
+ hdr.circuit_t);
+ return ISIS_ERROR;
+ }
/*
* Then get the tlvs
*/
@@ -650,171 +732,194 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char *ssnpa)
expected |= TLVFLAG_IPV6_ADDR;
retval = parse_tlvs (circuit->area->area_tag,
- STREAM_PNT (circuit->rcv_stream),
- hdr.pdu_len - ISIS_LANHELLO_HDRLEN - ISIS_FIXED_HDR_LEN,
- &expected,
- &found,
- &tlvs);
-
- if (retval > ISIS_WARNING) {
- zlog_warn ("parse_tlvs() failed");
- goto out;
- }
+ STREAM_PNT (circuit->rcv_stream),
+ hdr.pdu_len - ISIS_LANHELLO_HDRLEN -
+ ISIS_FIXED_HDR_LEN, &expected, &found, &tlvs);
- if (!(found & TLVFLAG_AREA_ADDRS)) {
- zlog_warn ("No Area addresses TLV in Level %d LAN IS to IS hello", level);
- retval = ISIS_WARNING;
- goto out;
- }
+ if (retval > ISIS_WARNING)
+ {
+ zlog_warn ("parse_tlvs() failed");
+ goto out;
+ }
- if (circuit->passwd.type) {
- if (!(found & TLVFLAG_AUTH_INFO) ||
- authentication_check (&circuit->passwd, &tlvs.auth_info)) {
- isis_event_auth_failure (circuit->area->area_tag,
- "LAN hello authentication failure",
- hdr.source_id);
+ if (!(found & TLVFLAG_AREA_ADDRS))
+ {
+ zlog_warn ("No Area addresses TLV in Level %d LAN IS to IS hello",
+ level);
retval = ISIS_WARNING;
goto out;
}
- }
+
+ if (circuit->passwd.type)
+ {
+ if (!(found & TLVFLAG_AUTH_INFO) ||
+ authentication_check (&circuit->passwd, &tlvs.auth_info))
+ {
+ isis_event_auth_failure (circuit->area->area_tag,
+ "LAN hello authentication failure",
+ hdr.source_id);
+ retval = ISIS_WARNING;
+ goto out;
+ }
+ }
/*
* Accept the level 1 adjacency only if a match between local and
* remote area addresses is found
*/
- if (level == 1 && !area_match (circuit->area->area_addrs, tlvs.area_addrs)) {
- if (isis->debugs & DEBUG_ADJ_PACKETS) {
- zlog_info ("ISIS-Adj (%s): Area mismatch, level %d IIH on %s",
- circuit->area->area_tag, level,circuit->interface->name);
+ if (level == 1 && !area_match (circuit->area->area_addrs, tlvs.area_addrs))
+ {
+ if (isis->debugs & DEBUG_ADJ_PACKETS)
+ {
+ zlog_info ("ISIS-Adj (%s): Area mismatch, level %d IIH on %s",
+ circuit->area->area_tag, level,
+ circuit->interface->name);
+ }
+ retval = ISIS_OK;
+ goto out;
}
- retval = ISIS_OK;
- goto out;
- }
/*
* it's own IIH PDU - discard silently
- */
- if (!memcmp (circuit->u.bc.snpa, ssnpa, ETH_ALEN)) {
- zlog_info ("ISIS-Adj (%s): it's own IIH PDU - discarded",
- circuit->area->area_tag);
+ */
+ if (!memcmp (circuit->u.bc.snpa, ssnpa, ETH_ALEN))
+ {
+ zlog_info ("ISIS-Adj (%s): it's own IIH PDU - discarded",
+ circuit->area->area_tag);
- retval = ISIS_OK;
- goto out;
- }
+ retval = ISIS_OK;
+ goto out;
+ }
/*
* check if it's own interface ip match iih ip addrs
*/
- if (!(found & TLVFLAG_IPV4_ADDR) || !ip_match(circuit->ip_addrs, tlvs.ipv4_addrs)) {
- zlog_info("ISIS-Adj: No usable IP interface addresses in LAN IIH from %s\n",
- circuit->interface->name);
- retval = ISIS_WARNING;
- goto out;
- }
-
+ if (!(found & TLVFLAG_IPV4_ADDR)
+ || !ip_match (circuit->ip_addrs, tlvs.ipv4_addrs))
+ {
+ zlog_info
+ ("ISIS-Adj: No usable IP interface addresses in LAN IIH from %s\n",
+ circuit->interface->name);
+ retval = ISIS_WARNING;
+ goto out;
+ }
adj = isis_adj_lookup (hdr.source_id, circuit->u.bc.adjdb[level - 1]);
- if (!adj) {
- /*
- * Do as in 8.4.2.5
- */
- adj = isis_new_adj (hdr.source_id, ssnpa, level, circuit);
- if (adj == NULL)
- retval = ISIS_ERROR;
+ if (!adj)
+ {
+ /*
+ * Do as in 8.4.2.5
+ */
+ adj = isis_new_adj (hdr.source_id, ssnpa, level, circuit);
+ if (adj == NULL)
+ retval = ISIS_ERROR;
goto out;
- adj->level = level;
- isis_adj_state_change(adj, ISIS_ADJ_INITIALIZING, NULL);
+ adj->level = level;
+ isis_adj_state_change (adj, ISIS_ADJ_INITIALIZING, NULL);
- if (level == 1) {
- adj->sys_type = ISIS_SYSTYPE_L1_IS;
- } else {
- adj->sys_type = ISIS_SYSTYPE_L2_IS;
+ if (level == 1)
+ {
+ adj->sys_type = ISIS_SYSTYPE_L1_IS;
+ }
+ else
+ {
+ adj->sys_type = ISIS_SYSTYPE_L2_IS;
+ }
+ 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]);
}
- 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]);
- }
- switch (level) {
- case 1 :
- if (memcmp(circuit->u.bc.l1_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1)) {
- thread_add_event (master, isis_event_dis_status_change, circuit, 0);
- memcpy (&circuit->u.bc.l1_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1);
- }
- break;
- case 2 :
- if (memcmp (circuit->u.bc.l2_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1)) {
- thread_add_event (master, isis_event_dis_status_change, circuit, 0);
- memcpy (&circuit->u.bc.l2_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1);
+ switch (level)
+ {
+ case 1:
+ if (memcmp (circuit->u.bc.l1_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1))
+ {
+ thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+ memcpy (&circuit->u.bc.l1_desig_is, hdr.lan_id,
+ ISIS_SYS_ID_LEN + 1);
+ }
+ break;
+ case 2:
+ if (memcmp (circuit->u.bc.l2_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1))
+ {
+ thread_add_event (master, isis_event_dis_status_change, circuit, 0);
+ memcpy (&circuit->u.bc.l2_desig_is, hdr.lan_id,
+ ISIS_SYS_ID_LEN + 1);
+ }
+ break;
}
- break;
- }
#if 0
- /* Old solution: believe the lan-header always
- */
- if (level == 1) {
- memcpy(circuit->u.bc.l1_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1);
- } else if (level == 2) {
- memcpy(circuit->u.bc.l2_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1);
- }
+ /* Old solution: believe the lan-header always
+ */
+ if (level == 1)
+ {
+ memcpy (circuit->u.bc.l1_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1);
+ }
+ else if (level == 2)
+ {
+ memcpy (circuit->u.bc.l2_desig_is, hdr.lan_id, ISIS_SYS_ID_LEN + 1);
+ }
#endif
adj->hold_time = hdr.hold_time;
- adj->last_upd = time (NULL);
- adj->prio[level-1] = hdr.prio;
+ adj->last_upd = time (NULL);
+ adj->prio[level - 1] = hdr.prio;
memcpy (adj->lanid, hdr.lan_id, ISIS_SYS_ID_LEN + 1);
/* which protocol are spoken ??? */
- if (found & TLVFLAG_NLPID)
+ if (found & TLVFLAG_NLPID)
tlvs_to_adj_nlpids (&tlvs, adj);
/* we need to copy addresses to the adj */
- if (found & TLVFLAG_IPV4_ADDR)
+ if (found & TLVFLAG_IPV4_ADDR)
tlvs_to_adj_ipv4_addrs (&tlvs, adj);
#ifdef HAVE_IPV6
- if (found & TLVFLAG_IPV6_ADDR)
+ if (found & TLVFLAG_IPV6_ADDR)
tlvs_to_adj_ipv6_addrs (&tlvs, adj);
#endif /* HAVE_IPV6 */
adj->circuit_t = hdr.circuit_t;
/* lets take care of the expiry */
- THREAD_TIMER_OFF(adj->t_expire);
- THREAD_TIMER_ON(master, adj->t_expire, isis_adj_expire, adj,
- (long)adj->hold_time);
+ THREAD_TIMER_OFF (adj->t_expire);
+ THREAD_TIMER_ON (master, adj->t_expire, isis_adj_expire, adj,
+ (long) adj->hold_time);
/*
* If the snpa for this circuit is found from LAN Neighbours TLV
* we have two-way communication -> adjacency can be put to state "up"
*/
- if (found & TLVFLAG_LAN_NEIGHS) {
- if (adj->adj_state != ISIS_ADJ_UP) {
- LIST_LOOP (tlvs.lan_neighs, snpa, node)
- if (!memcmp (snpa, circuit->u.bc.snpa, ETH_ALEN)) {
- isis_adj_state_change (adj, ISIS_ADJ_UP,
- "own SNPA found in LAN Neighbours TLV");
- }
+ if (found & TLVFLAG_LAN_NEIGHS)
+ {
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ LIST_LOOP (tlvs.lan_neighs, snpa, node)
+ if (!memcmp (snpa, circuit->u.bc.snpa, ETH_ALEN))
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_UP,
+ "own SNPA found in LAN Neighbours TLV");
+ }
+ }
}
- }
- out:
+out:
/* DEBUG_ADJ_PACKETS */
- if (isis->debugs & DEBUG_ADJ_PACKETS) {
- /* FIXME: is this place right? fix missing info */
- zlog_info ("ISIS-Adj (%s): Rcvd L%d LAN IIH from %s on %s, cirType %s, "
- "cirID %u, length %ld",
- circuit->area->area_tag,
- level,snpa_print(ssnpa), circuit->interface->name,
- circuit_t2string(circuit->circuit_is_type),
- circuit->circuit_id,
- stream_get_endp (circuit->rcv_stream));
- }
-
+ if (isis->debugs & DEBUG_ADJ_PACKETS)
+ {
+ /* FIXME: is this place right? fix missing info */
+ zlog_info ("ISIS-Adj (%s): Rcvd L%d LAN IIH from %s on %s, cirType %s, "
+ "cirID %u, length %ld",
+ circuit->area->area_tag,
+ level, snpa_print (ssnpa), circuit->interface->name,
+ circuit_t2string (circuit->circuit_is_type),
+ circuit->circuit_id, stream_get_endp (circuit->rcv_stream));
+ }
free_tlvs (&tlvs);
@@ -825,9 +930,9 @@ process_lan_hello (int level, struct isis_circuit *circuit, u_char *ssnpa)
* Process Level 1/2 Link State
* ISO - 10589
* Section 7.3.15.1 - Action on receipt of a link state PDU
- */
-static int
-process_lsp (int level, struct isis_circuit *circuit, u_char *ssnpa)
+ */
+static int
+process_lsp (int level, struct isis_circuit *circuit, u_char * ssnpa)
{
struct isis_link_state_hdr *hdr;
struct isis_adjacency *adj = NULL;
@@ -837,64 +942,65 @@ process_lsp (int level, struct isis_circuit *circuit, u_char *ssnpa)
struct isis_passwd *passwd;
/* Sanity check - FIXME: move to correct place */
- if ((stream_get_endp (circuit->rcv_stream) -
- stream_get_getp (circuit->rcv_stream)) < ISIS_LSP_HDR_LEN ) {
- zlog_warn ("Packet too short");
- return ISIS_WARNING;
- }
+ if ((stream_get_endp (circuit->rcv_stream) -
+ stream_get_getp (circuit->rcv_stream)) < ISIS_LSP_HDR_LEN)
+ {
+ zlog_warn ("Packet too short");
+ return ISIS_WARNING;
+ }
/* Reference the header */
- hdr = (struct isis_link_state_hdr*)STREAM_PNT (circuit->rcv_stream);
-
- if (isis->debugs & DEBUG_UPDATE_PACKETS) {
- zlog_info ("ISIS-Upd (%s): Rcvd L%d LSP %s, seq 0x%08x, cksum 0x%04x, "
- "lifetime %us, len %lu, on %s",
- circuit->area->area_tag,
- level,
- rawlspid_print(hdr->lsp_id),
- ntohl(hdr->seq_num),
- ntohs(hdr->checksum),
- ntohs(hdr->rem_lifetime),
- circuit->rcv_stream->endp,
- circuit->interface->name);
- }
+ hdr = (struct isis_link_state_hdr *) STREAM_PNT (circuit->rcv_stream);
+
+ if (isis->debugs & DEBUG_UPDATE_PACKETS)
+ {
+ zlog_info ("ISIS-Upd (%s): Rcvd L%d LSP %s, seq 0x%08x, cksum 0x%04x, "
+ "lifetime %us, len %lu, on %s",
+ circuit->area->area_tag,
+ level,
+ rawlspid_print (hdr->lsp_id),
+ ntohl (hdr->seq_num),
+ ntohs (hdr->checksum),
+ ntohs (hdr->rem_lifetime),
+ circuit->rcv_stream->endp, circuit->interface->name);
+ }
assert (ntohs (hdr->pdu_len) > ISIS_LSP_HDR_LEN);
/* Checksum sanity check - FIXME: move to correct place */
/* 12 = sysid+pdu+remtime */
- if (iso_csum_verify (STREAM_PNT (circuit->rcv_stream) + 4,
- ntohs (hdr->pdu_len) - 12, &hdr->checksum)) {
- zlog_info ("ISIS-Upd (%s): LSP %s invalid LSP checksum 0x%04x",
- circuit->area->area_tag,
- rawlspid_print (hdr->lsp_id),
- ntohs(hdr->checksum));
-
- return ISIS_WARNING;
- }
+ if (iso_csum_verify (STREAM_PNT (circuit->rcv_stream) + 4,
+ ntohs (hdr->pdu_len) - 12, &hdr->checksum))
+ {
+ zlog_info ("ISIS-Upd (%s): LSP %s invalid LSP checksum 0x%04x",
+ circuit->area->area_tag,
+ rawlspid_print (hdr->lsp_id), ntohs (hdr->checksum));
+
+ return ISIS_WARNING;
+ }
/* 7.3.15.1 a) 1 - external domain circuit will discard lsps */
- if (circuit->ext_domain) {
- zlog_info ("ISIS-Upd (%s): LSP %s received at level %d over circuit with "
- "externalDomain = true",
- circuit->area->area_tag,
- rawlspid_print (hdr->lsp_id),
- level);
-
- return ISIS_WARNING;
- }
+ if (circuit->ext_domain)
+ {
+ zlog_info
+ ("ISIS-Upd (%s): LSP %s received at level %d over circuit with "
+ "externalDomain = true", circuit->area->area_tag,
+ rawlspid_print (hdr->lsp_id), level);
+
+ return ISIS_WARNING;
+ }
/* 7.3.15.1 a) 2,3 - manualL2OnlyMode not implemented */
- if (!accept_level (level, circuit->circuit_is_type)) {
- zlog_info ("ISIS-Upd (%s): LSP %s received at level %d over circuit of"
- " type %s",
- circuit->area->area_tag,
- rawlspid_print(hdr->lsp_id),
- level,
- circuit_t2string (circuit->circuit_is_type));
-
- return ISIS_WARNING;
- }
+ if (!accept_level (level, circuit->circuit_is_type))
+ {
+ zlog_info ("ISIS-Upd (%s): LSP %s received at level %d over circuit of"
+ " type %s",
+ circuit->area->area_tag,
+ rawlspid_print (hdr->lsp_id),
+ level, circuit_t2string (circuit->circuit_is_type));
+
+ return ISIS_WARNING;
+ }
/* 7.3.15.1 a) 4 - need to make sure IDLength matches */
@@ -903,221 +1009,254 @@ process_lsp (int level, struct isis_circuit *circuit, u_char *ssnpa)
/* 7.3.15.1 a) 7 - password check */
(level == ISIS_LEVEL1) ? (passwd = &circuit->area->area_passwd) :
(passwd = &circuit->area->domain_passwd);
- if (passwd->type) {
- if (isis_lsp_authinfo_check (circuit->rcv_stream, circuit->area,
- ntohs (hdr->pdu_len), passwd)) {
- isis_event_auth_failure (circuit->area->area_tag,
- "LSP authentication failure",
- hdr->lsp_id);
- return ISIS_WARNING;
+ if (passwd->type)
+ {
+ if (isis_lsp_authinfo_check (circuit->rcv_stream, circuit->area,
+ ntohs (hdr->pdu_len), passwd))
+ {
+ isis_event_auth_failure (circuit->area->area_tag,
+ "LSP authentication failure", hdr->lsp_id);
+ return ISIS_WARNING;
+ }
}
- }
/* Find the LSP in our database and compare it to this Link State header */
lsp = lsp_search (hdr->lsp_id, circuit->area->lspdb[level - 1]);
if (lsp)
- comp = lsp_compare (circuit->area->area_tag, lsp, hdr->seq_num,
- hdr->checksum, hdr->rem_lifetime);
- if (lsp && (lsp->own_lsp
+ comp = lsp_compare (circuit->area->area_tag, lsp, hdr->seq_num,
+ hdr->checksum, hdr->rem_lifetime);
+ if (lsp && (lsp->own_lsp
#ifdef TOPOLOGY_GENERATE
- || lsp->from_topology
+ || lsp->from_topology
#endif /* TOPOLOGY_GENERATE */
- ))
+ ))
goto dontcheckadj;
/* 7.3.15.1 a) 6 - Must check that we have an adjacency of the same level */
/* for broadcast circuits, snpa should be compared */
/* FIXME : Point To Point */
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- adj = isis_adj_lookup_snpa (ssnpa, circuit->u.bc.adjdb[level - 1]);
- if (!adj) {
- zlog_info ("(%s): DS ======= LSP %s, seq 0x%08x, cksum 0x%04x, "
- "lifetime %us on %s",
- circuit->area->area_tag,
- rawlspid_print (hdr->lsp_id),
- ntohl (hdr->seq_num),
- ntohs (hdr->checksum),
- ntohs (hdr->rem_lifetime),
- circuit->interface->name);
- return ISIS_WARNING; /* Silently discard */
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ adj = isis_adj_lookup_snpa (ssnpa, circuit->u.bc.adjdb[level - 1]);
+ if (!adj)
+ {
+ zlog_info ("(%s): DS ======= LSP %s, seq 0x%08x, cksum 0x%04x, "
+ "lifetime %us on %s",
+ circuit->area->area_tag,
+ rawlspid_print (hdr->lsp_id),
+ ntohl (hdr->seq_num),
+ ntohs (hdr->checksum),
+ ntohs (hdr->rem_lifetime), circuit->interface->name);
+ return ISIS_WARNING; /* Silently discard */
+ }
}
- }
/* for non broadcast, we just need to find same level adj */
- else {
- /* If no adj, or no sharing of level */
- if (!circuit->u.p2p.neighbor) {
- return ISIS_OK; /* Silently discard */
- } else {
- if (((level == 1) &&
- (circuit->u.p2p.neighbor->adj_usage == ISIS_ADJ_LEVEL2)) ||
- ((level == 2) &&
- (circuit->u.p2p.neighbor->adj_usage == ISIS_ADJ_LEVEL1)))
- return ISIS_WARNING; /* Silently discard */
+ else
+ {
+ /* If no adj, or no sharing of level */
+ if (!circuit->u.p2p.neighbor)
+ {
+ return ISIS_OK; /* Silently discard */
+ }
+ else
+ {
+ if (((level == 1) &&
+ (circuit->u.p2p.neighbor->adj_usage == ISIS_ADJ_LEVEL2)) ||
+ ((level == 2) &&
+ (circuit->u.p2p.neighbor->adj_usage == ISIS_ADJ_LEVEL1)))
+ return ISIS_WARNING; /* Silently discard */
+ }
}
- }
- dontcheckadj:
+dontcheckadj:
/* 7.3.15.1 a) 7 - Passwords for level 1 - not implemented */
/* 7.3.15.1 a) 8 - Passwords for level 2 - not implemented */
- /* 7.3.15.1 a) 9 - OriginatingLSPBufferSize - not implemented FIXME: do it*/
-
-
- /* 7.3.15.1 b) - If the remaining life time is 0, we perform 7.3.16.4*/
- if (hdr->rem_lifetime == 0) {
- if (!lsp) {
- /* 7.3.16.4 a) 1) No LSP in db -> send an ack, but don't save */
- /* only needed on explicit update, eg - p2p */
- if (circuit->circ_type == CIRCUIT_T_P2P)
- ack_lsp (hdr, circuit, level);
- return retval; /* FIXME: do we need a purge? */
- } else {
- if (memcmp (hdr->lsp_id, isis->sysid, ISIS_SYS_ID_LEN )) {
- /* LSP by some other system -> do 7.3.16.4 b) */
- /* 7.3.16.4 b) 1) */
- if (comp == LSP_NEWER) {
- lsp_update (lsp, hdr, circuit->rcv_stream, circuit->area);
- /* ii */
- ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- /* iii */
- ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
- /* v */
- ISIS_FLAGS_CLEAR_ALL(lsp->SSNflags); /* FIXME: OTHER than c */
- /* iv */
- if (circuit->circ_type != CIRCUIT_T_BROADCAST)
- ISIS_SET_FLAG(lsp->SSNflags, circuit);
-
- } /* 7.3.16.4 b) 2) */
- else if (comp == LSP_EQUAL) {
- /* i */
- ISIS_CLEAR_FLAG(lsp->SRMflags, circuit);
- /* ii*/
- if (circuit->circ_type != CIRCUIT_T_BROADCAST)
- ISIS_SET_FLAG(lsp->SSNflags, circuit);
- } /* 7.3.16.4 b) 3) */
- else {
- ISIS_SET_FLAG(lsp->SRMflags, circuit);
- ISIS_CLEAR_FLAG(lsp->SSNflags, circuit);
- }
- } else {
- /* our own LSP -> 7.3.16.4 c) */
- if (LSP_PSEUDO_ID(lsp->lsp_header->lsp_id) != circuit->circuit_id ||
- (LSP_PSEUDO_ID(lsp->lsp_header->lsp_id) == circuit->circuit_id &&
- circuit->u.bc.is_dr[level - 1] == 1) ) {
- lsp->lsp_header->seq_num = htonl (ntohl (hdr->seq_num) + 1);
- zlog_info ("LSP LEN: %d", ntohs (lsp->lsp_header->pdu_len));
- iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
- ntohs (lsp->lsp_header->pdu_len) - 12, 12);
- ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- zlog_info ("ISIS-Upd (%s): (1) re-originating LSP %s new seq 0x%08x",
- circuit->area->area_tag,
- rawlspid_print (hdr->lsp_id),
- ntohl (lsp->lsp_header->seq_num));
- lsp->lsp_header->rem_lifetime = htons (isis_jitter
- (circuit->area->
- max_lsp_lifetime[level-1],
- MAX_AGE_JITTER));
-
- } else {
- /* Got purge for own pseudo-lsp, and we are not DR */
- lsp_purge_dr (lsp->lsp_header->lsp_id, circuit, level);
- }
- }
+ /* 7.3.15.1 a) 9 - OriginatingLSPBufferSize - not implemented FIXME: do it */
+
+ /* 7.3.15.1 b) - If the remaining life time is 0, we perform 7.3.16.4 */
+ if (hdr->rem_lifetime == 0)
+ {
+ if (!lsp)
+ {
+ /* 7.3.16.4 a) 1) No LSP in db -> send an ack, but don't save */
+ /* only needed on explicit update, eg - p2p */
+ if (circuit->circ_type == CIRCUIT_T_P2P)
+ ack_lsp (hdr, circuit, level);
+ return retval; /* FIXME: do we need a purge? */
+ }
+ else
+ {
+ if (memcmp (hdr->lsp_id, isis->sysid, ISIS_SYS_ID_LEN))
+ {
+ /* LSP by some other system -> do 7.3.16.4 b) */
+ /* 7.3.16.4 b) 1) */
+ if (comp == LSP_NEWER)
+ {
+ lsp_update (lsp, hdr, circuit->rcv_stream, circuit->area);
+ /* ii */
+ ISIS_FLAGS_SET_ALL (lsp->SRMflags);
+ /* iii */
+ ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+ /* v */
+ ISIS_FLAGS_CLEAR_ALL (lsp->SSNflags); /* FIXME: OTHER than c */
+ /* iv */
+ if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+ ISIS_SET_FLAG (lsp->SSNflags, circuit);
+
+ } /* 7.3.16.4 b) 2) */
+ else if (comp == LSP_EQUAL)
+ {
+ /* i */
+ ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+ /* ii */
+ if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+ ISIS_SET_FLAG (lsp->SSNflags, circuit);
+ } /* 7.3.16.4 b) 3) */
+ else
+ {
+ ISIS_SET_FLAG (lsp->SRMflags, circuit);
+ ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
+ }
+ }
+ else
+ {
+ /* our own LSP -> 7.3.16.4 c) */
+ if (LSP_PSEUDO_ID (lsp->lsp_header->lsp_id) !=
+ circuit->circuit_id
+ || (LSP_PSEUDO_ID (lsp->lsp_header->lsp_id) ==
+ circuit->circuit_id
+ && circuit->u.bc.is_dr[level - 1] == 1))
+ {
+ lsp->lsp_header->seq_num = htonl (ntohl (hdr->seq_num) + 1);
+ zlog_info ("LSP LEN: %d", ntohs (lsp->lsp_header->pdu_len));
+ iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
+ ntohs (lsp->lsp_header->pdu_len) - 12, 12);
+ ISIS_FLAGS_SET_ALL (lsp->SRMflags);
+ zlog_info
+ ("ISIS-Upd (%s): (1) re-originating LSP %s new seq 0x%08x",
+ circuit->area->area_tag, rawlspid_print (hdr->lsp_id),
+ ntohl (lsp->lsp_header->seq_num));
+ lsp->lsp_header->rem_lifetime =
+ htons (isis_jitter
+ (circuit->area->max_lsp_lifetime[level - 1],
+ MAX_AGE_JITTER));
+ }
+ else
+ {
+ /* Got purge for own pseudo-lsp, and we are not DR */
+ lsp_purge_dr (lsp->lsp_header->lsp_id, circuit, level);
+ }
+ }
+ }
+ return retval;
}
- return retval;
- }
/* 7.3.15.1 c) - If this is our own lsp and we don't have it initiate a
* purge */
- if (memcmp (hdr->lsp_id, isis->sysid, ISIS_SYS_ID_LEN ) == 0) {
- if (!lsp) {
- /* 7.3.16.4: initiate a purge */
- lsp_purge_non_exist (hdr, circuit->area);
- return ISIS_OK;
- }
- /* 7.3.15.1 d) - If this is our own lsp and we have it */
-
- /* In 7.3.16.1, If an Intermediate system R somewhere in the domain
- * has information that the current sequence number for source S is
- * "greater" than that held by S, ... */
-
- else if (ntohl (hdr->seq_num) > ntohl (lsp->lsp_header->seq_num)) {
- /* 7.3.16.1 */
- lsp->lsp_header->seq_num = htonl (ntohl (hdr->seq_num) + 1);
-
- iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
- ntohs(lsp->lsp_header->pdu_len) - 12, 12);
-
- ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- zlog_info ("ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08x",
- circuit->area->area_tag,
- rawlspid_print (hdr->lsp_id),
- ntohl (lsp->lsp_header->seq_num));
- lsp->lsp_header->rem_lifetime = htons (isis_jitter
- (circuit->
- area->max_lsp_lifetime[level-1],
- MAX_AGE_JITTER));
-
+ if (memcmp (hdr->lsp_id, isis->sysid, ISIS_SYS_ID_LEN) == 0)
+ {
+ if (!lsp)
+ {
+ /* 7.3.16.4: initiate a purge */
+ lsp_purge_non_exist (hdr, circuit->area);
+ return ISIS_OK;
+ }
+ /* 7.3.15.1 d) - If this is our own lsp and we have it */
+
+ /* In 7.3.16.1, If an Intermediate system R somewhere in the domain
+ * has information that the current sequence number for source S is
+ * "greater" than that held by S, ... */
+
+ else if (ntohl (hdr->seq_num) > ntohl (lsp->lsp_header->seq_num))
+ {
+ /* 7.3.16.1 */
+ lsp->lsp_header->seq_num = htonl (ntohl (hdr->seq_num) + 1);
+
+ iso_csum_create (STREAM_DATA (lsp->pdu) + 12,
+ ntohs (lsp->lsp_header->pdu_len) - 12, 12);
+
+ ISIS_FLAGS_SET_ALL (lsp->SRMflags);
+ zlog_info
+ ("ISIS-Upd (%s): (2) re-originating LSP %s new seq 0x%08x",
+ circuit->area->area_tag, rawlspid_print (hdr->lsp_id),
+ ntohl (lsp->lsp_header->seq_num));
+ lsp->lsp_header->rem_lifetime =
+ htons (isis_jitter
+ (circuit->area->max_lsp_lifetime[level - 1],
+ MAX_AGE_JITTER));
+ }
}
- } else {
- /* 7.3.15.1 e) - This lsp originated on another system */
-
- /* 7.3.15.1 e) 1) LSP newer than the one in db or no LSP in db */
- if ((!lsp || comp == LSP_NEWER)){
- /* i */
- if (lsp) {
+ else
+ {
+ /* 7.3.15.1 e) - This lsp originated on another system */
+
+ /* 7.3.15.1 e) 1) LSP newer than the one in db or no LSP in db */
+ if ((!lsp || comp == LSP_NEWER))
+ {
+ /* i */
+ if (lsp)
+ {
#ifdef EXTREME_DEBUG
- zlog_info ("level %d number is - %ld", level,
- circuit->area->lspdb[level-1]->dict_nodecount);
+ zlog_info ("level %d number is - %ld", level,
+ circuit->area->lspdb[level - 1]->dict_nodecount);
#endif /* EXTREME DEBUG */
- lsp_search_and_destroy (hdr->lsp_id, circuit->area->lspdb[level-1]);
- /* exists, so we overwrite */
+ lsp_search_and_destroy (hdr->lsp_id,
+ circuit->area->lspdb[level - 1]);
+ /* exists, so we overwrite */
#ifdef EXTREME_DEBUG
- zlog_info ("level %d number is - %ld",level,
- circuit->area->lspdb[level-1]->dict_nodecount);
+ zlog_info ("level %d number is - %ld", level,
+ circuit->area->lspdb[level - 1]->dict_nodecount);
#endif /* EXTREME DEBUG */
- }
- /*
- * If this lsp is a frag, need to see if we have zero lsp present
- */
- if (LSP_FRAGMENT (hdr->lsp_id) != 0) {
- memcpy (lspid, hdr->lsp_id, ISIS_SYS_ID_LEN + 1);
- LSP_FRAGMENT (lspid) = 0;
- lsp0 = lsp_search (lspid, circuit->area->lspdb[level - 1]);
- if (!lsp0) {
- zlog_info ("Got lsp frag, while zero lsp not database");
- return ISIS_OK;
- }
- }
- lsp = lsp_new_from_stream_ptr (circuit->rcv_stream, ntohs (hdr->pdu_len),
- lsp0, circuit->area);
- lsp->level = level;
- lsp->adj = adj;
- lsp_insert (lsp, circuit->area->lspdb[level-1]);
- /* ii */
- ISIS_FLAGS_SET_ALL (lsp->SRMflags);
- /* iii */
- ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
-
- /* iv */
- if (circuit->circ_type != CIRCUIT_T_BROADCAST)
- ISIS_SET_FLAG (lsp->SSNflags, circuit);
- /* FIXME: v) */
- }
- /* 7.3.15.1 e) 2) LSP equal to the one in db */
- else if (comp == LSP_EQUAL) {
- ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
- lsp_update (lsp, hdr, circuit->rcv_stream, circuit->area);
- if (circuit->circ_type != CIRCUIT_T_BROADCAST) {
- ISIS_SET_FLAG (lsp->SSNflags, circuit);
- }
- }
- /* 7.3.15.1 e) 3) LSP older than the one in db */
- else {
- ISIS_SET_FLAG(lsp->SRMflags, circuit);
- ISIS_CLEAR_FLAG(lsp->SSNflags, circuit);
+ }
+ /*
+ * If this lsp is a frag, need to see if we have zero lsp present
+ */
+ if (LSP_FRAGMENT (hdr->lsp_id) != 0)
+ {
+ memcpy (lspid, hdr->lsp_id, ISIS_SYS_ID_LEN + 1);
+ LSP_FRAGMENT (lspid) = 0;
+ lsp0 = lsp_search (lspid, circuit->area->lspdb[level - 1]);
+ if (!lsp0)
+ {
+ zlog_info ("Got lsp frag, while zero lsp not database");
+ return ISIS_OK;
+ }
+ }
+ lsp =
+ lsp_new_from_stream_ptr (circuit->rcv_stream,
+ ntohs (hdr->pdu_len), lsp0,
+ circuit->area);
+ lsp->level = level;
+ lsp->adj = adj;
+ lsp_insert (lsp, circuit->area->lspdb[level - 1]);
+ /* ii */
+ ISIS_FLAGS_SET_ALL (lsp->SRMflags);
+ /* iii */
+ ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+
+ /* iv */
+ if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+ ISIS_SET_FLAG (lsp->SSNflags, circuit);
+ /* FIXME: v) */
+ }
+ /* 7.3.15.1 e) 2) LSP equal to the one in db */
+ else if (comp == LSP_EQUAL)
+ {
+ ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+ lsp_update (lsp, hdr, circuit->rcv_stream, circuit->area);
+ if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+ {
+ ISIS_SET_FLAG (lsp->SSNflags, circuit);
+ }
+ }
+ /* 7.3.15.1 e) 3) LSP older than the one in db */
+ else
+ {
+ ISIS_SET_FLAG (lsp->SRMflags, circuit);
+ ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
+ }
}
- }
if (lsp)
lsp->adj = adj;
return retval;
@@ -1130,8 +1269,8 @@ process_lsp (int level, struct isis_circuit *circuit, u_char *ssnpa)
*/
int
-process_snp (int snp_type, int level, struct isis_circuit *circuit,
- u_char *ssnpa)
+process_snp (int snp_type, int level, struct isis_circuit *circuit,
+ u_char * ssnpa)
{
int retval = ISIS_OK;
int cmp, own_lsp;
@@ -1143,76 +1282,82 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
uint32_t found = 0, expected = 0;
struct isis_lsp *lsp;
struct lsp_entry *entry;
- struct listnode *node,*node2;
+ struct listnode *node, *node2;
struct tlvs tlvs;
struct list *lsp_list = NULL;
struct isis_passwd *passwd;
- if (snp_type == ISIS_SNP_CSNP_FLAG) {
- /* getting the header info */
- typechar = 'C';
- chdr = (struct isis_complete_seqnum_hdr*)STREAM_PNT(circuit->rcv_stream);
- circuit->rcv_stream->getp += ISIS_CSNP_HDRLEN;
- len = ntohs(chdr->pdu_len);
- if (len < ISIS_CSNP_HDRLEN) {
- zlog_warn ("Received a CSNP with bogus length!");
- return ISIS_OK;
+ if (snp_type == ISIS_SNP_CSNP_FLAG)
+ {
+ /* getting the header info */
+ typechar = 'C';
+ chdr =
+ (struct isis_complete_seqnum_hdr *) STREAM_PNT (circuit->rcv_stream);
+ circuit->rcv_stream->getp += ISIS_CSNP_HDRLEN;
+ len = ntohs (chdr->pdu_len);
+ if (len < ISIS_CSNP_HDRLEN)
+ {
+ zlog_warn ("Received a CSNP with bogus length!");
+ return ISIS_OK;
+ }
}
- } else {
- typechar = 'P';
- phdr = (struct isis_partial_seqnum_hdr*)STREAM_PNT(circuit->rcv_stream);
- circuit->rcv_stream->getp += ISIS_PSNP_HDRLEN;
- len = ntohs(phdr->pdu_len);
- if (len < ISIS_PSNP_HDRLEN) {
- zlog_warn ("Received a CSNP with bogus length!");
- return ISIS_OK;
+ else
+ {
+ typechar = 'P';
+ phdr =
+ (struct isis_partial_seqnum_hdr *) STREAM_PNT (circuit->rcv_stream);
+ circuit->rcv_stream->getp += ISIS_PSNP_HDRLEN;
+ len = ntohs (phdr->pdu_len);
+ if (len < ISIS_PSNP_HDRLEN)
+ {
+ zlog_warn ("Received a CSNP with bogus length!");
+ return ISIS_OK;
+ }
}
- }
/* 7.3.15.2 a) 1 - external domain circuit will discard snp pdu */
- if (circuit->ext_domain) {
+ if (circuit->ext_domain)
+ {
- zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP on %s, "
- "skipping: circuit externalDomain = true",
- circuit->area->area_tag,
- level,
- typechar,
- circuit->interface->name);
+ zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP on %s, "
+ "skipping: circuit externalDomain = true",
+ circuit->area->area_tag,
+ level, typechar, circuit->interface->name);
- return ISIS_OK;
- }
+ return ISIS_OK;
+ }
/* 7.3.15.2 a) 2,3 - manualL2OnlyMode not implemented */
- if (!accept_level (level, circuit->circuit_is_type)) {
-
- zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP on %s, "
- "skipping: circuit type %s does not match level %d",
- circuit->area->area_tag,
- level,
- typechar,
- circuit->interface->name,
- circuit_t2string (circuit->circuit_is_type),
- level);
-
- return ISIS_OK;
- }
-
- /* 7.3.15.2 a) 4 - not applicable for CSNP only PSNPs on broadcast */
- if ((snp_type == ISIS_SNP_PSNP_FLAG) &&
- (circuit->circ_type == CIRCUIT_T_BROADCAST)) {
- if (!circuit->u.bc.is_dr[level-1]) {
+ if (!accept_level (level, circuit->circuit_is_type))
+ {
- zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s, "
- "skipping: we are not the DIS",
+ zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP on %s, "
+ "skipping: circuit type %s does not match level %d",
circuit->area->area_tag,
- level,
+ level,
typechar,
- snpa_print(ssnpa),
- circuit->interface->name);
+ circuit->interface->name,
+ circuit_t2string (circuit->circuit_is_type), level);
return ISIS_OK;
}
- }
+
+ /* 7.3.15.2 a) 4 - not applicable for CSNP only PSNPs on broadcast */
+ if ((snp_type == ISIS_SNP_PSNP_FLAG) &&
+ (circuit->circ_type == CIRCUIT_T_BROADCAST))
+ {
+ if (!circuit->u.bc.is_dr[level - 1])
+ {
+
+ zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s, "
+ "skipping: we are not the DIS",
+ circuit->area->area_tag,
+ level,
+ typechar, snpa_print (ssnpa), circuit->interface->name);
+
+ return ISIS_OK;
+ }
+ }
/* 7.3.15.2 a) 5 - need to make sure IDLength matches - already checked */
@@ -1222,19 +1367,27 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
/* 7.3.15.2 a) 7 - Must check that we have an adjacency of the same level */
/* for broadcast circuits, snpa should be compared */
/* FIXME : Do we need to check SNPA? */
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- if (snp_type == ISIS_SNP_CSNP_FLAG) {
- adj = isis_adj_lookup (chdr->source_id, circuit->u.bc.adjdb[level - 1]);
- } else {
- /* a psnp on a broadcast, how lovely of Juniper :) */
- adj = isis_adj_lookup (phdr->source_id, circuit->u.bc.adjdb[level - 1]);
- }
- if (!adj)
- return ISIS_OK; /* Silently discard */
- } else {
- if (!circuit->u.p2p.neighbor)
- return ISIS_OK; /* Silently discard */
- }
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ if (snp_type == ISIS_SNP_CSNP_FLAG)
+ {
+ adj =
+ isis_adj_lookup (chdr->source_id, circuit->u.bc.adjdb[level - 1]);
+ }
+ else
+ {
+ /* a psnp on a broadcast, how lovely of Juniper :) */
+ adj =
+ isis_adj_lookup (phdr->source_id, circuit->u.bc.adjdb[level - 1]);
+ }
+ if (!adj)
+ return ISIS_OK; /* Silently discard */
+ }
+ else
+ {
+ if (!circuit->u.p2p.neighbor)
+ return ISIS_OK; /* Silently discard */
+ }
/* 7.3.15.2 a) 8 - Passwords for level 1 - not implemented */
@@ -1246,163 +1399,183 @@ process_snp (int snp_type, int level, struct isis_circuit *circuit,
expected |= TLVFLAG_LSP_ENTRIES;
expected |= TLVFLAG_AUTH_INFO;
retval = parse_tlvs (circuit->area->area_tag,
- STREAM_PNT(circuit->rcv_stream),
+ STREAM_PNT (circuit->rcv_stream),
len - circuit->rcv_stream->getp,
- &expected,
- &found,
- &tlvs);
+ &expected, &found, &tlvs);
- if (retval > ISIS_WARNING) {
- zlog_warn ("something went very wrong processing SNP");
- free_tlvs (&tlvs);
- return retval;
- }
+ if (retval > ISIS_WARNING)
+ {
+ zlog_warn ("something went very wrong processing SNP");
+ free_tlvs (&tlvs);
+ return retval;
+ }
(level == 1) ? (passwd = &circuit->area->area_passwd) :
- (passwd = &circuit->area->domain_passwd);
- if (passwd->type) {
- if (!(found & TLVFLAG_AUTH_INFO) ||
- authentication_check (passwd, &tlvs.auth_info)) {
- isis_event_auth_failure (circuit->area->area_tag, "SNP authentication"
- " failure", phdr ?
- phdr->source_id : chdr->source_id);
- return ISIS_OK;
- }
- }
+ (passwd = &circuit->area->domain_passwd);
+ if (passwd->type)
+ {
+ if (!(found & TLVFLAG_AUTH_INFO) ||
+ authentication_check (passwd, &tlvs.auth_info))
+ {
+ isis_event_auth_failure (circuit->area->area_tag,
+ "SNP authentication" " failure",
+ phdr ? phdr->source_id : chdr->source_id);
+ return ISIS_OK;
+ }
+ }
/* debug isis snp-packets */
- if (isis->debugs & DEBUG_SNP_PACKETS) {
- zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s",
- circuit->area->area_tag,
- level,
- typechar,
- snpa_print(ssnpa),
- circuit->interface->name);
- if (tlvs.lsp_entries) {
- LIST_LOOP (tlvs.lsp_entries,entry,node) {
- zlog_info("ISIS-Snp (%s): %cSNP entry %s, seq 0x%08x,"
- " cksum 0x%04x, lifetime %us",
- circuit->area->area_tag,
- typechar,
- rawlspid_print (entry->lsp_id),
- ntohl (entry->seq_num),
- ntohs (entry->checksum),
- ntohs (entry->rem_lifetime));
- }
+ if (isis->debugs & DEBUG_SNP_PACKETS)
+ {
+ zlog_info ("ISIS-Snp (%s): Rcvd L%d %cSNP from %s on %s",
+ circuit->area->area_tag,
+ level,
+ typechar, snpa_print (ssnpa), circuit->interface->name);
+ if (tlvs.lsp_entries)
+ {
+ LIST_LOOP (tlvs.lsp_entries, entry, node)
+ {
+ zlog_info ("ISIS-Snp (%s): %cSNP entry %s, seq 0x%08x,"
+ " cksum 0x%04x, lifetime %us",
+ circuit->area->area_tag,
+ typechar,
+ rawlspid_print (entry->lsp_id),
+ ntohl (entry->seq_num),
+ ntohs (entry->checksum), ntohs (entry->rem_lifetime));
+ }
+ }
}
- }
/* 7.3.15.2 b) Actions on LSP_ENTRIES reported */
- if (tlvs.lsp_entries) {
- LIST_LOOP (tlvs.lsp_entries, entry, node) {
- lsp = lsp_search (entry->lsp_id, circuit->area->lspdb[level - 1]);
- own_lsp = !memcmp (entry->lsp_id, isis->sysid, ISIS_SYS_ID_LEN);
- if (lsp) {
- /* 7.3.15.2 b) 1) is this LSP newer */
- cmp = lsp_compare (circuit->area->area_tag, lsp, entry->seq_num,
- entry->checksum, entry->rem_lifetime);
- /* 7.3.15.2 b) 2) if it equals, clear SRM on p2p */
- if (cmp == LSP_EQUAL) {
- if (circuit->circ_type != CIRCUIT_T_BROADCAST)
- ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
- /* 7.3.15.2 b) 3) if it is older, clear SSN and set SRM */
- } else if (cmp == LSP_OLDER) {
- ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
- ISIS_SET_FLAG (lsp->SRMflags, circuit);
- } else {
- /* 7.3.15.2 b) 4) if it is newer, set SSN and clear SRM on p2p*/
- if (own_lsp) {
- lsp_inc_seqnum (lsp, ntohl (entry->seq_num));
- ISIS_SET_FLAG (lsp->SRMflags, circuit);
- } else {
- ISIS_SET_FLAG (lsp->SSNflags, circuit);
- if (circuit->circ_type != CIRCUIT_T_BROADCAST)
- ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
- }
- }
- } else {
- /* 7.3.15.2 b) 5) if it was not found, and all of those are not 0,
- * insert it and set SSN on it */
- if (entry->rem_lifetime && entry->checksum && entry->seq_num &&
- memcmp (entry->lsp_id, isis->sysid, ISIS_SYS_ID_LEN)) {
- lsp = lsp_new (entry->lsp_id, ntohs (entry->rem_lifetime),
- 0, 0, entry->checksum, level);
- lsp_insert (lsp, circuit->area->lspdb[level - 1]);
- ISIS_SET_FLAG (lsp->SSNflags, circuit);
- }
+ if (tlvs.lsp_entries)
+ {
+ LIST_LOOP (tlvs.lsp_entries, entry, node)
+ {
+ lsp = lsp_search (entry->lsp_id, circuit->area->lspdb[level - 1]);
+ own_lsp = !memcmp (entry->lsp_id, isis->sysid, ISIS_SYS_ID_LEN);
+ if (lsp)
+ {
+ /* 7.3.15.2 b) 1) is this LSP newer */
+ cmp = lsp_compare (circuit->area->area_tag, lsp, entry->seq_num,
+ entry->checksum, entry->rem_lifetime);
+ /* 7.3.15.2 b) 2) if it equals, clear SRM on p2p */
+ if (cmp == LSP_EQUAL)
+ {
+ if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+ ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+ /* 7.3.15.2 b) 3) if it is older, clear SSN and set SRM */
+ }
+ else if (cmp == LSP_OLDER)
+ {
+ ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
+ ISIS_SET_FLAG (lsp->SRMflags, circuit);
+ }
+ else
+ {
+ /* 7.3.15.2 b) 4) if it is newer, set SSN and clear SRM
+ * on p2p */
+ if (own_lsp)
+ {
+ lsp_inc_seqnum (lsp, ntohl (entry->seq_num));
+ ISIS_SET_FLAG (lsp->SRMflags, circuit);
+ }
+ else
+ {
+ ISIS_SET_FLAG (lsp->SSNflags, circuit);
+ if (circuit->circ_type != CIRCUIT_T_BROADCAST)
+ ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+ }
+ }
+ }
+ else
+ {
+ /* 7.3.15.2 b) 5) if it was not found, and all of those are not 0,
+ * insert it and set SSN on it */
+ if (entry->rem_lifetime && entry->checksum && entry->seq_num &&
+ memcmp (entry->lsp_id, isis->sysid, ISIS_SYS_ID_LEN))
+ {
+ lsp = lsp_new (entry->lsp_id, ntohs (entry->rem_lifetime),
+ 0, 0, entry->checksum, level);
+ lsp_insert (lsp, circuit->area->lspdb[level - 1]);
+ ISIS_SET_FLAG (lsp->SSNflags, circuit);
+ }
+ }
}
}
- }
/* 7.3.15.2 c) on CSNP set SRM for all in range which were not reported */
- if (snp_type == ISIS_SNP_CSNP_FLAG) {
- /*
- * Build a list from our own LSP db bounded with start_ and stop_lsp_id
- */
- lsp_list = list_new ();
- lsp_build_list_nonzero_ht (chdr->start_lsp_id, chdr->stop_lsp_id,
- lsp_list, circuit->area->lspdb[level - 1]);
-
- /* Fixme: Find a better solution */
- if (tlvs.lsp_entries) {
- LIST_LOOP (tlvs.lsp_entries, entry, node) {
- LIST_LOOP (lsp_list, lsp, node2) {
- if (lsp_id_cmp (lsp->lsp_header->lsp_id, entry->lsp_id) == 0) {
- list_delete_node (lsp_list, node2);
- break;
- }
- }
+ if (snp_type == ISIS_SNP_CSNP_FLAG)
+ {
+ /*
+ * Build a list from our own LSP db bounded with start_ and stop_lsp_id
+ */
+ lsp_list = list_new ();
+ lsp_build_list_nonzero_ht (chdr->start_lsp_id, chdr->stop_lsp_id,
+ lsp_list, circuit->area->lspdb[level - 1]);
+
+ /* Fixme: Find a better solution */
+ if (tlvs.lsp_entries)
+ {
+ LIST_LOOP (tlvs.lsp_entries, entry, node)
+ {
+ LIST_LOOP (lsp_list, lsp, node2)
+ {
+ if (lsp_id_cmp (lsp->lsp_header->lsp_id, entry->lsp_id) == 0)
+ {
+ list_delete_node (lsp_list, node2);
+ break;
+ }
+ }
+ }
+ }
+ /* on remaining LSPs we set SRM (neighbor knew not of) */
+ LIST_LOOP (lsp_list, lsp, node2)
+ {
+ ISIS_SET_FLAG (lsp->SRMflags, circuit);
}
+ /* lets free it */
+ list_free (lsp_list);
}
- /* on remaining LSPs we set SRM (neighbor knew not of) */
- LIST_LOOP (lsp_list, lsp, node2) {
- ISIS_SET_FLAG (lsp->SRMflags, circuit);
- }
- /* lets free it */
- list_free (lsp_list);
- }
free_tlvs (&tlvs);
return retval;
}
int
-process_csnp (int level, struct isis_circuit *circuit, u_char *ssnpa)
+process_csnp (int level, struct isis_circuit *circuit, u_char * ssnpa)
{
-
/* Sanity check - FIXME: move to correct place */
- if ((stream_get_endp (circuit->rcv_stream) -
- stream_get_getp (circuit->rcv_stream)) < ISIS_CSNP_HDRLEN) {
- zlog_warn ("Packet too short ( < %d)", ISIS_CSNP_HDRLEN);
- return ISIS_WARNING;
- }
+ if ((stream_get_endp (circuit->rcv_stream) -
+ stream_get_getp (circuit->rcv_stream)) < ISIS_CSNP_HDRLEN)
+ {
+ zlog_warn ("Packet too short ( < %d)", ISIS_CSNP_HDRLEN);
+ return ISIS_WARNING;
+ }
return process_snp (ISIS_SNP_CSNP_FLAG, level, circuit, ssnpa);
}
-int
-process_psnp (int level, struct isis_circuit *circuit, u_char *ssnpa)
+int
+process_psnp (int level, struct isis_circuit *circuit, u_char * ssnpa)
{
-
- if ((stream_get_endp (circuit->rcv_stream) -
- stream_get_getp (circuit->rcv_stream)) < ISIS_PSNP_HDRLEN) {
- zlog_warn ("Packet too short");
- return ISIS_WARNING;
- }
+ if ((stream_get_endp (circuit->rcv_stream) -
+ stream_get_getp (circuit->rcv_stream)) < ISIS_PSNP_HDRLEN)
+ {
+ zlog_warn ("Packet too short");
+ return ISIS_WARNING;
+ }
return process_snp (ISIS_SNP_PSNP_FLAG, level, circuit, ssnpa);
}
-
-
/*
* Process ISH
* ISO - 10589
* Section 8.2.2 - Receiving ISH PDUs by an intermediate system
* FIXME: sample packet dump, need to figure 0x81 - looks like NLPid
- 0x82 0x15 0x01 0x00 0x04 0x01 0x2c 0x59
- 0x38 0x08 0x47 0x00 0x01 0x00 0x02 0x00
- 0x03 0x00 0x81 0x01 0xcc
+ * 0x82 0x15 0x01 0x00 0x04 0x01 0x2c 0x59
+ * 0x38 0x08 0x47 0x00 0x01 0x00 0x02 0x00
+ * 0x03 0x00 0x81 0x01 0xcc
*/
int
process_is_hello (struct isis_circuit *circuit)
@@ -1419,172 +1592,185 @@ process_is_hello (struct isis_circuit *circuit)
return retval;
neigh_len = stream_getc (circuit->rcv_stream);
- sysid = STREAM_PNT(circuit->rcv_stream) + neigh_len - 1 - ISIS_SYS_ID_LEN;
+ sysid = STREAM_PNT (circuit->rcv_stream) + neigh_len - 1 - ISIS_SYS_ID_LEN;
adj = circuit->u.p2p.neighbor;
- if (!adj) {
- /* 8.2.2 */
- adj = isis_new_adj (sysid, " ", 0, circuit);
- if (adj == NULL)
- return ISIS_ERROR;
-
- isis_adj_state_change (adj, ISIS_ADJ_INITIALIZING, NULL);
- adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
- circuit->u.p2p.neighbor = adj;
- }
- /* 8.2.2 a)*/
- if ((adj->adj_state == ISIS_ADJ_UP) && memcmp (adj->sysid,sysid,
- ISIS_SYS_ID_LEN)) {
- /* 8.2.2 a) 1) FIXME: adjStateChange(down) event */
- /* 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, " ", 0, circuit);
- if (adj == NULL)
- return ISIS_ERROR;
+ if (!adj)
+ {
+ /* 8.2.2 */
+ adj = isis_new_adj (sysid, " ", 0, circuit);
+ if (adj == NULL)
+ return ISIS_ERROR;
- /* 8.2.2 a) 3) i */
- isis_adj_state_change (adj, ISIS_ADJ_INITIALIZING, NULL);
- /* 8.2.2 a) 3) ii */
- adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
- /* 8.2.2 a) 4) quite meaningless */
- }
+ isis_adj_state_change (adj, ISIS_ADJ_INITIALIZING, NULL);
+ adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
+ circuit->u.p2p.neighbor = adj;
+ }
+ /* 8.2.2 a) */
+ if ((adj->adj_state == ISIS_ADJ_UP) && memcmp (adj->sysid, sysid,
+ ISIS_SYS_ID_LEN))
+ {
+ /* 8.2.2 a) 1) FIXME: adjStateChange(down) event */
+ /* 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, " ", 0, circuit);
+ if (adj == NULL)
+ return ISIS_ERROR;
+
+ /* 8.2.2 a) 3) i */
+ isis_adj_state_change (adj, ISIS_ADJ_INITIALIZING, NULL);
+ /* 8.2.2 a) 3) ii */
+ adj->sys_type = ISIS_SYSTYPE_UNKNOWN;
+ /* 8.2.2 a) 4) quite meaningless */
+ }
/* 8.2.2 b) ignore on condition */
- if ((adj->adj_state == ISIS_ADJ_INITIALIZING) &&
- (adj->sys_type == ISIS_SYSTYPE_IS)) {
- /* do nothing */
- } else {
- /* 8.2.2 c) respond with a p2p IIH */
- send_hello (circuit, 1);
- }
+ if ((adj->adj_state == ISIS_ADJ_INITIALIZING) &&
+ (adj->sys_type == ISIS_SYSTYPE_IS))
+ {
+ /* do nothing */
+ }
+ else
+ {
+ /* 8.2.2 c) respond with a p2p IIH */
+ send_hello (circuit, 1);
+ }
/* 8.2.2 d) type is IS */
- adj->sys_type = ISIS_SYSTYPE_IS;
+ adj->sys_type = ISIS_SYSTYPE_IS;
/* 8.2.2 e) FIXME: Circuit type of? */
-
return retval;
}
-
/*
* PDU Dispatcher
*/
-int
-isis_handle_pdu (struct isis_circuit *circuit, u_char *ssnpa)
+int
+isis_handle_pdu (struct isis_circuit *circuit, u_char * ssnpa)
{
-
struct isis_fixed_hdr *hdr;
struct esis_fixed_hdr *esis_hdr;
- int retval=ISIS_OK;
+ int retval = ISIS_OK;
/*
* Let's first read data from stream to the header
*/
- hdr = (struct isis_fixed_hdr*)STREAM_DATA(circuit->rcv_stream);
+ hdr = (struct isis_fixed_hdr *) STREAM_DATA (circuit->rcv_stream);
- if ((hdr->idrp != ISO10589_ISIS) && (hdr->idrp != ISO9542_ESIS)){
- zlog_warn ("Not an IS-IS or ES-IS packet IDRP=%02x", hdr->idrp);
- return ISIS_ERROR;
- }
+ if ((hdr->idrp != ISO10589_ISIS) && (hdr->idrp != ISO9542_ESIS))
+ {
+ zlog_warn ("Not an IS-IS or ES-IS packet IDRP=%02x", hdr->idrp);
+ return ISIS_ERROR;
+ }
/* now we need to know if this is an ISO 9542 packet and
* take real good care of it, waaa!
*/
- if (hdr->idrp == ISO9542_ESIS){
- esis_hdr = (struct esis_fixed_hdr*)STREAM_DATA(circuit->rcv_stream);
- stream_set_getp (circuit->rcv_stream, ESIS_FIXED_HDR_LEN);
- /* FIXME: Need to do some acceptence tests */
- /* example length... */
- switch (esis_hdr->pdu_type) {
- case ESH_PDU:
- /* FIXME */
- break;
- case ISH_PDU:
- zlog_info ("AN ISH PDU!!");
- retval = process_is_hello (circuit);
- break;
- default:
- return ISIS_ERROR;
- }
- return retval;
- } else {
- stream_set_getp (circuit->rcv_stream, ISIS_FIXED_HDR_LEN);
- }
+ if (hdr->idrp == ISO9542_ESIS)
+ {
+ esis_hdr = (struct esis_fixed_hdr *) STREAM_DATA (circuit->rcv_stream);
+ stream_set_getp (circuit->rcv_stream, ESIS_FIXED_HDR_LEN);
+ /* FIXME: Need to do some acceptence tests */
+ /* example length... */
+ switch (esis_hdr->pdu_type)
+ {
+ case ESH_PDU:
+ /* FIXME */
+ break;
+ case ISH_PDU:
+ zlog_info ("AN ISH PDU!!");
+ retval = process_is_hello (circuit);
+ break;
+ default:
+ return ISIS_ERROR;
+ }
+ return retval;
+ }
+ else
+ {
+ stream_set_getp (circuit->rcv_stream, ISIS_FIXED_HDR_LEN);
+ }
/*
* and then process it
*/
- if (hdr->length < ISIS_MINIMUM_FIXED_HDR_LEN) {
- zlog_err ("Fixed header length = %d", hdr->length);
- return ISIS_ERROR;
- }
+ if (hdr->length < ISIS_MINIMUM_FIXED_HDR_LEN)
+ {
+ zlog_err ("Fixed header length = %d", hdr->length);
+ return ISIS_ERROR;
+ }
- if (hdr->version1 != 1) {
- zlog_warn ("Unsupported ISIS version %u", hdr->version1);
- return ISIS_WARNING;
- }
+ if (hdr->version1 != 1)
+ {
+ zlog_warn ("Unsupported ISIS version %u", hdr->version1);
+ return ISIS_WARNING;
+ }
/* either 6 or 0 */
- if ((hdr->id_len != 0) && (hdr->id_len != ISIS_SYS_ID_LEN)) {
- zlog_err ("IDFieldLengthMismatch: ID Length field in a received PDU %u, "
- "while the parameter for this IS is %u", hdr->id_len,
- ISIS_SYS_ID_LEN);
- return ISIS_ERROR;
- }
+ if ((hdr->id_len != 0) && (hdr->id_len != ISIS_SYS_ID_LEN))
+ {
+ zlog_err
+ ("IDFieldLengthMismatch: ID Length field in a received PDU %u, "
+ "while the parameter for this IS is %u", hdr->id_len,
+ ISIS_SYS_ID_LEN);
+ return ISIS_ERROR;
+ }
- if (hdr->version2 != 1) {
- zlog_warn ("Unsupported ISIS version %u", hdr->version2);
- return ISIS_WARNING;
- }
+ if (hdr->version2 != 1)
+ {
+ zlog_warn ("Unsupported ISIS version %u", hdr->version2);
+ return ISIS_WARNING;
+ }
/* either 3 or 0 */
- if ((hdr->max_area_addrs != 0) && (hdr->max_area_addrs != isis->max_area_addrs)) {
- zlog_err ("maximumAreaAddressesMismatch: maximumAreaAdresses in a "
- "received PDU %u while the parameter for this IS is %u",
- hdr->max_area_addrs, isis->max_area_addrs);
- return ISIS_ERROR;
- }
+ if ((hdr->max_area_addrs != 0)
+ && (hdr->max_area_addrs != isis->max_area_addrs))
+ {
+ zlog_err ("maximumAreaAddressesMismatch: maximumAreaAdresses in a "
+ "received PDU %u while the parameter for this IS is %u",
+ hdr->max_area_addrs, isis->max_area_addrs);
+ return ISIS_ERROR;
+ }
- switch (hdr->pdu_type) {
- case L1_LAN_HELLO:
- retval = process_lan_hello (ISIS_LEVEL1, circuit, ssnpa);
- break;
- case L2_LAN_HELLO:
- retval = process_lan_hello (ISIS_LEVEL2, circuit, ssnpa);
- break;
- case P2P_HELLO:
- retval = process_p2p_hello (circuit);
- break;
- case L1_LINK_STATE:
- retval = process_lsp (ISIS_LEVEL1, circuit, ssnpa);
- break;
- case L2_LINK_STATE:
- retval = process_lsp (ISIS_LEVEL2, circuit, ssnpa);
- break;
- case L1_COMPLETE_SEQ_NUM:
- retval = process_csnp (ISIS_LEVEL1, circuit, ssnpa);
- break;
- case L2_COMPLETE_SEQ_NUM:
- retval = process_csnp (ISIS_LEVEL2, circuit, ssnpa);
- break;
- case L1_PARTIAL_SEQ_NUM:
- retval = process_psnp (ISIS_LEVEL1, circuit, ssnpa);
- break;
- case L2_PARTIAL_SEQ_NUM:
- retval = process_psnp (ISIS_LEVEL2, circuit, ssnpa);
- break;
- default:
- return ISIS_ERROR;
- }
+ switch (hdr->pdu_type)
+ {
+ case L1_LAN_HELLO:
+ retval = process_lan_hello (ISIS_LEVEL1, circuit, ssnpa);
+ break;
+ case L2_LAN_HELLO:
+ retval = process_lan_hello (ISIS_LEVEL2, circuit, ssnpa);
+ break;
+ case P2P_HELLO:
+ retval = process_p2p_hello (circuit);
+ break;
+ case L1_LINK_STATE:
+ retval = process_lsp (ISIS_LEVEL1, circuit, ssnpa);
+ break;
+ case L2_LINK_STATE:
+ retval = process_lsp (ISIS_LEVEL2, circuit, ssnpa);
+ break;
+ case L1_COMPLETE_SEQ_NUM:
+ retval = process_csnp (ISIS_LEVEL1, circuit, ssnpa);
+ break;
+ case L2_COMPLETE_SEQ_NUM:
+ retval = process_csnp (ISIS_LEVEL2, circuit, ssnpa);
+ break;
+ case L1_PARTIAL_SEQ_NUM:
+ retval = process_psnp (ISIS_LEVEL1, circuit, ssnpa);
+ break;
+ case L2_PARTIAL_SEQ_NUM:
+ retval = process_psnp (ISIS_LEVEL2, circuit, ssnpa);
+ break;
+ default:
+ return ISIS_ERROR;
+ }
return retval;
}
-
#ifdef GNU_LINUX
int
isis_receive (struct thread *thread)
{
-
struct isis_circuit *circuit;
u_char ssnpa[ETH_ALEN];
int retval;
@@ -1596,12 +1782,12 @@ isis_receive (struct thread *thread)
assert (circuit);
if (circuit->rcv_stream == NULL)
- circuit->rcv_stream = stream_new (ISO_MTU(circuit));
+ circuit->rcv_stream = stream_new (ISO_MTU (circuit));
else
stream_reset (circuit->rcv_stream);
retval = circuit->rx (circuit, ssnpa);
- circuit->t_read = NULL;
+ circuit->t_read = NULL;
if (retval == ISIS_OK)
retval = isis_handle_pdu (circuit, ssnpa);
@@ -1609,7 +1795,8 @@ isis_receive (struct thread *thread)
/*
* prepare for next packet.
*/
- THREAD_READ_ON(master, circuit->t_read, isis_receive, circuit, circuit->fd);
+ THREAD_READ_ON (master, circuit->t_read, isis_receive, circuit,
+ circuit->fd);
return retval;
}
@@ -1618,7 +1805,6 @@ isis_receive (struct thread *thread)
int
isis_receive (struct thread *thread)
{
-
struct isis_circuit *circuit;
u_char ssnpa[ETH_ALEN];
int retval;
@@ -1629,10 +1815,10 @@ isis_receive (struct thread *thread)
circuit = THREAD_ARG (thread);
assert (circuit);
- circuit->t_read = NULL;
+ circuit->t_read = NULL;
if (circuit->rcv_stream == NULL)
- circuit->rcv_stream = stream_new (ISO_MTU(circuit));
+ circuit->rcv_stream = stream_new (ISO_MTU (circuit));
else
stream_reset (circuit->rcv_stream);
@@ -1644,10 +1830,10 @@ isis_receive (struct thread *thread)
/*
* prepare for next packet.
*/
- circuit->t_read = thread_add_timer_msec (master, isis_receive, circuit,
- listcount
- (circuit->area->circuit_list)*100);
-
+ circuit->t_read = thread_add_timer_msec (master, isis_receive, circuit,
+ listcount
+ (circuit->area->circuit_list) *
+ 100);
return retval;
}
@@ -1662,47 +1848,47 @@ fill_fixed_hdr (struct isis_fixed_hdr *hdr, u_char pdu_type)
hdr->idrp = ISO10589_ISIS;
- switch (pdu_type) {
- case L1_LAN_HELLO:
- case L2_LAN_HELLO:
- hdr->length = ISIS_LANHELLO_HDRLEN;
- break;
- case P2P_HELLO:
- hdr->length = ISIS_P2PHELLO_HDRLEN;
- break;
- case L1_LINK_STATE:
- case L2_LINK_STATE:
- hdr->length = ISIS_LSP_HDR_LEN;
- break;
- case L1_COMPLETE_SEQ_NUM:
- case L2_COMPLETE_SEQ_NUM:
- hdr->length = ISIS_CSNP_HDRLEN;
- break;
- case L1_PARTIAL_SEQ_NUM:
- case L2_PARTIAL_SEQ_NUM:
- hdr->length = ISIS_PSNP_HDRLEN;
- break;
- default:
- zlog_warn ("fill_fixed_hdr(): unknown pdu type %d", pdu_type);
- return;
- }
+ switch (pdu_type)
+ {
+ case L1_LAN_HELLO:
+ case L2_LAN_HELLO:
+ hdr->length = ISIS_LANHELLO_HDRLEN;
+ break;
+ case P2P_HELLO:
+ hdr->length = ISIS_P2PHELLO_HDRLEN;
+ break;
+ case L1_LINK_STATE:
+ case L2_LINK_STATE:
+ hdr->length = ISIS_LSP_HDR_LEN;
+ break;
+ case L1_COMPLETE_SEQ_NUM:
+ case L2_COMPLETE_SEQ_NUM:
+ hdr->length = ISIS_CSNP_HDRLEN;
+ break;
+ case L1_PARTIAL_SEQ_NUM:
+ case L2_PARTIAL_SEQ_NUM:
+ hdr->length = ISIS_PSNP_HDRLEN;
+ break;
+ default:
+ zlog_warn ("fill_fixed_hdr(): unknown pdu type %d", pdu_type);
+ return;
+ }
hdr->length += ISIS_FIXED_HDR_LEN;
hdr->pdu_type = pdu_type;
hdr->version1 = 1;
- hdr->id_len = 0; /* ISIS_SYS_ID_LEN - 0==6 */
+ hdr->id_len = 0; /* ISIS_SYS_ID_LEN - 0==6 */
hdr->version2 = 1;
- hdr->max_area_addrs = 0; /* isis->max_area_addrs - 0==3 */
+ hdr->max_area_addrs = 0; /* isis->max_area_addrs - 0==3 */
}
-
/*
* SEND SIDE
*/
void
fill_fixed_hdr_andstream (struct isis_fixed_hdr *hdr, u_char pdu_type,
- struct stream *stream)
+ struct stream *stream)
{
- fill_fixed_hdr (hdr,pdu_type);
+ fill_fixed_hdr (hdr, pdu_type);
stream_putc (stream, hdr->idrp);
stream_putc (stream, hdr->length);
@@ -1716,7 +1902,6 @@ fill_fixed_hdr_andstream (struct isis_fixed_hdr *hdr, u_char pdu_type,
return;
}
-
int
send_hello (struct isis_circuit *circuit, int level)
{
@@ -1728,55 +1913,65 @@ send_hello (struct isis_circuit *circuit, int level)
unsigned long len_pointer, length;
int retval;
- if (circuit->interface->mtu == 0) {
- zlog_warn ("circuit has zero MTU");
- return ISIS_WARNING;
- }
+ if (circuit->interface->mtu == 0)
+ {
+ zlog_warn ("circuit has zero MTU");
+ return ISIS_WARNING;
+ }
if (!circuit->snd_stream)
- circuit->snd_stream = stream_new (ISO_MTU(circuit));
+ circuit->snd_stream = stream_new (ISO_MTU (circuit));
else
stream_reset (circuit->snd_stream);
if (circuit->circ_type == CIRCUIT_T_BROADCAST)
if (level == 1)
- fill_fixed_hdr_andstream(&fixed_hdr, L1_LAN_HELLO, circuit->snd_stream);
+ fill_fixed_hdr_andstream (&fixed_hdr, L1_LAN_HELLO,
+ circuit->snd_stream);
else
- fill_fixed_hdr_andstream(&fixed_hdr, L2_LAN_HELLO, circuit->snd_stream);
+ fill_fixed_hdr_andstream (&fixed_hdr, L2_LAN_HELLO,
+ circuit->snd_stream);
else
- fill_fixed_hdr_andstream(&fixed_hdr, P2P_HELLO, circuit->snd_stream);
+ fill_fixed_hdr_andstream (&fixed_hdr, P2P_HELLO, circuit->snd_stream);
/*
* Fill LAN Level 1 or 2 Hello PDU header
*/
memset (&hello_hdr, 0, sizeof (struct isis_lan_hello_hdr));
- interval = circuit->hello_multiplier[level - 1] *
+ interval = circuit->hello_multiplier[level - 1] *
circuit->hello_interval[level - 1];
if (interval > USHRT_MAX)
interval = USHRT_MAX;
hello_hdr.circuit_t = circuit->circuit_is_type;
memcpy (hello_hdr.source_id, isis->sysid, ISIS_SYS_ID_LEN);
- hello_hdr.hold_time = htons((u_int16_t)interval);
-
- hello_hdr.pdu_len = 0; /* Update the PDU Length later */
- len_pointer = stream_get_putp (circuit->snd_stream) + 3 + ISIS_SYS_ID_LEN;
+ hello_hdr.hold_time = htons ((u_int16_t) interval);
+ hello_hdr.pdu_len = 0; /* Update the PDU Length later */
+ len_pointer = stream_get_putp (circuit->snd_stream) + 3 + ISIS_SYS_ID_LEN;
/* copy the shared part of the hello to the p2p hello if needed */
- if (circuit->circ_type == CIRCUIT_T_P2P) {
- memcpy (&p2p_hello_hdr, &hello_hdr, 5 + ISIS_SYS_ID_LEN);
- p2p_hello_hdr.local_id = circuit->circuit_id;
- /* FIXME: need better understanding */
- stream_put (circuit->snd_stream, &p2p_hello_hdr, ISIS_P2PHELLO_HDRLEN);
- } else {
- hello_hdr.prio = circuit->u.bc.priority[level - 1];
- if(level == 1 && circuit->u.bc.l1_desig_is) {
- memcpy(hello_hdr.lan_id, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
- } else if (level == 2 && circuit->u.bc.l2_desig_is){
- memcpy(hello_hdr.lan_id, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
- }
- stream_put (circuit->snd_stream, &hello_hdr, ISIS_LANHELLO_HDRLEN);
- }
+ if (circuit->circ_type == CIRCUIT_T_P2P)
+ {
+ memcpy (&p2p_hello_hdr, &hello_hdr, 5 + ISIS_SYS_ID_LEN);
+ p2p_hello_hdr.local_id = circuit->circuit_id;
+ /* FIXME: need better understanding */
+ stream_put (circuit->snd_stream, &p2p_hello_hdr, ISIS_P2PHELLO_HDRLEN);
+ }
+ else
+ {
+ hello_hdr.prio = circuit->u.bc.priority[level - 1];
+ if (level == 1 && circuit->u.bc.l1_desig_is)
+ {
+ memcpy (hello_hdr.lan_id, circuit->u.bc.l1_desig_is,
+ ISIS_SYS_ID_LEN + 1);
+ }
+ else if (level == 2 && circuit->u.bc.l2_desig_is)
+ {
+ memcpy (hello_hdr.lan_id, circuit->u.bc.l2_desig_is,
+ ISIS_SYS_ID_LEN + 1);
+ }
+ stream_put (circuit->snd_stream, &hello_hdr, ISIS_LANHELLO_HDRLEN);
+ }
/*
* Then the variable length part
@@ -1793,19 +1988,20 @@ send_hello (struct isis_circuit *circuit, int level)
return ISIS_WARNING;
/* LAN Neighbors TLV */
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- if (level == 1 && circuit->u.bc.lan_neighs[0]->count > 0)
- if (tlv_add_lan_neighs (circuit->u.bc.lan_neighs[0],
- circuit->snd_stream))
- return ISIS_WARNING;
- if (level == 2 && circuit->u.bc.lan_neighs[1]->count > 0)
- if (tlv_add_lan_neighs (circuit->u.bc.lan_neighs[1],
- circuit->snd_stream))
- return ISIS_WARNING;
- }
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ if (level == 1 && circuit->u.bc.lan_neighs[0]->count > 0)
+ if (tlv_add_lan_neighs (circuit->u.bc.lan_neighs[0],
+ circuit->snd_stream))
+ return ISIS_WARNING;
+ if (level == 2 && circuit->u.bc.lan_neighs[1]->count > 0)
+ if (tlv_add_lan_neighs (circuit->u.bc.lan_neighs[1],
+ circuit->snd_stream))
+ return ISIS_WARNING;
+ }
/* Protocols Supported TLV */
- if (circuit->nlpids.count > 0)
+ if (circuit->nlpids.count > 0)
if (tlv_add_nlpid (&circuit->nlpids, circuit->snd_stream))
return ISIS_WARNING;
/* IP interface Address TLV */
@@ -1813,9 +2009,9 @@ send_hello (struct isis_circuit *circuit, int level)
if (tlv_add_ip_addrs (circuit->ip_addrs, circuit->snd_stream))
return ISIS_WARNING;
-#ifdef HAVE_IPV6
+#ifdef HAVE_IPV6
/* IPv6 Interface Address TLV */
- if (circuit->ipv6_router && circuit->ipv6_link &&
+ if (circuit->ipv6_router && circuit->ipv6_link &&
circuit->ipv6_link->count > 0)
if (tlv_add_ipv6_addrs (circuit->ipv6_link, circuit->snd_stream))
return ISIS_WARNING;
@@ -1827,25 +2023,28 @@ send_hello (struct isis_circuit *circuit, int level)
length = stream_get_putp (circuit->snd_stream);
/* Update PDU length */
- stream_putw_at (circuit->snd_stream, len_pointer, (u_int16_t)length);
+ stream_putw_at (circuit->snd_stream, len_pointer, (u_int16_t) length);
retval = circuit->tx (circuit, level);
if (retval)
zlog_warn ("sending of LAN Level %d Hello failed", level);
/* DEBUG_ADJ_PACKETS */
- if (isis->debugs & DEBUG_ADJ_PACKETS) {
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- zlog_info ("ISIS-Adj (%s): Sent L%d LAN IIH on %s, length %ld",
- circuit->area->area_tag, level, circuit->interface->name,
- STREAM_SIZE(circuit->snd_stream));
- } else {
- zlog_info ("ISIS-Adj (%s): Sent P2P IIH on %s, length %ld",
- circuit->area->area_tag, circuit->interface->name,
- STREAM_SIZE(circuit->snd_stream));
+ if (isis->debugs & DEBUG_ADJ_PACKETS)
+ {
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ zlog_info ("ISIS-Adj (%s): Sent L%d LAN IIH on %s, length %ld",
+ circuit->area->area_tag, level, circuit->interface->name,
+ STREAM_SIZE (circuit->snd_stream));
+ }
+ else
+ {
+ zlog_info ("ISIS-Adj (%s): Sent P2P IIH on %s, length %ld",
+ circuit->area->area_tag, circuit->interface->name,
+ STREAM_SIZE (circuit->snd_stream));
+ }
}
- }
-
return retval;
}
@@ -1853,13 +2052,12 @@ send_hello (struct isis_circuit *circuit, int level)
int
send_lan_hello (struct isis_circuit *circuit, int level)
{
- return send_hello (circuit,level);
+ return send_hello (circuit, level);
}
int
send_lan_l1_hello (struct thread *thread)
{
-
struct isis_circuit *circuit;
int retval;
@@ -1868,13 +2066,14 @@ send_lan_l1_hello (struct thread *thread)
circuit->u.bc.t_send_lan_hello[0] = NULL;
if (circuit->u.bc.run_dr_elect[0])
- retval = isis_dr_elect (circuit, 1);
+ retval = isis_dr_elect (circuit, 1);
retval = send_lan_hello (circuit, 1);
/* set next timer thread */
- 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));
+ 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));
return retval;
}
@@ -1894,9 +2093,10 @@ send_lan_l2_hello (struct thread *thread)
retval = send_lan_hello (circuit, 2);
- /* set next timer thread*/
- 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));
+ /* set next timer thread */
+ 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));
return retval;
}
@@ -1910,18 +2110,19 @@ send_p2p_hello (struct thread *thread)
assert (circuit);
circuit->u.p2p.t_send_p2p_hello = NULL;
- send_hello(circuit,1);
+ send_hello (circuit, 1);
- /* set next timer thread*/
- THREAD_TIMER_ON(master, circuit->u.p2p.t_send_p2p_hello, send_p2p_hello,
- circuit, isis_jitter (circuit->hello_interval[1], IIH_JITTER));
+ /* set next timer thread */
+ THREAD_TIMER_ON (master, circuit->u.p2p.t_send_p2p_hello, send_p2p_hello,
+ circuit, isis_jitter (circuit->hello_interval[1],
+ IIH_JITTER));
return ISIS_OK;
}
int
-build_csnp (int level, u_char *start, u_char *stop, struct list *lsps,
- struct isis_circuit *circuit)
+build_csnp (int level, u_char * start, u_char * stop, struct list *lsps,
+ struct isis_circuit *circuit)
{
struct isis_fixed_hdr fixed_hdr;
struct isis_passwd *passwd;
@@ -1929,19 +2130,19 @@ build_csnp (int level, u_char *start, u_char *stop, struct list *lsps,
unsigned long lenp;
u_int16_t length;
- if (level ==1)
- fill_fixed_hdr_andstream (&fixed_hdr, L1_COMPLETE_SEQ_NUM,
- circuit->snd_stream);
+ if (level == 1)
+ fill_fixed_hdr_andstream (&fixed_hdr, L1_COMPLETE_SEQ_NUM,
+ circuit->snd_stream);
else
- fill_fixed_hdr_andstream (&fixed_hdr, L2_COMPLETE_SEQ_NUM,
- circuit->snd_stream);
+ fill_fixed_hdr_andstream (&fixed_hdr, L2_COMPLETE_SEQ_NUM,
+ circuit->snd_stream);
/*
* Fill Level 1 or 2 Complete Sequence Numbers header
*/
lenp = stream_get_putp (circuit->snd_stream);
- stream_putw (circuit->snd_stream, 0); /* PDU length - when we know it */
+ stream_putw (circuit->snd_stream, 0); /* PDU length - when we know it */
/* no need to send the source here, it is always us if we csnp */
stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
/* with zero circuit id - ref 9.10, 9.11 */
@@ -1962,10 +2163,11 @@ build_csnp (int level, u_char *start, u_char *stop, struct list *lsps,
retval = tlv_add_authinfo (passwd->type, passwd->len,
passwd->passwd, circuit->snd_stream);
- if (!retval && lsps) {
- retval = tlv_add_lsp_entries (lsps, circuit->snd_stream);
- }
- length = (u_int16_t)stream_get_putp (circuit->snd_stream);
+ if (!retval && lsps)
+ {
+ retval = tlv_add_lsp_entries (lsps, circuit->snd_stream);
+ }
+ length = (u_int16_t) stream_get_putp (circuit->snd_stream);
assert (length >= ISIS_CSNP_HDRLEN);
/* Update PU length */
stream_putw_at (circuit->snd_stream, lenp, length);
@@ -1987,41 +2189,44 @@ send_csnp (struct isis_circuit *circuit, int level)
struct listnode *node;
struct isis_lsp *lsp;
- memset (start,0x00, ISIS_SYS_ID_LEN + 2);
+ memset (start, 0x00, ISIS_SYS_ID_LEN + 2);
memset (stop, 0xff, ISIS_SYS_ID_LEN + 2);
- if (circuit->area->lspdb[level-1] &&
- dict_count (circuit->area->lspdb[level-1]) > 0) {
- list = list_new ();
- lsp_build_list (start, stop, list, circuit->area->lspdb[level-1]);
-
- if (circuit->snd_stream == NULL)
- circuit->snd_stream = stream_new (ISO_MTU(circuit));
- else
- stream_reset (circuit->snd_stream);
-
- retval = build_csnp (level, start, stop, list, circuit);
-
- if (isis->debugs & DEBUG_SNP_PACKETS) {
- zlog_info ("ISIS-Snp (%s): Sent L%d CSNP on %s, length %ld",
- circuit->area->area_tag, level, circuit->interface->name,
- STREAM_SIZE(circuit->snd_stream));
- LIST_LOOP (list, lsp, node) {
- zlog_info("ISIS-Snp (%s): CSNP entry %s, seq 0x%08x,"
- " cksum 0x%04x, lifetime %us",
- circuit->area->area_tag,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl (lsp->lsp_header->seq_num),
- ntohs (lsp->lsp_header->checksum),
- ntohs (lsp->lsp_header->rem_lifetime));
- }
- }
+ if (circuit->area->lspdb[level - 1] &&
+ dict_count (circuit->area->lspdb[level - 1]) > 0)
+ {
+ list = list_new ();
+ lsp_build_list (start, stop, list, circuit->area->lspdb[level - 1]);
+
+ if (circuit->snd_stream == NULL)
+ circuit->snd_stream = stream_new (ISO_MTU (circuit));
+ else
+ stream_reset (circuit->snd_stream);
+
+ retval = build_csnp (level, start, stop, list, circuit);
+
+ if (isis->debugs & DEBUG_SNP_PACKETS)
+ {
+ zlog_info ("ISIS-Snp (%s): Sent L%d CSNP on %s, length %ld",
+ circuit->area->area_tag, level, circuit->interface->name,
+ STREAM_SIZE (circuit->snd_stream));
+ LIST_LOOP (list, lsp, node)
+ {
+ zlog_info ("ISIS-Snp (%s): CSNP entry %s, seq 0x%08x,"
+ " cksum 0x%04x, lifetime %us",
+ circuit->area->area_tag,
+ rawlspid_print (lsp->lsp_header->lsp_id),
+ ntohl (lsp->lsp_header->seq_num),
+ ntohs (lsp->lsp_header->checksum),
+ ntohs (lsp->lsp_header->rem_lifetime));
+ }
+ }
- list_delete (list);
+ list_delete (list);
- if (retval == ISIS_OK)
- retval = circuit->tx (circuit, level);
- }
+ if (retval == ISIS_OK)
+ retval = circuit->tx (circuit, level);
+ }
return retval;
}
@@ -2036,12 +2241,13 @@ send_l1_csnp (struct thread *thread)
circuit->t_send_csnp[0] = NULL;
- if (circuit->circ_type == CIRCUIT_T_BROADCAST && circuit->u.bc.is_dr[0]) {
- send_csnp(circuit,1);
- }
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST && circuit->u.bc.is_dr[0])
+ {
+ send_csnp (circuit, 1);
+ }
/* set next timer thread */
- THREAD_TIMER_ON(master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
- isis_jitter(circuit->csnp_interval[0], CSNP_JITTER));
+ THREAD_TIMER_ON (master, circuit->t_send_csnp[0], send_l1_csnp, circuit,
+ isis_jitter (circuit->csnp_interval[0], CSNP_JITTER));
return retval;
}
@@ -2057,12 +2263,13 @@ send_l2_csnp (struct thread *thread)
circuit->t_send_csnp[1] = NULL;
- if (circuit->circ_type == CIRCUIT_T_BROADCAST && circuit->u.bc.is_dr[1]) {
- send_csnp(circuit,2);
- }
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST && circuit->u.bc.is_dr[1])
+ {
+ send_csnp (circuit, 2);
+ }
/* set next timer thread */
- THREAD_TIMER_ON(master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
- isis_jitter(circuit->csnp_interval[1], CSNP_JITTER));
+ THREAD_TIMER_ON (master, circuit->t_send_csnp[1], send_l2_csnp, circuit,
+ isis_jitter (circuit->csnp_interval[1], CSNP_JITTER));
return retval;
}
@@ -2079,17 +2286,17 @@ build_psnp (int level, struct isis_circuit *circuit, struct list *lsps)
struct listnode *node;
if (level == 1)
- fill_fixed_hdr_andstream (&fixed_hdr, L1_PARTIAL_SEQ_NUM,
- circuit->snd_stream);
+ fill_fixed_hdr_andstream (&fixed_hdr, L1_PARTIAL_SEQ_NUM,
+ circuit->snd_stream);
else
fill_fixed_hdr_andstream (&fixed_hdr, L2_PARTIAL_SEQ_NUM,
- circuit->snd_stream);
+ circuit->snd_stream);
/*
* Fill Level 1 or 2 Partial Sequence Numbers header
*/
lenp = stream_get_putp (circuit->snd_stream);
- stream_putw (circuit->snd_stream, 0); /* PDU length - when we know it */
+ stream_putw (circuit->snd_stream, 0); /* PDU length - when we know it */
stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
stream_putc (circuit->snd_stream, circuit->idx);
@@ -2106,23 +2313,26 @@ build_psnp (int level, struct isis_circuit *circuit, struct list *lsps)
retval = tlv_add_authinfo (passwd->type, passwd->len,
passwd->passwd, circuit->snd_stream);
- if (!retval && lsps) {
- retval = tlv_add_lsp_entries (lsps, circuit->snd_stream);
- }
+ if (!retval && lsps)
+ {
+ retval = tlv_add_lsp_entries (lsps, circuit->snd_stream);
+ }
- if (isis->debugs & DEBUG_SNP_PACKETS) {
- LIST_LOOP (lsps, lsp, node) {
- zlog_info("ISIS-Snp (%s): PSNP entry %s, seq 0x%08x,"
- " cksum 0x%04x, lifetime %us",
- circuit->area->area_tag,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl (lsp->lsp_header->seq_num),
- ntohs (lsp->lsp_header->checksum),
- ntohs (lsp->lsp_header->rem_lifetime));
+ if (isis->debugs & DEBUG_SNP_PACKETS)
+ {
+ LIST_LOOP (lsps, lsp, node)
+ {
+ zlog_info ("ISIS-Snp (%s): PSNP entry %s, seq 0x%08x,"
+ " cksum 0x%04x, lifetime %us",
+ circuit->area->area_tag,
+ rawlspid_print (lsp->lsp_header->lsp_id),
+ ntohl (lsp->lsp_header->seq_num),
+ ntohs (lsp->lsp_header->checksum),
+ ntohs (lsp->lsp_header->rem_lifetime));
+ }
}
- }
- length = (u_int16_t)stream_get_putp (circuit->snd_stream);
+ length = (u_int16_t) stream_get_putp (circuit->snd_stream);
assert (length >= ISIS_PSNP_HDRLEN);
/* Update PDU length */
stream_putw_at (circuit->snd_stream, lenp, length);
@@ -2142,45 +2352,51 @@ send_psnp (int level, struct isis_circuit *circuit)
struct list *list = NULL;
struct listnode *node;
- if ((circuit->circ_type == CIRCUIT_T_BROADCAST &&
+ if ((circuit->circ_type == CIRCUIT_T_BROADCAST &&
!circuit->u.bc.is_dr[level - 1]) ||
- circuit->circ_type != CIRCUIT_T_BROADCAST) {
+ circuit->circ_type != CIRCUIT_T_BROADCAST)
+ {
- if (circuit->area->lspdb[level-1] &&
- dict_count (circuit->area->lspdb[level-1]) > 0) {
- list = list_new ();
- lsp_build_list_ssn (circuit, list, circuit->area->lspdb[level-1]);
-
- if (listcount(list) > 0) {
- if (circuit->snd_stream == NULL)
- circuit->snd_stream = stream_new (ISO_MTU(circuit));
- else
- stream_reset (circuit->snd_stream);
-
-
- if (isis->debugs & DEBUG_SNP_PACKETS)
- zlog_info ("ISIS-Snp (%s): Sent L%d PSNP on %s, length %ld",
- circuit->area->area_tag, level, circuit->interface->name,
- STREAM_SIZE(circuit->snd_stream));
-
- retval = build_psnp (level, circuit, list);
- if (retval == ISIS_OK)
- retval = circuit->tx (circuit, level);
-
- if (retval == ISIS_OK) {
- /*
- * sending succeeded, we can clear SSN flags of this circuit
- * for the LSPs in list
- */
- for (node = listhead (list); node; nextnode(node)) {
- lsp = getdata (node);
- ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
- }
- }
- }
- list_delete (list);
+ if (circuit->area->lspdb[level - 1] &&
+ dict_count (circuit->area->lspdb[level - 1]) > 0)
+ {
+ list = list_new ();
+ lsp_build_list_ssn (circuit, list, circuit->area->lspdb[level - 1]);
+
+ if (listcount (list) > 0)
+ {
+ if (circuit->snd_stream == NULL)
+ circuit->snd_stream = stream_new (ISO_MTU (circuit));
+ else
+ stream_reset (circuit->snd_stream);
+
+
+ if (isis->debugs & DEBUG_SNP_PACKETS)
+ zlog_info ("ISIS-Snp (%s): Sent L%d PSNP on %s, length %ld",
+ circuit->area->area_tag, level,
+ circuit->interface->name,
+ STREAM_SIZE (circuit->snd_stream));
+
+ retval = build_psnp (level, circuit, list);
+ if (retval == ISIS_OK)
+ retval = circuit->tx (circuit, level);
+
+ if (retval == ISIS_OK)
+ {
+ /*
+ * sending succeeded, we can clear SSN flags of this circuit
+ * for the LSPs in list
+ */
+ for (node = listhead (list); node; nextnode (node))
+ {
+ lsp = getdata (node);
+ ISIS_CLEAR_FLAG (lsp->SSNflags, circuit);
+ }
+ }
+ }
+ list_delete (list);
+ }
}
- }
return retval;
}
@@ -2199,8 +2415,8 @@ send_l1_psnp (struct thread *thread)
send_psnp (1, circuit);
/* set next timer thread */
- THREAD_TIMER_ON(master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
- isis_jitter(circuit->psnp_interval[0], PSNP_JITTER));
+ THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
+ isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));
return retval;
}
@@ -2212,7 +2428,6 @@ send_l1_psnp (struct thread *thread)
int
send_l2_psnp (struct thread *thread)
{
-
struct isis_circuit *circuit;
int retval = ISIS_OK;
@@ -2224,26 +2439,24 @@ send_l2_psnp (struct thread *thread)
send_psnp (2, circuit);
/* set next timer thread */
- THREAD_TIMER_ON(master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
- isis_jitter(circuit->psnp_interval[1], PSNP_JITTER));
+ THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
+ isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));
return retval;
}
-
void
build_link_state (struct isis_lsp *lsp, struct isis_circuit *circuit,
- struct stream *stream)
+ struct stream *stream)
{
unsigned long length;
- stream_put (stream, lsp->pdu, ntohs(lsp->lsp_header->pdu_len));
- length = stream_get_putp (stream);
+ stream_put (stream, lsp->pdu, ntohs (lsp->lsp_header->pdu_len));
+ length = stream_get_putp (stream);
return;
}
-
/*
* ISO 10589 - 7.3.14.3
*/
@@ -2258,90 +2471,98 @@ send_lsp (struct thread *thread)
circuit = THREAD_ARG (thread);
assert (circuit);
- if (circuit->state == C_STATE_UP) {
- node = listhead (circuit->lsp_queue);
- assert (node);
-
- lsp = getdata (node);
-
- /*
- * Do not send if levels do not match
- */
- if (!(lsp->level & circuit->circuit_is_type))
- goto dontsend;
-
- /*
- * Do not send if we do not have adjacencies in state up on the circuit
- */
- if (circuit->upadjcount[lsp->level - 1] == 0)
- goto dontsend;
- /* only send if it needs sending */
- if ((time(NULL) - lsp->last_sent) >=
- circuit->area->lsp_gen_interval[lsp->level-1]) {
-
- if (isis->debugs & DEBUG_UPDATE_PACKETS) {
- zlog_info ("ISIS-Upd (%s): Sent L%d LSP %s, seq 0x%08x, cksum 0x%04x,"
- " lifetime %us on %s",
- circuit->area->area_tag,
- lsp->level,
- rawlspid_print (lsp->lsp_header->lsp_id),
- ntohl(lsp->lsp_header->seq_num),
- ntohs(lsp->lsp_header->checksum),
- ntohs(lsp->lsp_header->rem_lifetime),
- circuit->interface->name);
- }
- /* copy our lsp to the send buffer */
- circuit->snd_stream->getp = lsp->pdu->getp;
- circuit->snd_stream->putp = lsp->pdu->putp;
- circuit->snd_stream->endp = lsp->pdu->endp;
- memcpy (circuit->snd_stream->data, lsp->pdu->data, lsp->pdu->endp);
+ if (circuit->state == C_STATE_UP)
+ {
+ node = listhead (circuit->lsp_queue);
+ assert (node);
- retval = circuit->tx (circuit, lsp->level);
+ lsp = getdata (node);
/*
- * If the sending succeeded, we can del the lsp from circuits lsp_queue
+ * Do not send if levels do not match
*/
- if (retval == ISIS_OK) {
- list_delete_node (circuit->lsp_queue, node);
+ if (!(lsp->level & circuit->circuit_is_type))
+ goto dontsend;
- /*
- * On broadcast circuits also the SRMflag can be cleared
- */
- if (circuit->circ_type == CIRCUIT_T_BROADCAST)
- ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+ /*
+ * Do not send if we do not have adjacencies in state up on the circuit
+ */
+ if (circuit->upadjcount[lsp->level - 1] == 0)
+ goto dontsend;
+ /* only send if it needs sending */
+ if ((time (NULL) - lsp->last_sent) >=
+ circuit->area->lsp_gen_interval[lsp->level - 1])
+ {
+
+ if (isis->debugs & DEBUG_UPDATE_PACKETS)
+ {
+ zlog_info
+ ("ISIS-Upd (%s): Sent L%d LSP %s, seq 0x%08x, cksum 0x%04x,"
+ " lifetime %us on %s", circuit->area->area_tag, lsp->level,
+ rawlspid_print (lsp->lsp_header->lsp_id),
+ ntohl (lsp->lsp_header->seq_num),
+ ntohs (lsp->lsp_header->checksum),
+ ntohs (lsp->lsp_header->rem_lifetime),
+ circuit->interface->name);
+ }
+ /* copy our lsp to the send buffer */
+ circuit->snd_stream->getp = lsp->pdu->getp;
+ circuit->snd_stream->putp = lsp->pdu->putp;
+ circuit->snd_stream->endp = lsp->pdu->endp;
+ memcpy (circuit->snd_stream->data, lsp->pdu->data, lsp->pdu->endp);
+
+ retval = circuit->tx (circuit, lsp->level);
- if (flags_any_set (lsp->SRMflags) == 0) {
/*
- * need to remember when we were last sent
+ * If the sending succeeded, we can del the lsp from circuits
+ * lsp_queue
*/
- lsp->last_sent = time (NULL);
+ if (retval == ISIS_OK)
+ {
+ list_delete_node (circuit->lsp_queue, node);
+
+ /*
+ * On broadcast circuits also the SRMflag can be cleared
+ */
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ ISIS_CLEAR_FLAG (lsp->SRMflags, circuit);
+
+ if (flags_any_set (lsp->SRMflags) == 0)
+ {
+ /*
+ * need to remember when we were last sent
+ */
+ lsp->last_sent = time (NULL);
+ }
+ }
+ else
+ {
+ zlog_info ("sending of level %d link state failed", lsp->level);
+ }
+ }
+ else
+ {
+ /* my belief is that if it wasn't his time, the lsp can be removed
+ * from the queue
+ */
+ dontsend:
+ list_delete_node (circuit->lsp_queue, node);
}
- } else {
- zlog_info ("sending of level %d link state failed", lsp->level);
- }
- } else {
- /* my belief is that if it wasn't his time, the lsp can be removed
- * from the queue
- */
- dontsend:
- list_delete_node (circuit->lsp_queue, node);
- }
#if 0
- /*
- * If there are still LSPs send next one after lsp-interval (33 msecs)
- */
- if (listcount (circuit->lsp_queue) > 0)
- thread_add_timer (master, send_lsp, circuit,
- 1);
+ /*
+ * If there are still LSPs send next one after lsp-interval (33 msecs)
+ */
+ if (listcount (circuit->lsp_queue) > 0)
+ thread_add_timer (master, send_lsp, circuit, 1);
#endif
- }
+ }
return retval;
-}
+}
int
-ack_lsp (struct isis_link_state_hdr *hdr, struct isis_circuit *circuit,
- int level)
+ack_lsp (struct isis_link_state_hdr *hdr, struct isis_circuit *circuit,
+ int level)
{
unsigned long lenp;
int retval;
@@ -2349,32 +2570,32 @@ ack_lsp (struct isis_link_state_hdr *hdr, struct isis_circuit *circuit,
struct isis_fixed_hdr fixed_hdr;
if (!circuit->snd_stream)
- circuit->snd_stream = stream_new (ISO_MTU(circuit));
+ circuit->snd_stream = stream_new (ISO_MTU (circuit));
else
stream_reset (circuit->snd_stream);
// fill_llc_hdr (stream);
if (level == 1)
- fill_fixed_hdr_andstream (&fixed_hdr, L1_PARTIAL_SEQ_NUM,
- circuit->snd_stream);
+ fill_fixed_hdr_andstream (&fixed_hdr, L1_PARTIAL_SEQ_NUM,
+ circuit->snd_stream);
else
- fill_fixed_hdr_andstream (&fixed_hdr, L2_PARTIAL_SEQ_NUM,
- circuit->snd_stream);
+ fill_fixed_hdr_andstream (&fixed_hdr, L2_PARTIAL_SEQ_NUM,
+ circuit->snd_stream);
lenp = stream_get_putp (circuit->snd_stream);
- stream_putw (circuit->snd_stream, 0); /* PDU length */
- stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
+ stream_putw (circuit->snd_stream, 0); /* PDU length */
+ stream_put (circuit->snd_stream, isis->sysid, ISIS_SYS_ID_LEN);
stream_putc (circuit->snd_stream, circuit->idx);
- stream_putc (circuit->snd_stream, 9); /* code */
- stream_putc (circuit->snd_stream, 16); /* len */
+ stream_putc (circuit->snd_stream, 9); /* code */
+ stream_putc (circuit->snd_stream, 16); /* len */
- stream_putw (circuit->snd_stream, ntohs(hdr->rem_lifetime));
- stream_put (circuit->snd_stream, hdr->lsp_id, ISIS_SYS_ID_LEN + 2);
- stream_putl (circuit->snd_stream, ntohl(hdr->seq_num));
- stream_putw (circuit->snd_stream, ntohs(hdr->checksum));
+ stream_putw (circuit->snd_stream, ntohs (hdr->rem_lifetime));
+ stream_put (circuit->snd_stream, hdr->lsp_id, ISIS_SYS_ID_LEN + 2);
+ stream_putl (circuit->snd_stream, ntohl (hdr->seq_num));
+ stream_putw (circuit->snd_stream, ntohs (hdr->checksum));
- length = (u_int16_t)stream_get_putp (circuit->snd_stream);
+ length = (u_int16_t) stream_get_putp (circuit->snd_stream);
/* Update PDU length */
stream_putw_at (circuit->snd_stream, lenp, length);
@@ -2388,67 +2609,86 @@ ack_lsp (struct isis_link_state_hdr *hdr, struct isis_circuit *circuit,
* ISH PDU Processing
*/
-
/*
* Let's first check if the local and remote system have any common area
* addresses
*/
- if (area_match(tlvs.area_addrs, isis->man_area_addrs) == 0) {
- if (circuit->circuit_t == IS_LEVEL_2) {
- /* do as in table 8 (p. 40) */
- switch (circuit_type) {
- case IS_LEVEL_1:
- if (adj->adj_state != ISIS_ADJ_UP) {
- /* Reject */
- zlog_warn("areaMismatch");
- retval = ISIS_WARNING;
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch",
- circuit->adjdb);
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2 ||
- adj->adj_usage == ISIS_ADJ_LEVEL2) {
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System",
- circuit->adjdb);
- }
- break;
- case IS_LEVEL_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL, circuit->adjdb);
- adj->adj_usage = ISIS_ADJ_LEVEL2;
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1 ||
- adj->adj_usage == ISIS_ADJ_LEVEL1AND2) {
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System",
- circuit->adjdb);
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL2) {
- ; /* Accept */
- }
- break;
- case IS_LEVEL_1_AND_2:
- if (adj->adj_state != ISIS_ADJ_UP) {
- isis_adj_state_change (adj, ISIS_ADJ_UP, NULL, circuit->adjdb);
- adj->adj_usage = ISIS_ADJ_LEVEL2;
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1) {
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System",
- circuit->adjdb);
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2) {
- isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch",
- circuit->adjdb);
- } else if (adj->adj_usage == ISIS_ADJ_LEVEL2) {
- ; /* Accept */
- }
- break;
+if (area_match (tlvs.area_addrs, isis->man_area_addrs) == 0)
+ {
+ if (circuit->circuit_t == IS_LEVEL_2)
+ {
+ /* do as in table 8 (p. 40) */
+ switch (circuit_type)
+ {
+ case IS_LEVEL_1:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ /* Reject */
+ zlog_warn ("areaMismatch");
+ retval = ISIS_WARNING;
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch",
+ circuit->adjdb);
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2 ||
+ adj->adj_usage == ISIS_ADJ_LEVEL2)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System",
+ circuit->adjdb);
+ }
+ break;
+ case IS_LEVEL_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL,
+ circuit->adjdb);
+ adj->adj_usage = ISIS_ADJ_LEVEL2;
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1 ||
+ adj->adj_usage == ISIS_ADJ_LEVEL1AND2)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System",
+ circuit->adjdb);
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL2)
+ {
+ ; /* Accept */
+ }
+ break;
+ case IS_LEVEL_1_AND_2:
+ if (adj->adj_state != ISIS_ADJ_UP)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_UP, NULL,
+ circuit->adjdb);
+ adj->adj_usage = ISIS_ADJ_LEVEL2;
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Wrong System",
+ circuit->adjdb);
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL1AND2)
+ {
+ isis_adj_state_change (adj, ISIS_ADJ_DOWN, "Area Mismatch",
+ circuit->adjdb);
+ }
+ else if (adj->adj_usage == ISIS_ADJ_LEVEL2)
+ {
+ ; /* Accept */
+ }
+ break;
+ }
+ goto mismatch;
+ }
+ else
+ {
+ isis_delete_adj (adj, circuit->adjdb);
+ zlog_warn ("areaMismatch");
+ return ISIS_WARNING;
}
- goto mismatch;
- } else {
- isis_delete_adj (adj, circuit->adjdb);
- zlog_warn("areaMismatch");
- return ISIS_WARNING;
- }
}
mismatch:
#endif
-
-
-
-
diff --git a/isisd/isis_pdu.h b/isisd/isis_pdu.h
index 994036801..29c762119 100644
--- a/isisd/isis_pdu.h
+++ b/isisd/isis_pdu.h
@@ -54,7 +54,7 @@ struct esis_fixed_hdr
u_char pdu_type;
u_int16_t holdtime;
u_int16_t checksum;
-} __attribute__((packed));
+} __attribute__ ((packed));
#define ESIS_FIXED_HDR_LEN 9
@@ -81,7 +81,7 @@ struct esis_fixed_hdr
* +-------+-------+-------+-------+-------+-------+-------+-------+
*/
-struct isis_fixed_hdr
+struct isis_fixed_hdr
{
u_char idrp;
u_char length;
@@ -117,14 +117,15 @@ struct isis_fixed_hdr
* | LAN ID | id_len + 1
* +-------+-------+-------+-------+-------+-------+-------+-------+
*/
-struct isis_lan_hello_hdr {
- u_char circuit_t;
- u_char source_id[ISIS_SYS_ID_LEN];
- u_int16_t hold_time;
- u_int16_t pdu_len;
- u_char prio;
- u_char lan_id[ISIS_SYS_ID_LEN + 1];
-} __attribute__((packed));
+struct isis_lan_hello_hdr
+{
+ u_char circuit_t;
+ u_char source_id[ISIS_SYS_ID_LEN];
+ u_int16_t hold_time;
+ u_int16_t pdu_len;
+ u_char prio;
+ u_char lan_id[ISIS_SYS_ID_LEN + 1];
+} __attribute__ ((packed));
#define ISIS_LANHELLO_HDRLEN 19
#define P2P_HELLO 17
@@ -142,13 +143,14 @@ struct isis_lan_hello_hdr {
* | Local Circuit ID | 1
* +-------+-------+-------+-------+-------+-------+-------+-------+
*/
-struct isis_p2p_hello_hdr {
- u_char circuit_t;
- u_char source_id[ISIS_SYS_ID_LEN];
- u_int16_t hold_time;
- u_int16_t pdu_len;
+struct isis_p2p_hello_hdr
+{
+ u_char circuit_t;
+ u_char source_id[ISIS_SYS_ID_LEN];
+ u_int16_t hold_time;
+ u_int16_t pdu_len;
u_char local_id;
-} __attribute__((packed));
+} __attribute__ ((packed));
#define ISIS_P2PHELLO_HDRLEN 12
#define L1_LINK_STATE 18
@@ -169,14 +171,15 @@ struct isis_p2p_hello_hdr {
* | P | ATT |LSPDBOL| ISTYPE |
* +-------+-------+-------+-------+-------+-------+-------+-------+
*/
-struct isis_link_state_hdr {
- u_int16_t pdu_len;
+struct isis_link_state_hdr
+{
+ u_int16_t pdu_len;
u_int16_t rem_lifetime;
- u_char lsp_id[ISIS_SYS_ID_LEN + 2];
+ u_char lsp_id[ISIS_SYS_ID_LEN + 2];
u_int32_t seq_num;
u_int16_t checksum;
- u_int8_t lsp_bits;
-} __attribute__((packed));
+ u_int8_t lsp_bits;
+} __attribute__ ((packed));
#define ISIS_LSP_HDR_LEN 19
#define L1_COMPLETE_SEQ_NUM 24
@@ -193,11 +196,12 @@ struct isis_link_state_hdr {
* + End LSP ID + id_len + 2
* +-------+-------+-------+-------+-------+-------+-------+-------+
*/
-struct isis_complete_seqnum_hdr {
+struct isis_complete_seqnum_hdr
+{
u_int16_t pdu_len;
- u_char source_id[ISIS_SYS_ID_LEN + 1];
- u_char start_lsp_id[ISIS_SYS_ID_LEN + 2];
- u_char stop_lsp_id[ISIS_SYS_ID_LEN + 2];
+ u_char source_id[ISIS_SYS_ID_LEN + 1];
+ u_char start_lsp_id[ISIS_SYS_ID_LEN + 2];
+ u_char stop_lsp_id[ISIS_SYS_ID_LEN + 2];
};
#define ISIS_CSNP_HDRLEN 25
@@ -211,9 +215,10 @@ struct isis_complete_seqnum_hdr {
* + Source ID + id_len + 1
* +---------------------------------------------------------------+
*/
-struct isis_partial_seqnum_hdr {
+struct isis_partial_seqnum_hdr
+{
u_int16_t pdu_len;
- u_char source_id[ISIS_SYS_ID_LEN + 1];
+ u_char source_id[ISIS_SYS_ID_LEN + 1];
};
#define ISIS_PSNP_HDRLEN 9
@@ -231,27 +236,22 @@ int isis_receive (struct thread *thread);
/*
* Sending functions
*/
-int send_lan_l1_hello (struct thread *thread);
-int send_lan_l2_hello (struct thread *thread);
-int send_p2p_hello (struct thread *thread);
-int send_csnp (struct isis_circuit *circuit, int level);
-int send_l1_csnp (struct thread *thread);
-int send_l2_csnp (struct thread *thread);
-int send_l1_psnp (struct thread *thread);
-int send_l2_psnp (struct thread *thread);
-int send_lsp (struct thread *thread);
-int ack_lsp (struct isis_link_state_hdr *hdr,
- struct isis_circuit *circuit, int level);
-void fill_fixed_hdr (struct isis_fixed_hdr *hdr, u_char pdu_type);
-int send_hello (struct isis_circuit *circuit, int level);
+int send_lan_l1_hello (struct thread *thread);
+int send_lan_l2_hello (struct thread *thread);
+int send_p2p_hello (struct thread *thread);
+int send_csnp (struct isis_circuit *circuit, int level);
+int send_l1_csnp (struct thread *thread);
+int send_l2_csnp (struct thread *thread);
+int send_l1_psnp (struct thread *thread);
+int send_l2_psnp (struct thread *thread);
+int send_lsp (struct thread *thread);
+int ack_lsp (struct isis_link_state_hdr *hdr,
+ struct isis_circuit *circuit, int level);
+void fill_fixed_hdr (struct isis_fixed_hdr *hdr, u_char pdu_type);
+int send_hello (struct isis_circuit *circuit, int level);
-int authentication_check (struct isis_passwd *one,
+int authentication_check (struct isis_passwd *one,
struct isis_passwd *theother);
#endif /* _ZEBRA_ISIS_PDU_H */
-
-
-
-
-
diff --git a/isisd/isis_route.c b/isisd/isis_route.c
index b889d3b8a..90808681c 100644
--- a/isisd/isis_route.c
+++ b/isisd/isis_route.c
@@ -55,27 +55,28 @@ extern struct thread_master *master;
struct isis_nexthop *
isis_nexthop_create (struct in_addr *ip, unsigned int ifindex)
-
{
struct listnode *node;
struct isis_nexthop *nexthop;
-
- for (node = listhead (isis->nexthops); node; nextnode (node)) {
- nexthop = getdata (node);
- if (nexthop->ifindex != ifindex)
- continue;
- if (ip && memcmp (&nexthop->ip, ip, sizeof (struct in_addr)) != 0)
- continue;
-
- nexthop->lock++;
- return nexthop;
- }
-
+
+ for (node = listhead (isis->nexthops); node; nextnode (node))
+ {
+ nexthop = getdata (node);
+ if (nexthop->ifindex != ifindex)
+ continue;
+ if (ip && memcmp (&nexthop->ip, ip, sizeof (struct in_addr)) != 0)
+ continue;
+
+ nexthop->lock++;
+ return nexthop;
+ }
+
nexthop = XMALLOC (MTYPE_ISIS_NEXTHOP, sizeof (struct isis_nexthop));
- if (!nexthop) {
- zlog_err ("ISIS-Rte: isis_nexthop_create: out of memory!");
- }
-
+ if (!nexthop)
+ {
+ zlog_err ("ISIS-Rte: isis_nexthop_create: out of memory!");
+ }
+
memset (nexthop, 0, sizeof (struct isis_nexthop));
nexthop->ifindex = ifindex;
memcpy (&nexthop->ip, ip, sizeof (struct in_addr));
@@ -85,32 +86,33 @@ isis_nexthop_create (struct in_addr *ip, unsigned int ifindex)
return nexthop;
}
-
void
isis_nexthop_delete (struct isis_nexthop *nexthop)
{
nexthop->lock--;
- if (nexthop->lock == 0) {
- listnode_delete (isis->nexthops, nexthop);
- XFREE (MTYPE_ISIS_NEXTHOP, nexthop);
- }
-
+ if (nexthop->lock == 0)
+ {
+ listnode_delete (isis->nexthops, nexthop);
+ XFREE (MTYPE_ISIS_NEXTHOP, nexthop);
+ }
+
return;
}
int
-nexthoplookup (struct list *nexthops, struct in_addr *ip,
- unsigned int ifindex)
+nexthoplookup (struct list *nexthops, struct in_addr *ip,
+ unsigned int ifindex)
{
struct listnode *node;
struct isis_nexthop *nh;
- for (node = listhead (nexthops); node; nextnode (node)) {
- nh = getdata (node);
- if (!(memcmp (ip, &nh->ip, sizeof (struct in_addr))) &&
- ifindex == nh->ifindex)
- return 1;
- }
+ for (node = listhead (nexthops); node; nextnode (node))
+ {
+ nh = getdata (node);
+ if (!(memcmp (ip, &nh->ip, sizeof (struct in_addr))) &&
+ ifindex == nh->ifindex)
+ return 1;
+ }
return 0;
}
@@ -119,9 +121,9 @@ void
nexthop_print (struct isis_nexthop *nh)
{
u_char buf[BUFSIZ];
-
+
inet_ntop (AF_INET, &nh->ip, buf, BUFSIZ);
-
+
zlog_info (" %s %u", buf, nh->ifindex);
}
@@ -129,24 +131,25 @@ void
nexthops_print (struct list *nhs)
{
struct listnode *node;
-
- for (node = listhead(nhs); node; nextnode (node))
+
+ for (node = listhead (nhs); node; nextnode (node))
nexthop_print (getdata (node));
}
#ifdef HAVE_IPV6
struct isis_nexthop6 *
-isis_nexthop6_new (struct in6_addr *ip6, unsigned int ifindex)
+isis_nexthop6_new (struct in6_addr *ip6, unsigned int ifindex)
{
-
+
struct isis_nexthop6 *nexthop6;
-
+
nexthop6 = XMALLOC (MTYPE_ISIS_NEXTHOP6, sizeof (struct isis_nexthop6));
- if (!nexthop6) {
- zlog_err ("ISIS-Rte: isis_nexthop_create6: out of memory!");
- }
-
+ if (!nexthop6)
+ {
+ zlog_err ("ISIS-Rte: isis_nexthop_create6: out of memory!");
+ }
+
memset (nexthop6, 0, sizeof (struct isis_nexthop6));
nexthop6->ifindex = ifindex;
memcpy (&nexthop6->ip6, ip6, sizeof (struct in6_addr));
@@ -157,54 +160,55 @@ isis_nexthop6_new (struct in6_addr *ip6, unsigned int ifindex)
struct isis_nexthop6 *
isis_nexthop6_create (struct in6_addr *ip6, unsigned int ifindex)
-
{
struct listnode *node;
struct isis_nexthop6 *nexthop6;
-
- for (node = listhead (isis->nexthops6); node; nextnode (node)) {
- nexthop6 = getdata (node);
- if (nexthop6->ifindex != ifindex)
- continue;
- if (ip6 && memcmp (&nexthop6->ip6, ip6, sizeof (struct in6_addr)) != 0)
- continue;
-
- nexthop6->lock++;
- return nexthop6;
- }
-
+
+ for (node = listhead (isis->nexthops6); node; nextnode (node))
+ {
+ nexthop6 = getdata (node);
+ if (nexthop6->ifindex != ifindex)
+ continue;
+ if (ip6 && memcmp (&nexthop6->ip6, ip6, sizeof (struct in6_addr)) != 0)
+ continue;
+
+ nexthop6->lock++;
+ return nexthop6;
+ }
+
nexthop6 = isis_nexthop6_new (ip6, ifindex);
return nexthop6;
}
-
void
isis_nexthop6_delete (struct isis_nexthop6 *nexthop6)
{
nexthop6->lock--;
- if (nexthop6->lock == 0) {
- listnode_delete (isis->nexthops6, nexthop6);
- XFREE (MTYPE_ISIS_NEXTHOP6, nexthop6);
- }
-
+ if (nexthop6->lock == 0)
+ {
+ listnode_delete (isis->nexthops6, nexthop6);
+ XFREE (MTYPE_ISIS_NEXTHOP6, nexthop6);
+ }
+
return;
}
int
-nexthop6lookup (struct list *nexthops6, struct in6_addr *ip6,
- unsigned int ifindex)
+nexthop6lookup (struct list *nexthops6, struct in6_addr *ip6,
+ unsigned int ifindex)
{
struct listnode *node;
struct isis_nexthop6 *nh6;
- for (node = listhead (nexthops6); node; nextnode (node)) {
- nh6 = getdata (node);
- if (!(memcmp (ip6, &nh6->ip6, sizeof (struct in6_addr))) &&
- ifindex == nh6->ifindex)
- return 1;
- }
+ for (node = listhead (nexthops6); node; nextnode (node))
+ {
+ nh6 = getdata (node);
+ if (!(memcmp (ip6, &nh6->ip6, sizeof (struct in6_addr))) &&
+ ifindex == nh6->ifindex)
+ return 1;
+ }
return 0;
}
@@ -213,9 +217,9 @@ void
nexthop6_print (struct isis_nexthop6 *nh6)
{
u_char buf[BUFSIZ];
-
+
inet_ntop (AF_INET6, &nh6->ip6, buf, BUFSIZ);
-
+
zlog_info (" %s %u", buf, nh6->ifindex);
}
@@ -223,8 +227,8 @@ void
nexthops6_print (struct list *nhs6)
{
struct listnode *node;
-
- for (node = listhead(nhs6); node; nextnode (node))
+
+ for (node = listhead (nhs6); node; nextnode (node))
nexthop6_print (getdata (node));
}
@@ -240,15 +244,17 @@ adjinfo2nexthop (struct list *nexthops, struct isis_adjacency *adj)
if (adj->ipv4_addrs == NULL)
return;
- for (node = listhead (adj->ipv4_addrs); node; nextnode (node)) {
- ipv4_addr = getdata (node);
- if (!nexthoplookup (nexthops, ipv4_addr,
- adj->circuit->interface->ifindex)) {
- nh = isis_nexthop_create (ipv4_addr,
- adj->circuit->interface->ifindex);
- listnode_add (nexthops, nh);
+ for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
+ {
+ ipv4_addr = getdata (node);
+ if (!nexthoplookup (nexthops, ipv4_addr,
+ adj->circuit->interface->ifindex))
+ {
+ nh = isis_nexthop_create (ipv4_addr,
+ adj->circuit->interface->ifindex);
+ listnode_add (nexthops, nh);
+ }
}
- }
}
#ifdef HAVE_IPV6
@@ -258,156 +264,170 @@ adjinfo2nexthop6 (struct list *nexthops6, struct isis_adjacency *adj)
struct listnode *node;
struct in6_addr *ipv6_addr;
struct isis_nexthop6 *nh6;
-
+
if (!adj->ipv6_addrs)
return;
- for (node = listhead (adj->ipv6_addrs); node; nextnode (node)) {
- ipv6_addr = getdata (node);
- if (!nexthop6lookup (nexthops6, ipv6_addr,
- adj->circuit->interface->ifindex)) {
- nh6 = isis_nexthop6_create (ipv6_addr,
- adj->circuit->interface->ifindex);
- listnode_add (nexthops6, nh6);
+ for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+ {
+ ipv6_addr = getdata (node);
+ if (!nexthop6lookup (nexthops6, ipv6_addr,
+ adj->circuit->interface->ifindex))
+ {
+ nh6 = isis_nexthop6_create (ipv6_addr,
+ adj->circuit->interface->ifindex);
+ listnode_add (nexthops6, nh6);
+ }
}
- }
}
#endif /* HAVE_IPV6 */
struct isis_route_info *
-isis_route_info_new (uint32_t cost, uint32_t depth, u_char family,
- struct list *adjacencies)
+isis_route_info_new (uint32_t cost, uint32_t depth, u_char family,
+ struct list *adjacencies)
{
struct isis_route_info *rinfo;
struct isis_adjacency *adj;
struct listnode *node;
-
+
rinfo = XMALLOC (MTYPE_ISIS_ROUTE_INFO, sizeof (struct isis_route_info));
- if (!rinfo) {
- zlog_err ("ISIS-Rte: isis_route_info_new: out of memory!");
- return NULL;
- }
+ if (!rinfo)
+ {
+ zlog_err ("ISIS-Rte: isis_route_info_new: out of memory!");
+ return NULL;
+ }
memset (rinfo, 0, sizeof (struct isis_route_info));
- if (family == AF_INET) {
- rinfo->nexthops = list_new ();
- for (node = listhead (adjacencies); node; nextnode (node)) {
- adj = getdata (node);
- adjinfo2nexthop (rinfo->nexthops, adj);
+ if (family == AF_INET)
+ {
+ rinfo->nexthops = list_new ();
+ for (node = listhead (adjacencies); node; nextnode (node))
+ {
+ adj = getdata (node);
+ adjinfo2nexthop (rinfo->nexthops, adj);
+ }
}
- }
#ifdef HAVE_IPV6
- if (family == AF_INET6) {
- rinfo->nexthops6 = list_new ();
- for (node = listhead (adjacencies); node; nextnode (node)) {
- adj =getdata (node);
- adjinfo2nexthop6 (rinfo->nexthops6, adj);
+ if (family == AF_INET6)
+ {
+ rinfo->nexthops6 = list_new ();
+ for (node = listhead (adjacencies); node; nextnode (node))
+ {
+ adj = getdata (node);
+ adjinfo2nexthop6 (rinfo->nexthops6, adj);
+ }
}
- }
-
+
#endif /* HAVE_IPV6 */
rinfo->cost = cost;
rinfo->depth = depth;
-
+
return rinfo;
}
-
void
isis_route_info_delete (struct isis_route_info *route_info)
{
-
- if (route_info->nexthops) {
- route_info->nexthops->del = (void *)isis_nexthop_delete;
- list_delete (route_info->nexthops);
- }
-
+ if (route_info->nexthops)
+ {
+ route_info->nexthops->del = (void *) isis_nexthop_delete;
+ list_delete (route_info->nexthops);
+ }
+
#ifdef HAVE_IPV6
- if (route_info->nexthops6) {
- route_info->nexthops6->del = (void *)isis_nexthop6_delete;
+ if (route_info->nexthops6)
+ {
+ route_info->nexthops6->del = (void *) isis_nexthop6_delete;
list_delete (route_info->nexthops6);
- }
+ }
#endif /* HAVE_IPV6 */
-
+
XFREE (MTYPE_ISIS_ROUTE_INFO, route_info);
}
int
-isis_route_info_same_attrib (struct isis_route_info *new,
- struct isis_route_info *old)
+isis_route_info_same_attrib (struct isis_route_info *new,
+ struct isis_route_info *old)
{
if (new->cost != old->cost)
return 0;
if (new->depth != old->depth)
return 0;
-
+
return 1;
}
int
-isis_route_info_same (struct isis_route_info *new, struct isis_route_info *old,
- u_char family)
+isis_route_info_same (struct isis_route_info *new,
+ struct isis_route_info *old, u_char family)
{
- struct listnode *node;
+ struct listnode *node;
struct isis_nexthop *nexthop;
#ifdef HAVE_IPV6
struct isis_nexthop6 *nexthop6;
#endif /* HAVE_IPV6 */
if (!isis_route_info_same_attrib (new, old))
return 0;
-
- if (family == AF_INET) {
- for (node = listhead (new->nexthops); node; nextnode (node)) {
- nexthop = (struct isis_nexthop *) getdata (node);
- if (nexthoplookup (old->nexthops, &nexthop->ip, nexthop->ifindex) == 0)
- return 0;
- }
-
- for (node = listhead (old->nexthops); node; nextnode (node)) {
- nexthop = (struct isis_nexthop *) getdata (node);
- if (nexthoplookup (new->nexthops, &nexthop->ip, nexthop->ifindex) == 0)
- return 0;
+
+ if (family == AF_INET)
+ {
+ for (node = listhead (new->nexthops); node; nextnode (node))
+ {
+ nexthop = (struct isis_nexthop *) getdata (node);
+ if (nexthoplookup (old->nexthops, &nexthop->ip, nexthop->ifindex) ==
+ 0)
+ return 0;
+ }
+
+ for (node = listhead (old->nexthops); node; nextnode (node))
+ {
+ nexthop = (struct isis_nexthop *) getdata (node);
+ if (nexthoplookup (new->nexthops, &nexthop->ip, nexthop->ifindex) ==
+ 0)
+ return 0;
+ }
}
- }
#ifdef HAVE_IPV6
- else if (family == AF_INET6) {
- for (node = listhead (new->nexthops6); node; nextnode (node)) {
- nexthop6 = (struct isis_nexthop6 *) getdata (node);
- if (nexthop6lookup (old->nexthops6, &nexthop6->ip6,
- nexthop6->ifindex) == 0)
- return 0;
- }
-
- for (node = listhead (old->nexthops6); node; nextnode (node)) {
- nexthop6 = (struct isis_nexthop6 *) getdata (node);
- if (nexthop6lookup (new->nexthops6, &nexthop6->ip6,
- nexthop6->ifindex) == 0)
- return 0;
+ else if (family == AF_INET6)
+ {
+ for (node = listhead (new->nexthops6); node; nextnode (node))
+ {
+ nexthop6 = (struct isis_nexthop6 *) getdata (node);
+ if (nexthop6lookup (old->nexthops6, &nexthop6->ip6,
+ nexthop6->ifindex) == 0)
+ return 0;
+ }
+
+ for (node = listhead (old->nexthops6); node; nextnode (node))
+ {
+ nexthop6 = (struct isis_nexthop6 *) getdata (node);
+ if (nexthop6lookup (new->nexthops6, &nexthop6->ip6,
+ nexthop6->ifindex) == 0)
+ return 0;
+ }
}
- }
#endif /* HAVE_IPV6 */
return 1;
}
-
void
isis_nexthops_merge (struct list *new, struct list *old)
{
struct listnode *node;
struct isis_nexthop *nexthop;
- for (node = listhead (new); node; nextnode (node)) {
- nexthop = (struct isis_nexthop *) getdata (node);
- if (nexthoplookup (old, &nexthop->ip, nexthop->ifindex))
- continue;
- listnode_add (old, nexthop);
- nexthop->lock++;
- }
+ for (node = listhead (new); node; nextnode (node))
+ {
+ nexthop = (struct isis_nexthop *) getdata (node);
+ if (nexthoplookup (old, &nexthop->ip, nexthop->ifindex))
+ continue;
+ listnode_add (old, nexthop);
+ nexthop->lock++;
+ }
}
-
#ifdef HAVE_IPV6
void
isis_nexthops6_merge (struct list *new, struct list *old)
@@ -415,123 +435,133 @@ isis_nexthops6_merge (struct list *new, struct list *old)
struct listnode *node;
struct isis_nexthop6 *nexthop6;
- for (node = listhead (new); node; nextnode (node)) {
- nexthop6 = (struct isis_nexthop6 *) getdata (node);
- if (nexthop6lookup (old, &nexthop6->ip6, nexthop6->ifindex))
- continue;
- listnode_add (old, nexthop6);
- nexthop6->lock++;
- }
+ for (node = listhead (new); node; nextnode (node))
+ {
+ nexthop6 = (struct isis_nexthop6 *) getdata (node);
+ if (nexthop6lookup (old, &nexthop6->ip6, nexthop6->ifindex))
+ continue;
+ listnode_add (old, nexthop6);
+ nexthop6->lock++;
+ }
}
#endif /* HAVE_IPV6 */
void
-isis_route_info_merge (struct isis_route_info *new,
- struct isis_route_info *old, u_char family)
+isis_route_info_merge (struct isis_route_info *new,
+ struct isis_route_info *old, u_char family)
{
-
- if (family == AF_INET)
+ if (family == AF_INET)
isis_nexthops_merge (new->nexthops, old->nexthops);
#ifdef HAVE_IPV6
- else if (family == AF_INET6)
+ else if (family == AF_INET6)
isis_nexthops6_merge (new->nexthops6, old->nexthops6);
#endif /* HAVE_IPV6 */
-
+
return;
}
-
int
-isis_route_info_prefer_new (struct isis_route_info *new,
- struct isis_route_info *old)
+isis_route_info_prefer_new (struct isis_route_info *new,
+ struct isis_route_info *old)
{
-
if (!CHECK_FLAG (old->flag, ISIS_ROUTE_FLAG_ACTIVE))
return 1;
if (new->cost < old->cost)
return 1;
-
+
return 0;
}
-
struct isis_route_info *
isis_route_create (struct prefix *prefix, u_int32_t cost, u_int32_t depth,
- struct list *adjacencies, struct isis_area *area)
+ struct list *adjacencies, struct isis_area *area)
{
struct route_node *route_node;
struct isis_route_info *rinfo_new, *rinfo_old, *route_info = NULL;
u_char buff[BUFSIZ];
u_char family;
-
+
family = prefix->family;
/* for debugs */
prefix2str (prefix, buff, BUFSIZ);
-
+
rinfo_new = isis_route_info_new (cost, depth, family, adjacencies);
- if (!rinfo_new) {
- zlog_err ("ISIS-Rte (%s): isis_route_create: out of memory!",
- area->area_tag);
- return NULL;
- }
-
+ if (!rinfo_new)
+ {
+ zlog_err ("ISIS-Rte (%s): isis_route_create: out of memory!",
+ area->area_tag);
+ return NULL;
+ }
+
if (family == AF_INET)
- route_node = route_node_get (area->route_table, prefix);
+ route_node = route_node_get (area->route_table, prefix);
#ifdef HAVE_IPV6
else if (family == AF_INET6)
- route_node = route_node_get (area->route_table6, prefix);
+ route_node = route_node_get (area->route_table6, prefix);
#endif /* HAVE_IPV6 */
- else
+ else
return NULL;
- rinfo_old = route_node->info;
- if (!rinfo_old) {
- if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte (%s) route created: %s", area->area_tag, buff);
- SET_FLAG(rinfo_new->flag, ISIS_ROUTE_FLAG_ACTIVE);
- route_node->info = rinfo_new;
- return rinfo_new;
- }
-
+ rinfo_old = route_node->info;
+ if (!rinfo_old)
+ {
+ if (isis->debugs & DEBUG_RTE_EVENTS)
+ zlog_info ("ISIS-Rte (%s) route created: %s", area->area_tag, buff);
+ SET_FLAG (rinfo_new->flag, ISIS_ROUTE_FLAG_ACTIVE);
+ route_node->info = rinfo_new;
+ return rinfo_new;
+ }
+
if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte (%s) route already exists: %s", area->area_tag, buff);
-
- if (isis_route_info_same (rinfo_new, rinfo_old, family)) {
- if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte (%s) route unchanged: %s", area->area_tag, buff);
- isis_route_info_delete (rinfo_new);
- route_info = rinfo_old;
- } else if (isis_route_info_same_attrib (rinfo_new, rinfo_old)) {
- /* merge the nexthop lists */
- if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte (%s) route changed (same attribs): %s",
- area->area_tag, buff);
-#ifdef EXTREME_DEBUG
- zlog_info ("Old nexthops");
- nexthops6_print (rinfo_old->nexthops6);
- zlog_info ("New nexthops");
- nexthops6_print (rinfo_new->nexthops6);
-#endif /* EXTREME_DEBUG */
- isis_route_info_merge (rinfo_new, rinfo_old, family);
- isis_route_info_delete (rinfo_new);
- route_info = rinfo_old;
- } else {
- if (isis_route_info_prefer_new (rinfo_new, rinfo_old)) {
+ zlog_info ("ISIS-Rte (%s) route already exists: %s", area->area_tag,
+ buff);
+
+ if (isis_route_info_same (rinfo_new, rinfo_old, family))
+ {
if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte (%s) route changed: %s", area->area_tag, buff);
- isis_route_info_delete (rinfo_old);
- route_info = rinfo_new;
- } else {
+ zlog_info ("ISIS-Rte (%s) route unchanged: %s", area->area_tag, buff);
+ isis_route_info_delete (rinfo_new);
+ route_info = rinfo_old;
+ }
+ else if (isis_route_info_same_attrib (rinfo_new, rinfo_old))
+ {
+ /* merge the nexthop lists */
if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte (%s) route rejected: %s", area->area_tag, buff);
+ zlog_info ("ISIS-Rte (%s) route changed (same attribs): %s",
+ area->area_tag, buff);
+#ifdef EXTREME_DEBUG
+ zlog_info ("Old nexthops");
+ nexthops6_print (rinfo_old->nexthops6);
+ zlog_info ("New nexthops");
+ nexthops6_print (rinfo_new->nexthops6);
+#endif /* EXTREME_DEBUG */
+ isis_route_info_merge (rinfo_new, rinfo_old, family);
isis_route_info_delete (rinfo_new);
route_info = rinfo_old;
}
- }
-
+ else
+ {
+ if (isis_route_info_prefer_new (rinfo_new, rinfo_old))
+ {
+ if (isis->debugs & DEBUG_RTE_EVENTS)
+ zlog_info ("ISIS-Rte (%s) route changed: %s", area->area_tag,
+ buff);
+ isis_route_info_delete (rinfo_old);
+ route_info = rinfo_new;
+ }
+ else
+ {
+ if (isis->debugs & DEBUG_RTE_EVENTS)
+ zlog_info ("ISIS-Rte (%s) route rejected: %s", area->area_tag,
+ buff);
+ isis_route_info_delete (rinfo_new);
+ route_info = rinfo_old;
+ }
+ }
+
SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE);
route_node->info = route_info;
-
+
return route_info;
}
@@ -549,21 +579,23 @@ isis_route_delete (struct prefix *prefix, struct route_table *table)
rode = route_node_get (table, prefix);
rinfo = rode->info;
- if (rinfo == NULL) {
- if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte: tried to delete non-existant route %s", buff);
- return;
- }
-
- if (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC)) {
- UNSET_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE);
- if (isis->debugs & DEBUG_RTE_EVENTS)
- zlog_info ("ISIS-Rte: route delete %s", buff);
- isis_zebra_route_update (prefix, rinfo);
- }
+ if (rinfo == NULL)
+ {
+ if (isis->debugs & DEBUG_RTE_EVENTS)
+ zlog_info ("ISIS-Rte: tried to delete non-existant route %s", buff);
+ return;
+ }
+
+ if (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC))
+ {
+ UNSET_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE);
+ if (isis->debugs & DEBUG_RTE_EVENTS)
+ zlog_info ("ISIS-Rte: route delete %s", buff);
+ isis_zebra_route_update (prefix, rinfo);
+ }
isis_route_info_delete (rinfo);
rode->info = NULL;
-
+
return;
}
@@ -581,27 +613,29 @@ isis_route_validate (struct thread *thread)
area = THREAD_ARG (thread);
table = area->route_table;
#ifdef HAVE_IPV6
- again:
+again:
#endif
- for (rode = route_top (table); rode; rode = route_next (rode)) {
- if (rode->info == NULL)
- continue;
- rinfo = rode->info;
-
- if (isis->debugs & DEBUG_RTE_EVENTS) {
- prefix2str (&rode->p, buff, BUFSIZ);
- zlog_info ("ISIS-Rte (%s): route validate: %s %s %s",
- area->area_tag,
- (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC) ?
- "sync'ed": "nosync"),
- (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE) ?
- "active": "inactive"), buff);
+ for (rode = route_top (table); rode; rode = route_next (rode))
+ {
+ if (rode->info == NULL)
+ continue;
+ rinfo = rode->info;
+
+ if (isis->debugs & DEBUG_RTE_EVENTS)
+ {
+ prefix2str (&rode->p, buff, BUFSIZ);
+ zlog_info ("ISIS-Rte (%s): route validate: %s %s %s",
+ area->area_tag,
+ (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC) ?
+ "sync'ed" : "nosync"),
+ (CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE) ?
+ "active" : "inactive"), buff);
+ }
+
+ isis_zebra_route_update (&rode->p, rinfo);
+ if (!CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE))
+ isis_route_delete (&rode->p, area->route_table);
}
-
- isis_zebra_route_update (&rode->p, rinfo);
- if (!CHECK_FLAG (rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE))
- isis_route_delete (&rode->p, area->route_table);
- }
#ifdef HAVE_IPV6
if (v6done)
return ISIS_OK;
diff --git a/isisd/isis_route.h b/isisd/isis_route.h
index 7137948eb..59b6c226f 100644
--- a/isisd/isis_route.h
+++ b/isisd/isis_route.h
@@ -26,35 +26,38 @@
#define _ZEBRA_ISIS_ROUTE_H
#ifdef HAVE_IPV6
-struct isis_nexthop6 {
+struct isis_nexthop6
+{
unsigned int ifindex;
struct in6_addr ip6;
unsigned int lock;
};
#endif /* HAVE_IPV6 */
-struct isis_nexthop {
+struct isis_nexthop
+{
unsigned int ifindex;
struct in_addr ip;
unsigned int lock;
};
-struct isis_route_info {
+struct isis_route_info
+{
#define ISIS_ROUTE_FLAG_ZEBRA_SYNC 0x01
#define ISIS_ROUTE_FLAG_ACTIVE 0x02
- u_char flag;
+ u_char flag;
u_int32_t cost;
u_int32_t depth;
struct list *nexthops;
#ifdef HAVE_IPV6
struct list *nexthops6;
-#endif /* HAVE_IPV6 */
+#endif /* HAVE_IPV6 */
};
-struct isis_route_info *isis_route_create (struct prefix *prefix,
- u_int32_t cost, u_int32_t depth,
- struct list *adjacencies,
- struct isis_area *area);
+struct isis_route_info *isis_route_create (struct prefix *prefix,
+ u_int32_t cost, u_int32_t depth,
+ struct list *adjacencies,
+ struct isis_area *area);
int isis_route_validate (struct thread *thread);
diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c
index 9a8df6100..56e44b888 100644
--- a/isisd/isis_routemap.c
+++ b/isisd/isis_routemap.c
@@ -52,48 +52,49 @@
extern struct isis *isis;
void
-isis_route_map_upd()
+isis_route_map_upd ()
{
int i = 0;
-
+
if (!isis)
return;
-
- for (i = 0; i <= ZEBRA_ROUTE_MAX; i++) {
- if (isis->rmap[i].name)
- isis->rmap[i].map = isis->rmap[i].map =
- route_map_lookup_by_name (isis->rmap[i].name);
- else
- isis->rmap[i].map = NULL;
- }
+
+ for (i = 0; i <= ZEBRA_ROUTE_MAX; i++)
+ {
+ if (isis->rmap[i].name)
+ isis->rmap[i].map = isis->rmap[i].map =
+ route_map_lookup_by_name (isis->rmap[i].name);
+ else
+ isis->rmap[i].map = NULL;
+ }
/* FIXME: do the address family sub-mode AF_INET6 here ? */
}
void
-isis_route_map_event(route_map_event_t event, char *name)
+isis_route_map_event (route_map_event_t event, char *name)
{
int type;
if (!isis)
return;
- for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
- if (isis->rmap[type].name && isis->rmap[type].map &&
- !strcmp (isis->rmap[type].name, name)) {
- isis_distribute_list_update (type);
+ for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
+ {
+ if (isis->rmap[type].name && isis->rmap[type].map &&
+ !strcmp (isis->rmap[type].name, name))
+ {
+ isis_distribute_list_update (type);
+ }
}
- }
}
-
void
isis_route_map_init (void)
{
route_map_init ();
route_map_init_vty ();
-
+
route_map_add_hook (isis_route_map_upd);
route_map_delete_hook (isis_route_map_upd);
route_map_event_hook (isis_route_map_event);
-
}
diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c
index 1e414c6ca..bd79659cb 100644
--- a/isisd/isis_spf.c
+++ b/isisd/isis_spf.c
@@ -60,73 +60,81 @@ int isis_run_spf_l2 (struct thread *thread);
/* performace issue ???? */
void
-union_adjlist( struct list *target, struct list *source )
+union_adjlist (struct list *target, struct list *source)
{
struct isis_adjacency *adj, *adj2;
struct listnode *node, *node2;
-
+
zlog_info ("Union adjlist!");
- for (node = listhead (source); node; nextnode (node)) {
- adj = getdata (node);
-
- /* lookup adjacency in the source list */
- for (node2 = listhead (target); node2; nextnode (node2)) {
- adj2 = getdata(node2);
- if (adj == adj2) break;
+ for (node = listhead (source); node; nextnode (node))
+ {
+ adj = getdata (node);
+
+ /* lookup adjacency in the source list */
+ for (node2 = listhead (target); node2; nextnode (node2))
+ {
+ adj2 = getdata (node2);
+ if (adj == adj2)
+ break;
+ }
+
+ if (!node2)
+ listnode_add (target, adj);
}
-
- if (!node2) listnode_add (target, adj);
- }
}
-
/* 7.2.7 */
-void
+void
remove_excess_adjs (struct list *adjs)
{
struct listnode *node, *excess = NULL;
struct isis_adjacency *adj, *candidate = NULL;
int comp;
- for (node = listhead (adjs); node; nextnode (node)) {
- if (excess == NULL)
- excess = node;
- candidate = getdata (excess);
- adj = getdata (node);
- if (candidate->sys_type < adj->sys_type) {
- excess = node;
- candidate = adj;
- continue;
- }
- if (candidate->sys_type > adj->sys_type)
- continue;
-
- comp = memcmp (candidate->sysid, adj->sysid, ISIS_SYS_ID_LEN);
- if (comp > 0) {
- excess = node;
- candidate = adj;
- continue;
- }
- if (comp < 0)
- continue;
-
- if (candidate->circuit->circuit_id > adj->circuit->circuit_id) {
- excess = node;
- candidate = adj;
- continue;
- }
+ for (node = listhead (adjs); node; nextnode (node))
+ {
+ if (excess == NULL)
+ excess = node;
+ candidate = getdata (excess);
+ adj = getdata (node);
+ if (candidate->sys_type < adj->sys_type)
+ {
+ excess = node;
+ candidate = adj;
+ continue;
+ }
+ if (candidate->sys_type > adj->sys_type)
+ continue;
+
+ comp = memcmp (candidate->sysid, adj->sysid, ISIS_SYS_ID_LEN);
+ if (comp > 0)
+ {
+ excess = node;
+ candidate = adj;
+ continue;
+ }
+ if (comp < 0)
+ continue;
- if (candidate->circuit->circuit_id < adj->circuit->circuit_id)
- continue;
-
- comp = memcmp (candidate->snpa, adj->snpa, ETH_ALEN);
- if (comp > 0) {
- excess = node;
- candidate = adj;
- continue;
+ if (candidate->circuit->circuit_id > adj->circuit->circuit_id)
+ {
+ excess = node;
+ candidate = adj;
+ continue;
+ }
+
+ if (candidate->circuit->circuit_id < adj->circuit->circuit_id)
+ continue;
+
+ comp = memcmp (candidate->snpa, adj->snpa, ETH_ALEN);
+ if (comp > 0)
+ {
+ excess = node;
+ candidate = adj;
+ continue;
+ }
}
- }
-
+
list_delete_node (adjs, excess);
return;
@@ -135,59 +143,61 @@ remove_excess_adjs (struct list *adjs)
const char *
vtype2string (enum vertextype vtype)
{
- switch (vtype) {
- case VTYPE_PSEUDO_IS:
- return "pseudo_IS";
- break;
- case VTYPE_NONPSEUDO_IS:
- return "IS";
- break;
- case VTYPE_ES:
- return "ES";
- break;
- case VTYPE_IPREACH_INTERNAL:
- return "IP internal";
- break;
- case VTYPE_IPREACH_EXTERNAL:
- return "IP external";
- break;
+ switch (vtype)
+ {
+ case VTYPE_PSEUDO_IS:
+ return "pseudo_IS";
+ break;
+ case VTYPE_NONPSEUDO_IS:
+ return "IS";
+ break;
+ case VTYPE_ES:
+ return "ES";
+ break;
+ case VTYPE_IPREACH_INTERNAL:
+ return "IP internal";
+ break;
+ case VTYPE_IPREACH_EXTERNAL:
+ return "IP external";
+ break;
#ifdef HAVE_IPV6
- case VTYPE_IP6REACH_INTERNAL:
- return "IP6 internal";
- break;
- case VTYPE_IP6REACH_EXTERNAL:
- return "IP6 external";
- break;
-#endif /* HAVE_IPV6 */
- default:
- return "UNKNOWN";
- }
- return NULL; /* Not reached */
+ case VTYPE_IP6REACH_INTERNAL:
+ return "IP6 internal";
+ break;
+ case VTYPE_IP6REACH_EXTERNAL:
+ return "IP6 external";
+ break;
+#endif /* HAVE_IPV6 */
+ default:
+ return "UNKNOWN";
+ }
+ return NULL; /* Not reached */
}
char *
-vid2string (struct isis_vertex *vertex, u_char *buff)
+vid2string (struct isis_vertex *vertex, u_char * buff)
{
- switch (vertex->type) {
- case VTYPE_PSEUDO_IS:
- return rawlspid_print (vertex->N.id);
- break;
- case VTYPE_NONPSEUDO_IS:
- case VTYPE_ES:
- return sysid_print (vertex->N.id);
- break;
- case VTYPE_IPREACH_INTERNAL:
- case VTYPE_IPREACH_EXTERNAL:
+ switch (vertex->type)
+ {
+ case VTYPE_PSEUDO_IS:
+ return rawlspid_print (vertex->N.id);
+ break;
+ case VTYPE_NONPSEUDO_IS:
+ case VTYPE_ES:
+ return sysid_print (vertex->N.id);
+ break;
+ case VTYPE_IPREACH_INTERNAL:
+ case VTYPE_IPREACH_EXTERNAL:
#ifdef HAVE_IPV6
- case VTYPE_IP6REACH_INTERNAL:
- case VTYPE_IP6REACH_EXTERNAL:
-#endif /* HAVE_IPV6 */
- prefix2str ((struct prefix *)&vertex->N.prefix, buff, BUFSIZ);
- break;
- default:
- return "UNKNOWN";
- }
-
+ case VTYPE_IP6REACH_INTERNAL:
+ case VTYPE_IP6REACH_EXTERNAL:
+#endif /* HAVE_IPV6 */
+ prefix2str ((struct prefix *) &vertex->N.prefix, buff, BUFSIZ);
+ break;
+ default:
+ return "UNKNOWN";
+ }
+
return buff;
}
@@ -197,36 +207,35 @@ isis_spftree_new ()
struct isis_spftree *tree;
tree = XMALLOC (MTYPE_ISIS_SPFTREE, sizeof (struct isis_spftree));
- if (tree == NULL) {
- zlog_err ("ISIS-Spf: isis_spftree_new Out of memory!");
- return NULL;
- }
+ if (tree == NULL)
+ {
+ zlog_err ("ISIS-Spf: isis_spftree_new Out of memory!");
+ return NULL;
+ }
memset (tree, 0, sizeof (struct isis_spftree));
tree->tents = list_new ();
- tree->paths = list_new ();
+ tree->paths = list_new ();
return tree;
}
void
isis_vertex_del (struct isis_vertex *vertex)
{
-
list_delete (vertex->Adj_N);
XFREE (MTYPE_ISIS_VERTEX, vertex);
-
+
return;
}
void
isis_spftree_del (struct isis_spftree *spftree)
{
-
- spftree->tents->del = (void *)isis_vertex_del;
+ spftree->tents->del = (void *) isis_vertex_del;
list_delete (spftree->tents);
-
- spftree->paths->del = (void *)isis_vertex_del;
+
+ spftree->paths->del = (void *) isis_vertex_del;
list_delete (spftree->paths);
XFREE (MTYPE_ISIS_SPFTREE, spftree);
@@ -234,28 +243,29 @@ isis_spftree_del (struct isis_spftree *spftree)
return;
}
-void
+void
spftree_area_init (struct isis_area *area)
{
-
- if ((area->is_type & IS_LEVEL_1) && area->spftree[0] == NULL) {
- area->spftree[0] = isis_spftree_new ();
+ if ((area->is_type & IS_LEVEL_1) && area->spftree[0] == NULL)
+ {
+ area->spftree[0] = isis_spftree_new ();
#ifdef HAVE_IPV6
- area->spftree6[0] = isis_spftree_new ();
+ area->spftree6[0] = isis_spftree_new ();
#endif
- /* thread_add_timer (master, isis_run_spf_l1, area,
- isis_jitter (PERIODIC_SPF_INTERVAL, 10)); */
- }
-
- if ((area->is_type & IS_LEVEL_2) && area->spftree[1] == NULL) {
- area->spftree[1] = isis_spftree_new ();
+ /* thread_add_timer (master, isis_run_spf_l1, area,
+ isis_jitter (PERIODIC_SPF_INTERVAL, 10)); */
+ }
+
+ if ((area->is_type & IS_LEVEL_2) && area->spftree[1] == NULL)
+ {
+ area->spftree[1] = isis_spftree_new ();
#ifdef HAVE_IPV6
- area->spftree6[1] = isis_spftree_new ();
+ area->spftree6[1] = isis_spftree_new ();
#endif
- /* thread_add_timer (master, isis_run_spf_l2, area,
- isis_jitter (PERIODIC_SPF_INTERVAL, 10)); */
- }
+ /* thread_add_timer (master, isis_run_spf_l2, area,
+ isis_jitter (PERIODIC_SPF_INTERVAL, 10)); */
+ }
return;
}
@@ -266,36 +276,38 @@ isis_vertex_new (void *id, enum vertextype vtype)
struct isis_vertex *vertex;
vertex = XMALLOC (MTYPE_ISIS_VERTEX, sizeof (struct isis_vertex));
- if (vertex == NULL) {
- zlog_err ("isis_vertex_new Out of memory!");
- return NULL;
- }
-
+ if (vertex == NULL)
+ {
+ zlog_err ("isis_vertex_new Out of memory!");
+ return NULL;
+ }
+
memset (vertex, 0, sizeof (struct isis_vertex));
vertex->type = vtype;
- switch (vtype) {
- case VTYPE_ES:
- case VTYPE_NONPSEUDO_IS:
- memcpy (vertex->N.id, (u_char *)id, ISIS_SYS_ID_LEN);
- break;
- case VTYPE_PSEUDO_IS:
- memcpy (vertex->N.id, (u_char *)id, ISIS_SYS_ID_LEN + 1);
- break;
- case VTYPE_IPREACH_INTERNAL:
- case VTYPE_IPREACH_EXTERNAL:
+ switch (vtype)
+ {
+ case VTYPE_ES:
+ case VTYPE_NONPSEUDO_IS:
+ memcpy (vertex->N.id, (u_char *) id, ISIS_SYS_ID_LEN);
+ break;
+ case VTYPE_PSEUDO_IS:
+ memcpy (vertex->N.id, (u_char *) id, ISIS_SYS_ID_LEN + 1);
+ break;
+ case VTYPE_IPREACH_INTERNAL:
+ case VTYPE_IPREACH_EXTERNAL:
#ifdef HAVE_IPV6
- case VTYPE_IP6REACH_INTERNAL:
- case VTYPE_IP6REACH_EXTERNAL:
-#endif /* HAVE_IPV6 */
- memcpy (&vertex->N.prefix, (struct prefix *)id,
- sizeof (struct prefix));
- break;
- default:
- zlog_err ("WTF!");
- }
+ case VTYPE_IP6REACH_INTERNAL:
+ case VTYPE_IP6REACH_EXTERNAL:
+#endif /* HAVE_IPV6 */
+ memcpy (&vertex->N.prefix, (struct prefix *) id,
+ sizeof (struct prefix));
+ break;
+ default:
+ zlog_err ("WTF!");
+ }
vertex->Adj_N = list_new ();
-
+
return vertex;
}
@@ -304,7 +316,7 @@ isis_vertex_new (void *id, enum vertextype vtype)
*/
void
isis_spf_add_self (struct isis_spftree *spftree, struct isis_area *area,
- int level)
+ int level)
{
struct isis_vertex *vertex;
struct isis_lsp *lsp;
@@ -313,14 +325,14 @@ isis_spf_add_self (struct isis_spftree *spftree, struct isis_area *area,
u_char buff[BUFSIZ];
#endif /* EXTREME_DEBUG */
memcpy (lspid, isis->sysid, ISIS_SYS_ID_LEN);
- LSP_PSEUDO_ID(lspid) = 0;
- LSP_FRAGMENT(lspid) = 0;
-
+ LSP_PSEUDO_ID (lspid) = 0;
+ LSP_FRAGMENT (lspid) = 0;
+
lsp = lsp_search (lspid, area->lspdb[level - 1]);
-
+
if (lsp == NULL)
zlog_warn ("ISIS-Spf: could not find own l%d LSP!", level);
-
+
vertex = isis_vertex_new (isis->sysid, VTYPE_NONPSEUDO_IS);
vertex->lsp = lsp;
@@ -328,143 +340,156 @@ isis_spf_add_self (struct isis_spftree *spftree, struct isis_area *area,
#ifdef EXTREME_DEBUG
zlog_info ("ISIS-Spf: added this IS %s %s depth %d dist %d to PATHS",
- vtype2string(vertex->type), vid2string(vertex, buff),
- vertex->depth, vertex->d_N);
+ vtype2string (vertex->type), vid2string (vertex, buff),
+ vertex->depth, vertex->d_N);
#endif /* EXTREME_DEBUG */
return;
}
struct isis_vertex *
-isis_find_vertex (struct list *list, void *id, enum vertextype vtype)
+isis_find_vertex (struct list *list, void *id, enum vertextype vtype)
{
struct listnode *node;
struct isis_vertex *vertex;
struct prefix *p1, *p2;
- for (node = listhead (list); node; nextnode (node)) {
- vertex = getdata (node);
- if (vertex->type != vtype)
- continue;
- switch (vtype) {
- case VTYPE_ES:
- case VTYPE_NONPSEUDO_IS:
- if (memcmp ((u_char *)id, vertex->N.id, ISIS_SYS_ID_LEN) == 0)
- return vertex;
- break;
- case VTYPE_PSEUDO_IS:
- if (memcmp ((u_char *)id, vertex->N.id, ISIS_SYS_ID_LEN + 1) == 0)
- return vertex;
- break;
- case VTYPE_IPREACH_INTERNAL:
- case VTYPE_IPREACH_EXTERNAL:
+ for (node = listhead (list); node; nextnode (node))
+ {
+ vertex = getdata (node);
+ if (vertex->type != vtype)
+ continue;
+ switch (vtype)
+ {
+ case VTYPE_ES:
+ case VTYPE_NONPSEUDO_IS:
+ if (memcmp ((u_char *) id, vertex->N.id, ISIS_SYS_ID_LEN) == 0)
+ return vertex;
+ break;
+ case VTYPE_PSEUDO_IS:
+ if (memcmp ((u_char *) id, vertex->N.id, ISIS_SYS_ID_LEN + 1) == 0)
+ return vertex;
+ break;
+ case VTYPE_IPREACH_INTERNAL:
+ case VTYPE_IPREACH_EXTERNAL:
#ifdef HAVE_IPV6
- case VTYPE_IP6REACH_INTERNAL:
- case VTYPE_IP6REACH_EXTERNAL:
+ case VTYPE_IP6REACH_INTERNAL:
+ case VTYPE_IP6REACH_EXTERNAL:
#endif /* HAVE_IPV6 */
- p1 = (struct prefix *)id;
- p2 = (struct prefix *)&vertex->N.id;
- if (p1->family == p2->family && p1->prefixlen == p2->prefixlen &&
- memcmp (&p1->u.prefix, &p2->u.prefix, PSIZE (p1->prefixlen)) == 0)
- return vertex;
- break;
+ p1 = (struct prefix *) id;
+ p2 = (struct prefix *) &vertex->N.id;
+ if (p1->family == p2->family && p1->prefixlen == p2->prefixlen &&
+ memcmp (&p1->u.prefix, &p2->u.prefix,
+ PSIZE (p1->prefixlen)) == 0)
+ return vertex;
+ break;
+ }
}
- }
return NULL;
}
-
-
/*
* Add a vertex to TENT sorted by cost and by vertextype on tie break situation
*/
struct isis_vertex *
-isis_spf_add2tent (struct isis_spftree *spftree, enum vertextype vtype,
- void *id, struct isis_adjacency *adj, u_int16_t cost,
- int depth, int family)
+isis_spf_add2tent (struct isis_spftree *spftree, enum vertextype vtype,
+ void *id, struct isis_adjacency *adj, u_int16_t cost,
+ int depth, int family)
{
struct isis_vertex *vertex, *v;
struct listnode *node;
-#ifdef EXTREME_DEBUG
+#ifdef EXTREME_DEBUG
u_char buff[BUFSIZ];
#endif
vertex = isis_vertex_new (id, vtype);
vertex->d_N = cost;
vertex->depth = depth;
-
+
if (adj)
listnode_add (vertex->Adj_N, adj);
-#ifdef EXTREME_DEBUG
+#ifdef EXTREME_DEBUG
zlog_info ("ISIS-Spf: add to TENT %s %s depth %d dist %d",
- vtype2string(vertex->type), vid2string(vertex, buff),
- vertex->depth, vertex->d_N);
+ vtype2string (vertex->type), vid2string (vertex, buff),
+ vertex->depth, vertex->d_N);
#endif /* EXTREME_DEBUG */
- listnode_add (spftree->tents, vertex);
- if (list_isempty (spftree->tents)) {
- listnode_add (spftree->tents, vertex);
- return vertex;
- }
- for (node = listhead (spftree->tents); node; nextnode (node)) {
- v = getdata (node);
- if (v->d_N > vertex->d_N) {
- list_add_node_prev (spftree->tents, node, vertex);
- break;
- } else if (v->d_N == vertex->d_N) {
- /* Tie break, add according to type */
- while (v && v->d_N == vertex->d_N && v->type > vertex->type) {
- if (v->type > vertex->type) {
- break;
- }
- nextnode (node);
- (node) ? (v = getdata (node)) : (v = NULL);
- }
- list_add_node_prev (spftree->tents, node, vertex);
- break;
- } else if (node->next == NULL) {
- list_add_node_next (spftree->tents, node, vertex);
- break;
+ listnode_add (spftree->tents, vertex);
+ if (list_isempty (spftree->tents))
+ {
+ listnode_add (spftree->tents, vertex);
+ return vertex;
+ }
+ for (node = listhead (spftree->tents); node; nextnode (node))
+ {
+ v = getdata (node);
+ if (v->d_N > vertex->d_N)
+ {
+ list_add_node_prev (spftree->tents, node, vertex);
+ break;
+ }
+ else if (v->d_N == vertex->d_N)
+ {
+ /* Tie break, add according to type */
+ while (v && v->d_N == vertex->d_N && v->type > vertex->type)
+ {
+ if (v->type > vertex->type)
+ {
+ break;
+ }
+ nextnode (node);
+ (node) ? (v = getdata (node)) : (v = NULL);
+ }
+ list_add_node_prev (spftree->tents, node, vertex);
+ break;
+ }
+ else if (node->next == NULL)
+ {
+ list_add_node_next (spftree->tents, node, vertex);
+ break;
+ }
}
- }
return vertex;
}
struct isis_vertex *
-isis_spf_add_local (struct isis_spftree *spftree, enum vertextype vtype,
- void *id, struct isis_adjacency *adj, u_int16_t cost,
- int family)
+isis_spf_add_local (struct isis_spftree *spftree, enum vertextype vtype,
+ void *id, struct isis_adjacency *adj, u_int16_t cost,
+ int family)
{
struct isis_vertex *vertex;
-
- vertex = isis_find_vertex (spftree->tents, id, vtype);
-
- if (vertex) {
- /* C.2.5 c) */
- if (vertex->d_N == cost) {
- if (adj)
- listnode_add (vertex->Adj_N, adj);
- /* d) */
- if (listcount (vertex->Adj_N) > ISIS_MAX_PATH_SPLITS)
- remove_excess_adjs (vertex->Adj_N);
- }
- /* f) */
- else if (vertex->d_N > cost) {
- listnode_delete (spftree->tents, vertex);
- goto add2tent;
+
+ vertex = isis_find_vertex (spftree->tents, id, vtype);
+
+ if (vertex)
+ {
+ /* C.2.5 c) */
+ if (vertex->d_N == cost)
+ {
+ if (adj)
+ listnode_add (vertex->Adj_N, adj);
+ /* d) */
+ if (listcount (vertex->Adj_N) > ISIS_MAX_PATH_SPLITS)
+ remove_excess_adjs (vertex->Adj_N);
+ }
+ /* f) */
+ else if (vertex->d_N > cost)
+ {
+ listnode_delete (spftree->tents, vertex);
+ goto add2tent;
+ }
+ /* e) do nothing */
+ return vertex;
}
- /* e) do nothing */
- return vertex;
- }
- add2tent:
+add2tent:
return isis_spf_add2tent (spftree, vtype, id, adj, cost, 1, family);
}
void
-process_N (struct isis_spftree *spftree, enum vertextype vtype, void *id,
- u_int16_t dist, u_int16_t depth, struct isis_adjacency *adj,
- int family)
+process_N (struct isis_spftree *spftree, enum vertextype vtype, void *id,
+ u_int16_t dist, u_int16_t depth, struct isis_adjacency *adj,
+ int family)
{
struct isis_vertex *vertex;
#ifdef EXTREME_DEBUG
@@ -476,39 +501,46 @@ process_N (struct isis_spftree *spftree, enum vertextype vtype, void *id,
return;
/* c) */
vertex = isis_find_vertex (spftree->paths, id, vtype);
- if (vertex) {
+ if (vertex)
+ {
#ifdef EXTREME_DEBUG
- zlog_info ("ISIS-Spf: process_N %s %s dist %d already found from PATH",
- vtype2string(vtype), vid2string(vertex, buff), dist);
+ zlog_info ("ISIS-Spf: process_N %s %s dist %d already found from PATH",
+ vtype2string (vtype), vid2string (vertex, buff), dist);
#endif /* EXTREME_DEBUG */
- assert (dist >= vertex->d_N);
- return;
- }
+ assert (dist >= vertex->d_N);
+ return;
+ }
vertex = isis_find_vertex (spftree->tents, id, vtype);
- /* d) */
- if (vertex) {
- /* 1) */
+ /* d) */
+ if (vertex)
+ {
+ /* 1) */
#ifdef EXTREME_DEBUG
- zlog_info ("ISIS-Spf: process_N %s %s dist %d",
- vtype2string(vtype), vid2string(vertex, buff), dist);
+ zlog_info ("ISIS-Spf: process_N %s %s dist %d",
+ vtype2string (vtype), vid2string (vertex, buff), dist);
#endif /* EXTREME_DEBUG */
- if (vertex->d_N == dist) {
- if (adj)
- listnode_add (vertex->Adj_N, adj);
- /* 2) */
- if (listcount(vertex->Adj_N) > ISIS_MAX_PATH_SPLITS)
- remove_excess_adjs (vertex->Adj_N);
- /* 3) */
- return;
- } else if (vertex->d_N < dist) {
- return;
- /* 4) */
- } else {
- listnode_delete (spftree->tents, vertex);
+ if (vertex->d_N == dist)
+ {
+ if (adj)
+ listnode_add (vertex->Adj_N, adj);
+ /* 2) */
+ if (listcount (vertex->Adj_N) > ISIS_MAX_PATH_SPLITS)
+ remove_excess_adjs (vertex->Adj_N);
+ /* 3) */
+ return;
+ }
+ else if (vertex->d_N < dist)
+ {
+ return;
+ /* 4) */
+ }
+ else
+ {
+ listnode_delete (spftree->tents, vertex);
+ }
}
- }
-
+
isis_spf_add2tent (spftree, vtype, id, adj, dist, depth, family);
return;
}
@@ -517,8 +549,8 @@ process_N (struct isis_spftree *spftree, enum vertextype vtype, void *id,
* C.2.6 Step 1
*/
int
-isis_spf_process_lsp (struct isis_spftree *spftree, struct isis_lsp *lsp,
- uint16_t cost, uint16_t depth, int family)
+isis_spf_process_lsp (struct isis_spftree *spftree, struct isis_lsp *lsp,
+ uint16_t cost, uint16_t depth, int family)
{
struct listnode *node, *fragnode = NULL;
u_int16_t dist;
@@ -529,147 +561,162 @@ isis_spf_process_lsp (struct isis_spftree *spftree, struct isis_lsp *lsp,
#ifdef HAVE_IPV6
struct ipv6_reachability *ip6reach;
#endif /* HAVE_IPV6 */
-
+
if (!lsp->adj)
return ISIS_WARNING;
- if (lsp->tlv_data.nlpids == NULL ||
- !speaks (lsp->tlv_data.nlpids, family))
+ if (lsp->tlv_data.nlpids == NULL || !speaks (lsp->tlv_data.nlpids, family))
return ISIS_OK;
- lspfragloop:
- if (lsp->lsp_header->seq_num == 0) {
- zlog_warn ("isis_spf_process_lsp(): lsp with 0 seq_num"
- " - do not process");
- return ISIS_WARNING;
- }
-
- if (!ISIS_MASK_LSP_OL_BIT(lsp->lsp_header->lsp_bits)) {
- if (lsp->tlv_data.is_neighs) {
- for (node = listhead (lsp->tlv_data.is_neighs); node; nextnode (node)) {
- is_neigh = getdata (node);
- /* C.2.6 a) */
- /* Two way connectivity */
- if (!memcmp (is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN))
- continue;
- dist = cost + is_neigh->metrics.metric_default;
- vtype = LSP_PSEUDO_ID(is_neigh->neigh_id) ? VTYPE_PSEUDO_IS
- : VTYPE_NONPSEUDO_IS;
- process_N (spftree, vtype, (void *)is_neigh->neigh_id, dist, depth+1,
- lsp->adj, family);
- }
- }
- if (family == AF_INET && lsp->tlv_data.ipv4_int_reachs) {
- prefix.family = AF_INET;
- for (node = listhead (lsp->tlv_data.ipv4_int_reachs); node;
- nextnode (node)) {
- ipreach = getdata (node);
- dist = cost + ipreach->metrics.metric_default;
- vtype = VTYPE_IPREACH_INTERNAL;
- prefix.u.prefix4 = ipreach->prefix;
- prefix.prefixlen = ip_masklen (ipreach->mask);
- process_N (spftree, vtype, (void *)&prefix, dist, depth + 1,
- lsp->adj, family);
- }
- }
-
- if (family == AF_INET && lsp->tlv_data.ipv4_ext_reachs) {
- prefix.family = AF_INET;
- for (node = listhead (lsp->tlv_data.ipv4_ext_reachs); node;
- nextnode (node)) {
- ipreach = getdata (node);
- dist = cost + ipreach->metrics.metric_default;
- vtype = VTYPE_IPREACH_EXTERNAL;
- prefix.u.prefix4 = ipreach->prefix;
- prefix.prefixlen = ip_masklen (ipreach->mask);
- process_N (spftree, vtype, (void *)&prefix, dist, depth + 1,
- lsp->adj, family);
- }
+lspfragloop:
+ if (lsp->lsp_header->seq_num == 0)
+ {
+ zlog_warn ("isis_spf_process_lsp(): lsp with 0 seq_num"
+ " - do not process");
+ return ISIS_WARNING;
}
+
+ if (!ISIS_MASK_LSP_OL_BIT (lsp->lsp_header->lsp_bits))
+ {
+ if (lsp->tlv_data.is_neighs)
+ {
+ for (node = listhead (lsp->tlv_data.is_neighs); node;
+ nextnode (node))
+ {
+ is_neigh = getdata (node);
+ /* C.2.6 a) */
+ /* Two way connectivity */
+ if (!memcmp (is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN))
+ continue;
+ dist = cost + is_neigh->metrics.metric_default;
+ vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS
+ : VTYPE_NONPSEUDO_IS;
+ process_N (spftree, vtype, (void *) is_neigh->neigh_id, dist,
+ depth + 1, lsp->adj, family);
+ }
+ }
+ if (family == AF_INET && lsp->tlv_data.ipv4_int_reachs)
+ {
+ prefix.family = AF_INET;
+ for (node = listhead (lsp->tlv_data.ipv4_int_reachs); node;
+ nextnode (node))
+ {
+ ipreach = getdata (node);
+ dist = cost + ipreach->metrics.metric_default;
+ vtype = VTYPE_IPREACH_INTERNAL;
+ prefix.u.prefix4 = ipreach->prefix;
+ prefix.prefixlen = ip_masklen (ipreach->mask);
+ process_N (spftree, vtype, (void *) &prefix, dist, depth + 1,
+ lsp->adj, family);
+ }
+ }
+
+ if (family == AF_INET && lsp->tlv_data.ipv4_ext_reachs)
+ {
+ prefix.family = AF_INET;
+ for (node = listhead (lsp->tlv_data.ipv4_ext_reachs); node;
+ nextnode (node))
+ {
+ ipreach = getdata (node);
+ dist = cost + ipreach->metrics.metric_default;
+ vtype = VTYPE_IPREACH_EXTERNAL;
+ prefix.u.prefix4 = ipreach->prefix;
+ prefix.prefixlen = ip_masklen (ipreach->mask);
+ process_N (spftree, vtype, (void *) &prefix, dist, depth + 1,
+ lsp->adj, family);
+ }
+ }
#ifdef HAVE_IPV6
- if (family == AF_INET6 && lsp->tlv_data.ipv6_reachs) {
- prefix.family = AF_INET6;
- for (node = listhead (lsp->tlv_data.ipv6_reachs); node;
- nextnode (node)) {
- ip6reach = getdata (node);
- dist = cost + ip6reach->metric;
- vtype = (ip6reach->control_info & CTRL_INFO_DISTRIBUTION) ?
- VTYPE_IP6REACH_EXTERNAL : VTYPE_IP6REACH_INTERNAL;
- prefix.prefixlen = ip6reach->prefix_len;
- memcpy (&prefix.u.prefix6.s6_addr, ip6reach->prefix,
- PSIZE(ip6reach->prefix_len));
- process_N (spftree, vtype, (void *)&prefix, dist, depth + 1,
- lsp->adj, family);
- }
- }
+ if (family == AF_INET6 && lsp->tlv_data.ipv6_reachs)
+ {
+ prefix.family = AF_INET6;
+ for (node = listhead (lsp->tlv_data.ipv6_reachs); node;
+ nextnode (node))
+ {
+ ip6reach = getdata (node);
+ dist = cost + ip6reach->metric;
+ vtype = (ip6reach->control_info & CTRL_INFO_DISTRIBUTION) ?
+ VTYPE_IP6REACH_EXTERNAL : VTYPE_IP6REACH_INTERNAL;
+ prefix.prefixlen = ip6reach->prefix_len;
+ memcpy (&prefix.u.prefix6.s6_addr, ip6reach->prefix,
+ PSIZE (ip6reach->prefix_len));
+ process_N (spftree, vtype, (void *) &prefix, dist, depth + 1,
+ lsp->adj, family);
+ }
+ }
#endif /* HAVE_IPV6 */
- }
-
+ }
+
if (fragnode == NULL)
fragnode = listhead (lsp->lspu.frags);
- else
+ else
fragnode = nextnode (fragnode);
- if (fragnode) {
- lsp = getdata (fragnode);
- goto lspfragloop;
- }
-
+ if (fragnode)
+ {
+ lsp = getdata (fragnode);
+ goto lspfragloop;
+ }
+
return ISIS_OK;
}
int
-isis_spf_process_pseudo_lsp (struct isis_spftree *spftree,struct isis_lsp *lsp,
- uint16_t cost, uint16_t depth, int family)
+isis_spf_process_pseudo_lsp (struct isis_spftree *spftree,
+ struct isis_lsp *lsp, uint16_t cost,
+ uint16_t depth, int family)
{
struct listnode *node, *fragnode = NULL;
struct is_neigh *is_neigh;
enum vertextype vtype;
-
- pseudofragloop:
-
- if (lsp->lsp_header->seq_num == 0) {
- zlog_warn ("isis_spf_process_pseudo_lsp(): lsp with 0 seq_num"
- " - do not process");
- return ISIS_WARNING;
- }
-
- for (node = (lsp->tlv_data.is_neighs ?
- listhead (lsp->tlv_data.is_neighs) : NULL);
- node; nextnode (node)) {
- is_neigh = getdata (node);
- vtype = LSP_PSEUDO_ID(is_neigh->neigh_id) ? VTYPE_PSEUDO_IS
- : VTYPE_NONPSEUDO_IS;
- /* Two way connectivity */
- if (!memcmp (is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN))
- continue;
- if (isis_find_vertex (spftree->tents, (void *)is_neigh->neigh_id, vtype)
- == NULL &&
- isis_find_vertex (spftree->paths, (void *)is_neigh->neigh_id, vtype)
- == NULL) {
- /* C.2.5 i) */
- isis_spf_add2tent (spftree, vtype, is_neigh->neigh_id, lsp->adj,
- cost, depth, family);
+
+pseudofragloop:
+
+ if (lsp->lsp_header->seq_num == 0)
+ {
+ zlog_warn ("isis_spf_process_pseudo_lsp(): lsp with 0 seq_num"
+ " - do not process");
+ return ISIS_WARNING;
}
- }
-
+
+ for (node = (lsp->tlv_data.is_neighs ?
+ listhead (lsp->tlv_data.is_neighs) : NULL);
+ node; nextnode (node))
+ {
+ is_neigh = getdata (node);
+ vtype = LSP_PSEUDO_ID (is_neigh->neigh_id) ? VTYPE_PSEUDO_IS
+ : VTYPE_NONPSEUDO_IS;
+ /* Two way connectivity */
+ if (!memcmp (is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN))
+ continue;
+ if (isis_find_vertex
+ (spftree->tents, (void *) is_neigh->neigh_id, vtype) == NULL
+ && isis_find_vertex (spftree->paths, (void *) is_neigh->neigh_id,
+ vtype) == NULL)
+ {
+ /* C.2.5 i) */
+ isis_spf_add2tent (spftree, vtype, is_neigh->neigh_id, lsp->adj,
+ cost, depth, family);
+ }
+ }
+
if (fragnode == NULL)
fragnode = listhead (lsp->lspu.frags);
- else
+ else
fragnode = nextnode (fragnode);
- if (fragnode) {
- lsp = getdata (fragnode);
- goto pseudofragloop;
- }
+ if (fragnode)
+ {
+ lsp = getdata (fragnode);
+ goto pseudofragloop;
+ }
-
return ISIS_OK;
}
-
+
int
-isis_spf_preload_tent (struct isis_spftree *spftree,
- struct isis_area *area, int level, int family)
+isis_spf_preload_tent (struct isis_spftree *spftree,
+ struct isis_area *area, int level, int family)
{
struct isis_vertex *vertex;
struct isis_circuit *circuit;
@@ -685,148 +732,172 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
#ifdef HAVE_IPV6
struct prefix_ipv6 *ipv6;
#endif /* HAVE_IPV6 */
-
- for (cnode = listhead (area->circuit_list); cnode; nextnode (cnode)) {
- circuit = getdata (cnode);
- if (circuit->state != C_STATE_UP)
- continue;
- if (!(circuit->circuit_is_type & level))
- continue;
- if (family == AF_INET && !circuit->ip_router)
- continue;
+
+ for (cnode = listhead (area->circuit_list); cnode; nextnode (cnode))
+ {
+ circuit = getdata (cnode);
+ if (circuit->state != C_STATE_UP)
+ continue;
+ if (!(circuit->circuit_is_type & level))
+ continue;
+ if (family == AF_INET && !circuit->ip_router)
+ continue;
#ifdef HAVE_IPV6
- if (family == AF_INET6 && !circuit->ipv6_router)
- continue;
+ if (family == AF_INET6 && !circuit->ipv6_router)
+ continue;
#endif /* HAVE_IPV6 */
- /*
- * Add IP(v6) addresses of this circuit
- */
- if (family == AF_INET) {
- prefix.family = AF_INET;
- for (ipnode = (circuit->ip_addrs ? listhead (circuit->ip_addrs) : NULL);
- ipnode; nextnode (ipnode)) {
- ipv4 = getdata (ipnode);
- prefix.u.prefix4 = ipv4->prefix;
- prefix.prefixlen = ipv4->prefixlen;
- isis_spf_add_local (spftree, VTYPE_IPREACH_INTERNAL, &prefix, NULL, 0,
- family);
- }
- }
+ /*
+ * Add IP(v6) addresses of this circuit
+ */
+ if (family == AF_INET)
+ {
+ prefix.family = AF_INET;
+ for (ipnode =
+ (circuit->ip_addrs ? listhead (circuit->ip_addrs) : NULL);
+ ipnode; nextnode (ipnode))
+ {
+ ipv4 = getdata (ipnode);
+ prefix.u.prefix4 = ipv4->prefix;
+ prefix.prefixlen = ipv4->prefixlen;
+ isis_spf_add_local (spftree, VTYPE_IPREACH_INTERNAL, &prefix,
+ NULL, 0, family);
+ }
+ }
#ifdef HAVE_IPV6
- if (family == AF_INET6) {
- prefix.family = AF_INET6;
- for (ipnode = (circuit->ipv6_non_link ? listhead
- (circuit->ipv6_non_link) : NULL); ipnode;
- nextnode (ipnode)) {
- ipv6 = getdata (ipnode);
- prefix.prefixlen = ipv6->prefixlen;
- prefix.u.prefix6 = ipv6->prefix;
- isis_spf_add_local (spftree, VTYPE_IP6REACH_INTERNAL,
- &prefix, NULL, 0, family);
- }
- }
+ if (family == AF_INET6)
+ {
+ prefix.family = AF_INET6;
+ for (ipnode = (circuit->ipv6_non_link ? listhead
+ (circuit->ipv6_non_link) : NULL); ipnode;
+ nextnode (ipnode))
+ {
+ ipv6 = getdata (ipnode);
+ prefix.prefixlen = ipv6->prefixlen;
+ prefix.u.prefix6 = ipv6->prefix;
+ isis_spf_add_local (spftree, VTYPE_IP6REACH_INTERNAL,
+ &prefix, NULL, 0, family);
+ }
+ }
#endif /* HAVE_IPV6 */
- if (circuit->circ_type == CIRCUIT_T_BROADCAST ) {
- /*
- * Add the adjacencies
- */
- adj_list = list_new ();
- adjdb = circuit->u.bc.adjdb[level - 1];
- isis_adj_build_up_list (adjdb, adj_list);
- if (listcount (adj_list) == 0) {
- list_delete (adj_list);
- zlog_warn ("ISIS-Spf: no L%d adjacencies on circuit %s",
- level, circuit->interface->name);
- continue;
- }
- anode = listhead (adj_list);
- while (anode) {
- adj = getdata (anode);
- if (!speaks (&adj->nlpids, family)) {
- anode = nextnode (anode);
- continue;
- }
- switch (adj->sys_type) {
- case ISIS_SYSTYPE_ES:
- isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj,
- circuit->metrics[level - 1].metric_default,
- family);
- break;
- case ISIS_SYSTYPE_IS:
- case ISIS_SYSTYPE_L1_IS:
- case ISIS_SYSTYPE_L2_IS:
- vertex =
- isis_spf_add_local (spftree, VTYPE_NONPSEUDO_IS,
- adj->sysid, adj,
- circuit->metrics[level - 1].metric_default,
- family);
- memcpy (lsp_id, adj->sysid, ISIS_SYS_ID_LEN);
- LSP_PSEUDO_ID(lsp_id) = 0;
- LSP_FRAGMENT(lsp_id) = 0;
- lsp = lsp_search (lsp_id, area->lspdb[level - 1]);
- if (!lsp)
- zlog_warn ("No lsp found for IS adjacency");
- /* else {
- isis_spf_process_lsp (spftree, lsp, vertex->d_N, 1, family);
- } */
- break;
- case ISIS_SYSTYPE_UNKNOWN:
- default:
- zlog_warn ("isis_spf_preload_tent unknow adj type");
- }
- anode = nextnode (anode);
- }
- list_delete (adj_list);
- /*
- * Add the pseudonode
- */
- if (level == 1)
- memcpy (lsp_id, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ /*
+ * Add the adjacencies
+ */
+ adj_list = list_new ();
+ adjdb = circuit->u.bc.adjdb[level - 1];
+ isis_adj_build_up_list (adjdb, adj_list);
+ if (listcount (adj_list) == 0)
+ {
+ list_delete (adj_list);
+ zlog_warn ("ISIS-Spf: no L%d adjacencies on circuit %s",
+ level, circuit->interface->name);
+ continue;
+ }
+ anode = listhead (adj_list);
+ while (anode)
+ {
+ adj = getdata (anode);
+ if (!speaks (&adj->nlpids, family))
+ {
+ anode = nextnode (anode);
+ continue;
+ }
+ switch (adj->sys_type)
+ {
+ case ISIS_SYSTYPE_ES:
+ isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj,
+ circuit->metrics[level -
+ 1].metric_default,
+ family);
+ break;
+ case ISIS_SYSTYPE_IS:
+ case ISIS_SYSTYPE_L1_IS:
+ case ISIS_SYSTYPE_L2_IS:
+ vertex =
+ isis_spf_add_local (spftree, VTYPE_NONPSEUDO_IS,
+ adj->sysid, adj,
+ circuit->metrics[level -
+ 1].metric_default,
+ family);
+ memcpy (lsp_id, adj->sysid, ISIS_SYS_ID_LEN);
+ LSP_PSEUDO_ID (lsp_id) = 0;
+ LSP_FRAGMENT (lsp_id) = 0;
+ lsp = lsp_search (lsp_id, area->lspdb[level - 1]);
+ if (!lsp)
+ zlog_warn ("No lsp found for IS adjacency");
+ /* else {
+ isis_spf_process_lsp (spftree, lsp, vertex->d_N, 1, family);
+ } */
+ break;
+ case ISIS_SYSTYPE_UNKNOWN:
+ default:
+ zlog_warn ("isis_spf_preload_tent unknow adj type");
+ }
+ anode = nextnode (anode);
+ }
+ list_delete (adj_list);
+ /*
+ * Add the pseudonode
+ */
+ if (level == 1)
+ memcpy (lsp_id, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1);
+ else
+ memcpy (lsp_id, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
+ lsp = lsp_search (lsp_id, area->lspdb[level - 1]);
+ adj = isis_adj_lookup (lsp_id, adjdb);
+ /* if no adj, we are the dis or error */
+ if (!adj && !circuit->u.bc.is_dr[level - 1])
+ {
+ zlog_warn ("ISIS-Spf: No adjacency found for DR");
+ }
+ if (lsp == NULL || lsp->lsp_header->rem_lifetime == 0)
+ {
+ zlog_warn ("ISIS-Spf: No lsp found for DR");
+ }
+ else
+ {
+ isis_spf_process_pseudo_lsp
+ (spftree, lsp, circuit->metrics[level - 1].metric_default, 0,
+ family);
+
+ }
+ }
+ else if (circuit->circ_type == CIRCUIT_T_P2P)
+ {
+ adj = circuit->u.p2p.neighbor;
+ if (!adj)
+ continue;
+ switch (adj->sys_type)
+ {
+ case ISIS_SYSTYPE_ES:
+ isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj,
+ circuit->metrics[level - 1].metric_default,
+ family);
+ break;
+ case ISIS_SYSTYPE_IS:
+ case ISIS_SYSTYPE_L1_IS:
+ case ISIS_SYSTYPE_L2_IS:
+ if (speaks (&adj->nlpids, family))
+ isis_spf_add_local (spftree, VTYPE_NONPSEUDO_IS, adj->sysid,
+ adj,
+ circuit->metrics[level -
+ 1].metric_default,
+ family);
+ break;
+ case ISIS_SYSTYPE_UNKNOWN:
+ default:
+ zlog_warn ("isis_spf_preload_tent unknow adj type");
+ break;
+ }
+ }
else
- memcpy (lsp_id, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1);
- lsp = lsp_search (lsp_id, area->lspdb[level - 1]);
- adj = isis_adj_lookup (lsp_id, adjdb);
- /* if no adj, we are the dis or error */
- if (!adj && !circuit->u.bc.is_dr[level - 1]) {
- zlog_warn ("ISIS-Spf: No adjacency found for DR");
- }
- if (lsp == NULL || lsp->lsp_header->rem_lifetime == 0) {
- zlog_warn ("ISIS-Spf: No lsp found for DR");
- } else {
- isis_spf_process_pseudo_lsp
- (spftree, lsp, circuit->metrics[level - 1].metric_default, 0,
- family);
-
- }
- } else if (circuit->circ_type == CIRCUIT_T_P2P ) {
- adj = circuit->u.p2p.neighbor;
- if (!adj)
- continue;
- switch (adj->sys_type) {
- case ISIS_SYSTYPE_ES:
- isis_spf_add_local (spftree, VTYPE_ES, adj->sysid, adj,
- circuit->metrics[level - 1].metric_default,
- family);
- break;
- case ISIS_SYSTYPE_IS:
- case ISIS_SYSTYPE_L1_IS:
- case ISIS_SYSTYPE_L2_IS:
- if (speaks (&adj->nlpids, family))
- isis_spf_add_local (spftree, VTYPE_NONPSEUDO_IS, adj->sysid, adj,
- circuit->metrics[level - 1].metric_default,
- family);
- break;
- case ISIS_SYSTYPE_UNKNOWN:
- default:
- zlog_warn ("isis_spf_preload_tent unknow adj type");
- break;
- }
- } else {
- zlog_warn ("isis_spf_preload_tent unsupported media");
- retval = ISIS_WARNING;
+ {
+ zlog_warn ("isis_spf_preload_tent unsupported media");
+ retval = ISIS_WARNING;
+ }
+
}
-
- }
return retval;
}
@@ -837,39 +908,38 @@ isis_spf_preload_tent (struct isis_spftree *spftree,
*/
void
add_to_paths (struct isis_spftree *spftree, struct isis_vertex *vertex,
- struct isis_area *area)
+ struct isis_area *area)
{
-
#ifdef EXTREME_DEBUG
u_char buff[BUFSIZ];
#endif /* EXTREME_DEBUG */
listnode_add (spftree->paths, vertex);
-#ifdef EXTREME_DEBUG
+#ifdef EXTREME_DEBUG
zlog_info ("ISIS-Spf: added %s %s depth %d dist %d to PATHS",
- vtype2string(vertex->type), vid2string(vertex, buff),
- vertex->depth, vertex->d_N);
-#endif /* EXTREME_DEBUG */
- if (vertex->type > VTYPE_ES) {
- if (listcount(vertex->Adj_N) > 0)
- isis_route_create ((struct prefix *)&vertex->N.prefix,
- vertex->d_N, vertex->depth, vertex->Adj_N, area);
- else if (isis->debugs & DEBUG_SPF_EVENTS)
- zlog_info ("ISIS-Spf: no adjacencies do not install route");
- }
-
+ vtype2string (vertex->type), vid2string (vertex, buff),
+ vertex->depth, vertex->d_N);
+#endif /* EXTREME_DEBUG */
+ if (vertex->type > VTYPE_ES)
+ {
+ if (listcount (vertex->Adj_N) > 0)
+ isis_route_create ((struct prefix *) &vertex->N.prefix,
+ vertex->d_N, vertex->depth, vertex->Adj_N, area);
+ else if (isis->debugs & DEBUG_SPF_EVENTS)
+ zlog_info ("ISIS-Spf: no adjacencies do not install route");
+ }
+
return;
}
-
void
init_spt (struct isis_spftree *spftree)
{
- spftree->tents->del = spftree->paths->del = (void *)isis_vertex_del;
+ spftree->tents->del = spftree->paths->del = (void *) isis_vertex_del;
list_delete_all_node (spftree->tents);
list_delete_all_node (spftree->paths);
spftree->tents->del = spftree->paths->del = NULL;
-
+
return;
}
@@ -879,17 +949,17 @@ isis_run_spf (struct isis_area *area, int level, int family)
int retval = ISIS_OK;
struct listnode *node;
struct isis_vertex *vertex;
- struct isis_spftree *spftree = NULL;
+ struct isis_spftree *spftree = NULL;
u_char lsp_id[ISIS_SYS_ID_LEN + 2];
struct isis_lsp *lsp;
-
+
if (family == AF_INET)
spftree = area->spftree[level - 1];
#ifdef HAVE_IPV6
else if (family == AF_INET6)
spftree = area->spftree6[level - 1];
#endif
-
+
assert (spftree);
/*
@@ -900,60 +970,72 @@ isis_run_spf (struct isis_area *area, int level, int family)
isis_spf_add_self (spftree, area, level);
/* b) */
retval = isis_spf_preload_tent (spftree, area, level, family);
-
+
/*
* C.2.7 Step 2
*/
- if (listcount (spftree->tents) == 0) {
- zlog_warn ("ISIS-Spf: TENT is empty");
- spftree->lastrun = time (NULL);
- return retval;
- }
-
- while (listcount (spftree->tents) > 0) {
- node = listhead (spftree->tents);
- vertex = getdata (node);
- /* Remove from tent list */
- list_delete_node (spftree->tents, node);
- if (isis_find_vertex (spftree->paths, vertex->N.id, vertex->type))
- continue;
- add_to_paths (spftree, vertex, area);
- if (vertex->type == VTYPE_PSEUDO_IS ||
- vertex->type == VTYPE_NONPSEUDO_IS) {
- memcpy (lsp_id, vertex->N.id, ISIS_SYS_ID_LEN + 1);
- LSP_FRAGMENT(lsp_id) = 0;
- lsp = lsp_search (lsp_id, area->lspdb[level - 1]);
- if (lsp) {
- if (LSP_PSEUDO_ID (lsp_id)) {
- isis_spf_process_pseudo_lsp (spftree, lsp, vertex->d_N,
- vertex->depth, family);
-
- } else {
- isis_spf_process_lsp (spftree, lsp, vertex->d_N, vertex->depth,
- family);
+ if (listcount (spftree->tents) == 0)
+ {
+ zlog_warn ("ISIS-Spf: TENT is empty");
+ spftree->lastrun = time (NULL);
+ return retval;
+ }
+
+ while (listcount (spftree->tents) > 0)
+ {
+ node = listhead (spftree->tents);
+ vertex = getdata (node);
+ /* Remove from tent list */
+ list_delete_node (spftree->tents, node);
+ if (isis_find_vertex (spftree->paths, vertex->N.id, vertex->type))
+ continue;
+ add_to_paths (spftree, vertex, area);
+ if (vertex->type == VTYPE_PSEUDO_IS ||
+ vertex->type == VTYPE_NONPSEUDO_IS)
+ {
+ memcpy (lsp_id, vertex->N.id, ISIS_SYS_ID_LEN + 1);
+ LSP_FRAGMENT (lsp_id) = 0;
+ lsp = lsp_search (lsp_id, area->lspdb[level - 1]);
+ if (lsp)
+ {
+ if (LSP_PSEUDO_ID (lsp_id))
+ {
+ isis_spf_process_pseudo_lsp (spftree, lsp, vertex->d_N,
+ vertex->depth, family);
+
+ }
+ else
+ {
+ isis_spf_process_lsp (spftree, lsp, vertex->d_N,
+ vertex->depth, family);
+ }
+ }
+ else
+ {
+ zlog_warn ("ISIS-Spf: No LSP found for %s",
+ rawlspid_print (lsp_id));
+ }
}
- } else {
- zlog_warn ("ISIS-Spf: No LSP found for %s", rawlspid_print (lsp_id));
- }
}
- }
-
+
thread_add_event (master, isis_route_validate, area, 0);
spftree->lastrun = time (NULL);
spftree->pending = 0;
-
- if (level == 1) {
- /* FIXME: Should do it earlier. */
- spftree->t_spf_periodic = NULL;
- THREAD_TIMER_ON(master, spftree->t_spf_periodic, isis_run_spf_l1, area,
- isis_jitter(PERIODIC_SPF_INTERVAL, 10));
- }
- else {
- /* FIXME: Should do it earlier. */
- spftree->t_spf_periodic = NULL;
- THREAD_TIMER_ON(master, spftree->t_spf_periodic, isis_run_spf_l2, area,
- isis_jitter(PERIODIC_SPF_INTERVAL, 10));
- }
+
+ if (level == 1)
+ {
+ /* FIXME: Should do it earlier. */
+ spftree->t_spf_periodic = NULL;
+ THREAD_TIMER_ON (master, spftree->t_spf_periodic, isis_run_spf_l1, area,
+ isis_jitter (PERIODIC_SPF_INTERVAL, 10));
+ }
+ else
+ {
+ /* FIXME: Should do it earlier. */
+ spftree->t_spf_periodic = NULL;
+ THREAD_TIMER_ON (master, spftree->t_spf_periodic, isis_run_spf_l2, area,
+ isis_jitter (PERIODIC_SPF_INTERVAL, 10));
+ }
return retval;
}
@@ -964,21 +1046,24 @@ isis_run_spf_l1 (struct thread *thread)
struct isis_area *area;
int retval = ISIS_OK;
- area = THREAD_ARG(thread);
+ area = THREAD_ARG (thread);
assert (area);
- if (!(area->is_type & IS_LEVEL_1)) {
- if (isis->debugs & DEBUG_SPF_EVENTS) {
- zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag);
+ if (!(area->is_type & IS_LEVEL_1))
+ {
+ if (isis->debugs & DEBUG_SPF_EVENTS)
+ {
+ zlog_warn ("ISIS-SPF (%s) area does not share level",
+ area->area_tag);
+ }
+ return ISIS_WARNING;
+ }
+
+ if (isis->debugs & DEBUG_SPF_EVENTS)
+ {
+ zlog_info ("ISIS-Spf (%s) L1 SPF needed, periodic SPF", area->area_tag);
}
- return ISIS_WARNING;
- }
- if (isis->debugs & DEBUG_SPF_EVENTS) {
- zlog_info ("ISIS-Spf (%s) L1 SPF needed, periodic SPF",
- area->area_tag);
- }
-
if (area->ip_circuits)
retval = isis_run_spf (area, 1, AF_INET);
#ifdef HAVE_IPV6
@@ -994,20 +1079,23 @@ isis_run_spf_l2 (struct thread *thread)
struct isis_area *area;
int retval = ISIS_OK;
- area = THREAD_ARG(thread);
+ area = THREAD_ARG (thread);
assert (area);
-
- if (!(area->is_type & IS_LEVEL_2)) {
- if (isis->debugs & DEBUG_SPF_EVENTS) {
- zlog_warn ("ISIS-SPF (%s) area does not share level", area->area_tag);
+
+ if (!(area->is_type & IS_LEVEL_2))
+ {
+ if (isis->debugs & DEBUG_SPF_EVENTS)
+ {
+ zlog_warn ("ISIS-SPF (%s) area does not share level",
+ area->area_tag);
+ }
+ return ISIS_WARNING;
+ }
+
+ if (isis->debugs & DEBUG_SPF_EVENTS)
+ {
+ zlog_info ("ISIS-Spf (%s) L2 SPF needed, periodic SPF", area->area_tag);
}
- return ISIS_WARNING;
- }
-
- if (isis->debugs & DEBUG_SPF_EVENTS) {
- zlog_info ("ISIS-Spf (%s) L2 SPF needed, periodic SPF",
- area->area_tag);
- }
if (area->ip_circuits)
retval = isis_run_spf (area, 2, AF_INET);
@@ -1019,7 +1107,7 @@ isis_run_spf_l2 (struct thread *thread)
return retval;
}
-int
+int
isis_spf_schedule (struct isis_area *area, int level)
{
int retval = ISIS_OK;
@@ -1029,43 +1117,45 @@ isis_spf_schedule (struct isis_area *area, int level)
if (spftree->pending)
return retval;
- diff = now - spftree->lastrun;
+ diff = now - spftree->lastrun;
/* FIXME: let's wait a minute before doing the SPF */
- if (now - isis->uptime < 60 || isis->uptime == 0) {
- if (level == 1)
- thread_add_timer (master, isis_run_spf_l1, area,
- 60);
- else
- thread_add_timer (master, isis_run_spf_l2, area,
- 60);
-
- spftree->pending = 1;
- return retval;
- }
+ if (now - isis->uptime < 60 || isis->uptime == 0)
+ {
+ if (level == 1)
+ thread_add_timer (master, isis_run_spf_l1, area, 60);
+ else
+ thread_add_timer (master, isis_run_spf_l2, area, 60);
+
+ spftree->pending = 1;
+ return retval;
+ }
/* FIXME: This stuff is just mess. All spf thread add/cancel
logic should be reviewed. */
- THREAD_TIMER_OFF(spftree->t_spf_periodic);
-
- if (diff < MINIMUM_SPF_INTERVAL) {
- if (level == 1)
- thread_add_timer (master, isis_run_spf_l1, area,
- MINIMUM_SPF_INTERVAL - diff);
- else
- thread_add_timer (master, isis_run_spf_l2, area,
- MINIMUM_SPF_INTERVAL - diff);
-
- spftree->pending = 1;
- } else {
- spftree->pending = 0;
- retval = isis_run_spf (area, level, AF_INET);
- }
+ THREAD_TIMER_OFF (spftree->t_spf_periodic);
+
+ if (diff < MINIMUM_SPF_INTERVAL)
+ {
+ if (level == 1)
+ thread_add_timer (master, isis_run_spf_l1, area,
+ MINIMUM_SPF_INTERVAL - diff);
+ else
+ thread_add_timer (master, isis_run_spf_l2, area,
+ MINIMUM_SPF_INTERVAL - diff);
+
+ spftree->pending = 1;
+ }
+ else
+ {
+ spftree->pending = 0;
+ retval = isis_run_spf (area, level, AF_INET);
+ }
return retval;
}
#ifdef HAVE_IPV6
-int
+int
isis_spf_schedule6 (struct isis_area *area, int level)
{
int retval = ISIS_OK;
@@ -1075,37 +1165,39 @@ isis_spf_schedule6 (struct isis_area *area, int level)
if (spftree->pending)
return retval;
- diff = now - spftree->lastrun;
-
- THREAD_TIMER_OFF(spftree->t_spf_periodic);
-
+ diff = now - spftree->lastrun;
+
+ THREAD_TIMER_OFF (spftree->t_spf_periodic);
+
/* FIXME: let's wait a minute before doing the SPF */
- if (now - isis->uptime < 60 || isis->uptime == 0) {
- if (level == 1)
- thread_add_timer (master, isis_run_spf_l1, area,
- 60);
- else
- thread_add_timer (master, isis_run_spf_l2, area,
- 60);
-
- spftree->pending = 1;
- return retval;
- }
+ if (now - isis->uptime < 60 || isis->uptime == 0)
+ {
+ if (level == 1)
+ thread_add_timer (master, isis_run_spf_l1, area, 60);
+ else
+ thread_add_timer (master, isis_run_spf_l2, area, 60);
+ spftree->pending = 1;
+ return retval;
+ }
- if (diff < MINIMUM_SPF_INTERVAL) {
- if (level == 1)
- thread_add_timer (master, isis_run_spf_l1, area,
- MINIMUM_SPF_INTERVAL - diff);
- else
- thread_add_timer (master, isis_run_spf_l2, area,
- MINIMUM_SPF_INTERVAL - diff);
- spftree->pending = 1;
- } else {
- spftree->pending = 0;
- retval = isis_run_spf (area, level, AF_INET6);
- }
+ if (diff < MINIMUM_SPF_INTERVAL)
+ {
+ if (level == 1)
+ thread_add_timer (master, isis_run_spf_l1, area,
+ MINIMUM_SPF_INTERVAL - diff);
+ else
+ thread_add_timer (master, isis_run_spf_l2, area,
+ MINIMUM_SPF_INTERVAL - diff);
+
+ spftree->pending = 1;
+ }
+ else
+ {
+ spftree->pending = 0;
+ retval = isis_run_spf (area, level, AF_INET6);
+ }
return retval;
}
@@ -1121,43 +1213,47 @@ isis_print_paths (struct vty *vty, struct list *paths)
struct isis_adjacency *adj;
#ifdef EXTREME_DEBUG
u_char buff[255];
-#endif
+#endif
vty_out (vty, "System Id Metric Next-Hop"
- " Interface SNPA%s", VTY_NEWLINE);
- for (node = listhead (paths); node; nextnode (node)) {
- vertex = getdata (node);
- if (vertex->type != VTYPE_NONPSEUDO_IS)
- continue;
- if (memcmp (vertex->N.id, isis->sysid, ISIS_SYS_ID_LEN) == 0) {
- vty_out (vty, "%s --%s", host.name, VTY_NEWLINE);
- } else {
- dyn = dynhn_find_by_id ((u_char *)vertex->N.id);
- anode = listhead (vertex->Adj_N);
- adj = getdata (anode);
- if (adj) {
- 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),
- vertex->d_N, (nh_dyn != NULL) ? nh_dyn->name.name :
- (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),
- vertex->d_N, VTY_NEWLINE);
- }
-
- }
+ " Interface SNPA%s", VTY_NEWLINE);
+ for (node = listhead (paths); node; nextnode (node))
+ {
+ vertex = getdata (node);
+ if (vertex->type != VTYPE_NONPSEUDO_IS)
+ continue;
+ if (memcmp (vertex->N.id, isis->sysid, ISIS_SYS_ID_LEN) == 0)
+ {
+ vty_out (vty, "%s --%s", host.name, VTY_NEWLINE);
+ }
+ else
+ {
+ dyn = dynhn_find_by_id ((u_char *) vertex->N.id);
+ anode = listhead (vertex->Adj_N);
+ adj = getdata (anode);
+ if (adj)
+ {
+ 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),
+ vertex->d_N, (nh_dyn != NULL) ? nh_dyn->name.name :
+ (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),
+ vertex->d_N, VTY_NEWLINE);
+ }
+ }
#if 0
- vty_out (vty, "%s %s %u %s", vtype2string(vertex->type),
- vid2string(vertex, buff), vertex->d_N, VTY_NEWLINE);
+ vty_out (vty, "%s %s %u %s", vtype2string (vertex->type),
+ vid2string (vertex, buff), vertex->d_N, VTY_NEWLINE);
#endif
- }
-
-
+ }
}
DEFUN (show_isis_topology,
@@ -1170,37 +1266,41 @@ DEFUN (show_isis_topology,
struct listnode *node;
struct isis_area *area;
int level;
-
+
if (!isis->area_list || isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node)) {
- area = getdata (node);
-
- vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
- VTY_NEWLINE);
-
- for (level=0; level < ISIS_LEVELS; level++) {
- if (area->ip_circuits > 0 && area->spftree[level]
- && area->spftree[level]->paths->count > 0) {
- vty_out (vty, "IS-IS paths to level-%d routers that speak IP%s",
- level+1, VTY_NEWLINE);
- isis_print_paths (vty, area->spftree[level]->paths);
- }
+ for (node = listhead (isis->area_list); node; nextnode (node))
+ {
+ area = getdata (node);
+
+ vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
+ VTY_NEWLINE);
+
+ for (level = 0; level < ISIS_LEVELS; level++)
+ {
+ if (area->ip_circuits > 0 && area->spftree[level]
+ && area->spftree[level]->paths->count > 0)
+ {
+ vty_out (vty, "IS-IS paths to level-%d routers that speak IP%s",
+ level + 1, VTY_NEWLINE);
+ isis_print_paths (vty, area->spftree[level]->paths);
+ }
#ifdef HAVE_IPV6
- if (area->ipv6_circuits > 0 && area->spftree6[level]
- && area->spftree6[level]->paths->count > 0) {
- vty_out (vty, "IS-IS paths to level-%d routers that speak IPv6%s",
- level+1, VTY_NEWLINE);
- isis_print_paths (vty, area->spftree6[level]->paths);
- }
+ if (area->ipv6_circuits > 0 && area->spftree6[level]
+ && area->spftree6[level]->paths->count > 0)
+ {
+ vty_out (vty,
+ "IS-IS paths to level-%d routers that speak IPv6%s",
+ level + 1, VTY_NEWLINE);
+ isis_print_paths (vty, area->spftree6[level]->paths);
+ }
#endif /* HAVE_IPV6 */
+ }
}
- }
return CMD_SUCCESS;
-}
-
+}
DEFUN (show_isis_topology_l1,
show_isis_topology_l1_cmd,
@@ -1212,35 +1312,37 @@ DEFUN (show_isis_topology_l1,
{
struct listnode *node;
struct isis_area *area;
-
+
if (!isis->area_list || isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node)) {
- area = getdata (node);
-
- vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
- VTY_NEWLINE);
-
- if (area->ip_circuits > 0 && area->spftree[0]
- && area->spftree[0]->paths->count > 0) {
- vty_out (vty, "IS-IS paths to level-1 routers that speak IP%s",
- VTY_NEWLINE);
- isis_print_paths (vty, area->spftree[0]->paths);
- }
+ for (node = listhead (isis->area_list); node; nextnode (node))
+ {
+ area = getdata (node);
+
+ vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
+ VTY_NEWLINE);
+
+ if (area->ip_circuits > 0 && area->spftree[0]
+ && area->spftree[0]->paths->count > 0)
+ {
+ vty_out (vty, "IS-IS paths to level-1 routers that speak IP%s",
+ VTY_NEWLINE);
+ isis_print_paths (vty, area->spftree[0]->paths);
+ }
#ifdef HAVE_IPV6
- if (area->ipv6_circuits > 0 && area->spftree6[0]
- && area->spftree6[0]->paths->count > 0) {
- vty_out (vty, "IS-IS paths to level-1 routers that speak IPv6%s",
- VTY_NEWLINE);
- isis_print_paths (vty, area->spftree6[0]->paths);
- }
+ if (area->ipv6_circuits > 0 && area->spftree6[0]
+ && area->spftree6[0]->paths->count > 0)
+ {
+ vty_out (vty, "IS-IS paths to level-1 routers that speak IPv6%s",
+ VTY_NEWLINE);
+ isis_print_paths (vty, area->spftree6[0]->paths);
+ }
#endif /* HAVE_IPV6 */
}
-
return CMD_SUCCESS;
-}
+}
DEFUN (show_isis_topology_l2,
show_isis_topology_l2_cmd,
@@ -1252,36 +1354,37 @@ DEFUN (show_isis_topology_l2,
{
struct listnode *node;
struct isis_area *area;
-
+
if (!isis->area_list || isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node)) {
- area = getdata (node);
-
- vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
- VTY_NEWLINE);
-
- if (area->ip_circuits > 0 && area->spftree[1]
- && area->spftree[1]->paths->count > 0) {
- vty_out (vty, "IS-IS paths to level-2 routers that speak IP%s",
- VTY_NEWLINE);
- isis_print_paths (vty, area->spftree[1]->paths);
- }
+ for (node = listhead (isis->area_list); node; nextnode (node))
+ {
+ area = getdata (node);
+
+ vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
+ VTY_NEWLINE);
+
+ if (area->ip_circuits > 0 && area->spftree[1]
+ && area->spftree[1]->paths->count > 0)
+ {
+ vty_out (vty, "IS-IS paths to level-2 routers that speak IP%s",
+ VTY_NEWLINE);
+ isis_print_paths (vty, area->spftree[1]->paths);
+ }
#ifdef HAVE_IPV6
- if (area->ipv6_circuits > 0 && area->spftree6[1]
- && area->spftree6[1]->paths->count > 0) {
- vty_out (vty, "IS-IS paths to level-2 routers that speak IPv6%s",
- VTY_NEWLINE);
- isis_print_paths (vty, area->spftree6[1]->paths);
- }
+ if (area->ipv6_circuits > 0 && area->spftree6[1]
+ && area->spftree6[1]->paths->count > 0)
+ {
+ vty_out (vty, "IS-IS paths to level-2 routers that speak IPv6%s",
+ VTY_NEWLINE);
+ isis_print_paths (vty, area->spftree6[1]->paths);
+ }
#endif /* HAVE_IPV6 */
}
-
return CMD_SUCCESS;
-}
-
+}
void
isis_spf_cmds_init ()
diff --git a/isisd/isis_spf.h b/isisd/isis_spf.h
index 59e4b6b51..432f846e0 100644
--- a/isisd/isis_spf.h
+++ b/isisd/isis_spf.h
@@ -24,17 +24,18 @@
#ifndef _ZEBRA_ISIS_SPF_H
#define _ZEBRA_ISIS_SPF_H
-enum vertextype {
+enum vertextype
+{
VTYPE_PSEUDO_IS = 1,
VTYPE_NONPSEUDO_IS,
VTYPE_ES,
VTYPE_IPREACH_INTERNAL,
VTYPE_IPREACH_EXTERNAL
#ifdef HAVE_IPV6
- ,
+ ,
VTYPE_IP6REACH_INTERNAL,
VTYPE_IP6REACH_EXTERNAL
-#endif /* HAVE_IPV6 */
+#endif /* HAVE_IPV6 */
};
/*
@@ -44,28 +45,28 @@ struct isis_vertex
{
enum vertextype type;
- union {
- u_char id [ISIS_SYS_ID_LEN + 1];
+ union
+ {
+ u_char id[ISIS_SYS_ID_LEN + 1];
struct prefix prefix;
} N;
-
- struct isis_lsp *lsp;
- u_int32_t d_N; /* d(N) Distance from this IS */
- u_int16_t depth; /* The depth in the imaginary tree */
- struct list *Adj_N; /* {Adj(N)} */
-};
+ struct isis_lsp *lsp;
+ u_int32_t d_N; /* d(N) Distance from this IS */
+ u_int16_t depth; /* The depth in the imaginary tree */
+ struct list *Adj_N; /* {Adj(N)} */
+};
struct isis_spftree
{
- struct thread *t_spf_periodic; /* periodic spf threads */
- time_t lastrun; /* for scheduling */
- int pending; /* already scheduled */
- struct list *paths; /* the SPT */
- struct list *tents; /* TENT */
+ struct thread *t_spf_periodic; /* periodic spf threads */
+ time_t lastrun; /* for scheduling */
+ int pending; /* already scheduled */
+ struct list *paths; /* the SPT */
+ struct list *tents; /* TENT */
- u_int32_t timerun; /* statistics */
+ u_int32_t timerun; /* statistics */
};
void spftree_area_init (struct isis_area *area);
@@ -75,11 +76,3 @@ void isis_spf_cmds_init (void);
int isis_spf_schedule6 (struct isis_area *area, int level);
#endif
#endif /* _ZEBRA_ISIS_SPF_H */
-
-
-
-
-
-
-
-
diff --git a/isisd/isis_tlv.c b/isisd/isis_tlv.c
index d7bbb914c..a35b68785 100644
--- a/isisd/isis_tlv.c
+++ b/isisd/isis_tlv.c
@@ -48,58 +48,71 @@ extern struct isis *isis;
void
free_tlv (void *val)
{
- XFREE (MTYPE_ISIS_TLV, val);
-
- return;
+ XFREE (MTYPE_ISIS_TLV, val);
+
+ return;
}
/*
* Called after parsing of a PDU. There shouldn't be any tlv's left, so this
* is only a caution to avoid memory leaks
*/
-void
+void
free_tlvs (struct tlvs *tlvs)
{
- if (tlvs->area_addrs) {
- list_delete (tlvs->area_addrs);
- }
- if (tlvs->is_neighs) {
- list_delete (tlvs->is_neighs);
- }
- if (tlvs->te_is_neighs) {
- list_delete (tlvs->te_is_neighs);
- }
- if (tlvs->es_neighs) {
- list_delete (tlvs->es_neighs);
- }
- if (tlvs->lsp_entries) {
- list_delete (tlvs->lsp_entries);
- }
- if (tlvs->lan_neighs) {
- list_delete (tlvs->lan_neighs);
- }
- if (tlvs->prefix_neighs) {
- list_delete (tlvs->prefix_neighs);
- }
- if (tlvs->ipv4_addrs) {
- list_delete (tlvs->ipv4_addrs);
- }
- if (tlvs->ipv4_int_reachs) {
- list_delete (tlvs->ipv4_int_reachs);
- }
- if (tlvs->ipv4_ext_reachs) {
- list_delete (tlvs->ipv4_ext_reachs);
- }
- if (tlvs->te_ipv4_reachs) {
- list_delete (tlvs->te_ipv4_reachs);
- }
+ if (tlvs->area_addrs)
+ {
+ list_delete (tlvs->area_addrs);
+ }
+ if (tlvs->is_neighs)
+ {
+ list_delete (tlvs->is_neighs);
+ }
+ if (tlvs->te_is_neighs)
+ {
+ list_delete (tlvs->te_is_neighs);
+ }
+ if (tlvs->es_neighs)
+ {
+ list_delete (tlvs->es_neighs);
+ }
+ if (tlvs->lsp_entries)
+ {
+ list_delete (tlvs->lsp_entries);
+ }
+ if (tlvs->lan_neighs)
+ {
+ list_delete (tlvs->lan_neighs);
+ }
+ if (tlvs->prefix_neighs)
+ {
+ list_delete (tlvs->prefix_neighs);
+ }
+ if (tlvs->ipv4_addrs)
+ {
+ list_delete (tlvs->ipv4_addrs);
+ }
+ if (tlvs->ipv4_int_reachs)
+ {
+ list_delete (tlvs->ipv4_int_reachs);
+ }
+ if (tlvs->ipv4_ext_reachs)
+ {
+ list_delete (tlvs->ipv4_ext_reachs);
+ }
+ if (tlvs->te_ipv4_reachs)
+ {
+ list_delete (tlvs->te_ipv4_reachs);
+ }
#ifdef HAVE_IPV6
- if (tlvs->ipv6_addrs) {
- list_delete (tlvs->ipv6_addrs);
- }
- if (tlvs->ipv6_reachs) {
- list_delete (tlvs->ipv6_reachs);
- }
+ if (tlvs->ipv6_addrs)
+ {
+ list_delete (tlvs->ipv6_addrs);
+ }
+ if (tlvs->ipv6_reachs)
+ {
+ list_delete (tlvs->ipv6_reachs);
+ }
#endif /* HAVE_IPV6 */
return;
}
@@ -108,534 +121,584 @@ free_tlvs (struct tlvs *tlvs)
* Parses the tlvs found in the variant length part of the PDU.
* Caller tells with flags in "expected" which TLV's it is interested in.
*/
-int
-parse_tlvs (char *areatag, u_char *stream, int size, u_int32_t *expected,
- u_int32_t *found, struct tlvs *tlvs)
+int
+parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected,
+ u_int32_t * found, struct tlvs *tlvs)
{
- u_char type, length;
- struct lan_neigh *lan_nei;
- struct area_addr *area_addr;
- struct is_neigh *is_nei;
- struct te_is_neigh *te_is_nei;
- struct es_neigh *es_nei;
- struct lsp_entry *lsp_entry;
- struct in_addr *ipv4_addr;
- struct ipv4_reachability *ipv4_reach;
- struct te_ipv4_reachability *te_ipv4_reach;
+ u_char type, length;
+ struct lan_neigh *lan_nei;
+ struct area_addr *area_addr;
+ struct is_neigh *is_nei;
+ struct te_is_neigh *te_is_nei;
+ struct es_neigh *es_nei;
+ struct lsp_entry *lsp_entry;
+ struct in_addr *ipv4_addr;
+ struct ipv4_reachability *ipv4_reach;
+ struct te_ipv4_reachability *te_ipv4_reach;
#ifdef HAVE_IPV6
- struct in6_addr *ipv6_addr;
- struct ipv6_reachability *ipv6_reach;
- int prefix_octets;
+ struct in6_addr *ipv6_addr;
+ struct ipv6_reachability *ipv6_reach;
+ int prefix_octets;
#endif /* HAVE_IPV6 */
- u_char virtual;
- int value_len, retval = ISIS_OK;
- u_char *pnt = stream;
+ u_char virtual;
+ int value_len, retval = ISIS_OK;
+ u_char *pnt = stream;
*found = 0;
memset (tlvs, 0, sizeof (struct tlvs));
-
- while (pnt < stream + size - 2) {
- type = *pnt;
- length = *(pnt+1);
- pnt += 2;
- value_len = 0;
- if ( pnt + length > stream + size ) {
- zlog_warn ("ISIS-TLV (%s): TLV (type %d, length %d) exceeds packet "
- "boundaries", areatag, type, length);
- retval = ISIS_WARNING;
- break;
- }
- switch (type) {
- case AREA_ADDRESSES:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Address Length |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Area Address |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * : :
- */
- *found |= TLVFLAG_AREA_ADDRS;
+
+ while (pnt < stream + size - 2)
+ {
+ type = *pnt;
+ length = *(pnt + 1);
+ pnt += 2;
+ value_len = 0;
+ if (pnt + length > stream + size)
+ {
+ zlog_warn ("ISIS-TLV (%s): TLV (type %d, length %d) exceeds packet "
+ "boundaries", areatag, type, length);
+ retval = ISIS_WARNING;
+ break;
+ }
+ switch (type)
+ {
+ case AREA_ADDRESSES:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Address Length |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Area Address |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * : :
+ */
+ *found |= TLVFLAG_AREA_ADDRS;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("TLV Area Adresses len %d", length);
+ zlog_info ("TLV Area Adresses len %d", length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_AREA_ADDRS) {
- while (length > value_len) {
- area_addr = (struct area_addr*)pnt;
- value_len += area_addr->addr_len + 1;
- pnt += area_addr->addr_len + 1;
- if (!tlvs->area_addrs) tlvs->area_addrs = list_new ();
- listnode_add (tlvs->area_addrs, area_addr);
- }
- } else {
- pnt += length;
- }
- break;
-
- case IS_NEIGHBOURS:
- *found |= TLVFLAG_IS_NEIGHS;
+ if (*expected & TLVFLAG_AREA_ADDRS)
+ {
+ while (length > value_len)
+ {
+ area_addr = (struct area_addr *) pnt;
+ value_len += area_addr->addr_len + 1;
+ pnt += area_addr->addr_len + 1;
+ if (!tlvs->area_addrs)
+ tlvs->area_addrs = list_new ();
+ listnode_add (tlvs->area_addrs, area_addr);
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case IS_NEIGHBOURS:
+ *found |= TLVFLAG_IS_NEIGHS;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): IS Neighbours length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): IS Neighbours length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (TLVFLAG_IS_NEIGHS & *expected) {
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Virtual Flag |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- */
- virtual = *pnt; /* FIXME: what is the use for this? */
- pnt++;
- value_len ++;
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | 0 | I/E | Default Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Delay Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Expense Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Error Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Neighbour ID |
- * +---------------------------------------------------------------+
- * : :
- */
- while (length > value_len) {
- is_nei = (struct is_neigh*)pnt;
- value_len += 4 + ISIS_SYS_ID_LEN + 1;
- pnt += 4 + ISIS_SYS_ID_LEN + 1;
- if (!tlvs->is_neighs) tlvs->is_neighs = list_new ();
- listnode_add (tlvs->is_neighs, is_nei);
- }
- } else {
- pnt += length;
- }
- break;
-
- case TE_IS_NEIGHBOURS:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Neighbour ID | 7
- * +---------------------------------------------------------------+
- * | TE Metric | 3
- * +---------------------------------------------------------------+
- * | SubTLVs Length | 1
- * +---------------------------------------------------------------+
- * : :
- */
- *found |= TLVFLAG_TE_IS_NEIGHS;
+ if (TLVFLAG_IS_NEIGHS & *expected)
+ {
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Virtual Flag |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ */
+ virtual = *pnt; /* FIXME: what is the use for this? */
+ pnt++;
+ value_len++;
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | 0 | I/E | Default Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Delay Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Expense Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Error Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Neighbour ID |
+ * +---------------------------------------------------------------+
+ * : :
+ */
+ while (length > value_len)
+ {
+ is_nei = (struct is_neigh *) pnt;
+ value_len += 4 + ISIS_SYS_ID_LEN + 1;
+ pnt += 4 + ISIS_SYS_ID_LEN + 1;
+ if (!tlvs->is_neighs)
+ tlvs->is_neighs = list_new ();
+ listnode_add (tlvs->is_neighs, is_nei);
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case TE_IS_NEIGHBOURS:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Neighbour ID | 7
+ * +---------------------------------------------------------------+
+ * | TE Metric | 3
+ * +---------------------------------------------------------------+
+ * | SubTLVs Length | 1
+ * +---------------------------------------------------------------+
+ * : :
+ */
+ *found |= TLVFLAG_TE_IS_NEIGHS;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): Extended IS Neighbours length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): Extended IS Neighbours length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (TLVFLAG_TE_IS_NEIGHS & *expected) {
- while (length > value_len) {
- te_is_nei = (struct te_is_neigh*)pnt;
- value_len += 11;
- pnt += 11;
- /* FIXME - subtlvs are handled here, for now we skip */
- value_len += te_is_nei->sub_tlvs_length;
- pnt += te_is_nei->sub_tlvs_length;
-
-
- if (!tlvs->te_is_neighs) tlvs->te_is_neighs = list_new ();
- listnode_add (tlvs->te_is_neighs, te_is_nei);
- }
- } else {
- pnt += length;
- }
- break;
-
- case ES_NEIGHBOURS:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | 0 | I/E | Default Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Delay Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Expense Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Error Metric |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Neighbour ID |
- * +---------------------------------------------------------------+
- * | Neighbour ID |
- * +---------------------------------------------------------------+
- * : :
- */
+ if (TLVFLAG_TE_IS_NEIGHS & *expected)
+ {
+ while (length > value_len)
+ {
+ te_is_nei = (struct te_is_neigh *) pnt;
+ value_len += 11;
+ pnt += 11;
+ /* FIXME - subtlvs are handled here, for now we skip */
+ value_len += te_is_nei->sub_tlvs_length;
+ pnt += te_is_nei->sub_tlvs_length;
+
+ if (!tlvs->te_is_neighs)
+ tlvs->te_is_neighs = list_new ();
+ listnode_add (tlvs->te_is_neighs, te_is_nei);
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case ES_NEIGHBOURS:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | 0 | I/E | Default Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Delay Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Expense Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Error Metric |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Neighbour ID |
+ * +---------------------------------------------------------------+
+ * | Neighbour ID |
+ * +---------------------------------------------------------------+
+ * : :
+ */
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): ES Neighbours length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): ES Neighbours length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- *found |= TLVFLAG_ES_NEIGHS;
- if (*expected & TLVFLAG_ES_NEIGHS) {
- es_nei = (struct es_neigh*)pnt;
- value_len += 4;
- pnt += 4;
- while (length > value_len) {
- /* FIXME FIXME FIXME - add to the list */
- /* sys_id->id = pnt;*/
- value_len += ISIS_SYS_ID_LEN;
- pnt += ISIS_SYS_ID_LEN;
- /* if (!es_nei->neigh_ids) es_nei->neigh_ids = sysid;*/
- }
- if (!tlvs->es_neighs) tlvs->es_neighs = list_new ();
- listnode_add (tlvs->es_neighs, es_nei);
- } else {
- pnt += length;
- }
- break;
-
- case LAN_NEIGHBOURS:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | LAN Address |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * : :
- */
- *found |= TLVFLAG_LAN_NEIGHS;
- #ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): LAN Neigbours length %d",
- areatag,
- length);
- #endif /* EXTREME_TLV_DEBUG */
- if (TLVFLAG_LAN_NEIGHS & *expected) {
- while (length > value_len) {
- lan_nei = (struct lan_neigh*)pnt;
- if (!tlvs->lan_neighs) tlvs->lan_neighs = list_new ();
- listnode_add (tlvs->lan_neighs, lan_nei);
- value_len += ETH_ALEN;
- pnt += ETH_ALEN;
- }
- } else {
- pnt += length;
- }
- break;
-
- case PADDING:
+ *found |= TLVFLAG_ES_NEIGHS;
+ if (*expected & TLVFLAG_ES_NEIGHS)
+ {
+ es_nei = (struct es_neigh *) pnt;
+ value_len += 4;
+ pnt += 4;
+ while (length > value_len)
+ {
+ /* FIXME FIXME FIXME - add to the list */
+ /* sys_id->id = pnt; */
+ value_len += ISIS_SYS_ID_LEN;
+ pnt += ISIS_SYS_ID_LEN;
+ /* if (!es_nei->neigh_ids) es_nei->neigh_ids = sysid; */
+ }
+ if (!tlvs->es_neighs)
+ tlvs->es_neighs = list_new ();
+ listnode_add (tlvs->es_neighs, es_nei);
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case LAN_NEIGHBOURS:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | LAN Address |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * : :
+ */
+ *found |= TLVFLAG_LAN_NEIGHS;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("TLV padding %d", length);
+ zlog_info ("ISIS-TLV (%s): LAN Neigbours length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- pnt += length;
- break;
-
- case LSP_ENTRIES:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Remaining Lifetime | 2
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | LSP ID | id+2
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | LSP Sequence Number | 4
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Checksum | 2
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- */
+ if (TLVFLAG_LAN_NEIGHS & *expected)
+ {
+ while (length > value_len)
+ {
+ lan_nei = (struct lan_neigh *) pnt;
+ if (!tlvs->lan_neighs)
+ tlvs->lan_neighs = list_new ();
+ listnode_add (tlvs->lan_neighs, lan_nei);
+ value_len += ETH_ALEN;
+ pnt += ETH_ALEN;
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case PADDING:
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("LSP Entries length %d",
- areatag,
- length);
+ zlog_info ("TLV padding %d", length);
#endif /* EXTREME_TLV_DEBUG */
- *found |= TLVFLAG_LSP_ENTRIES;
- if (TLVFLAG_LSP_ENTRIES & *expected) {
- while (length > value_len) {
- lsp_entry = (struct lsp_entry*)pnt;
- value_len += 10 + ISIS_SYS_ID_LEN;
- pnt += 10 + ISIS_SYS_ID_LEN;
- if (!tlvs->lsp_entries) tlvs->lsp_entries = list_new ();
- listnode_add (tlvs->lsp_entries, lsp_entry);
- }
- } else {
- pnt += length;
- }
- break;
-
- case CHECKSUM:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | 16 bit fletcher CHECKSUM |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * : :
- */
- *found |= TLVFLAG_CHECKSUM;
+ pnt += length;
+ break;
+
+ case LSP_ENTRIES:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Remaining Lifetime | 2
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | LSP ID | id+2
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | LSP Sequence Number | 4
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Checksum | 2
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ */
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): Checksum length %d",
- areatag,
- length);
+ zlog_info ("LSP Entries length %d", areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_CHECKSUM) {
- tlvs->checksum = (struct checksum*)pnt;
- }
- pnt += length;
- break;
-
- case PROTOCOLS_SUPPORTED:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | NLPID |
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * : :
- */
- *found |= TLVFLAG_NLPID;
+ *found |= TLVFLAG_LSP_ENTRIES;
+ if (TLVFLAG_LSP_ENTRIES & *expected)
+ {
+ while (length > value_len)
+ {
+ lsp_entry = (struct lsp_entry *) pnt;
+ value_len += 10 + ISIS_SYS_ID_LEN;
+ pnt += 10 + ISIS_SYS_ID_LEN;
+ if (!tlvs->lsp_entries)
+ tlvs->lsp_entries = list_new ();
+ listnode_add (tlvs->lsp_entries, lsp_entry);
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case CHECKSUM:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | 16 bit fletcher CHECKSUM |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * : :
+ */
+ *found |= TLVFLAG_CHECKSUM;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): Protocols Supported length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): Checksum length %d", areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_NLPID) {
- tlvs->nlpids = (struct nlpids*)(pnt-1);
- }
- pnt += length;
- break;
-
- case IPV4_ADDR:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * + IP version 4 address + 4
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * : :
- */
- *found |= TLVFLAG_IPV4_ADDR;
+ if (*expected & TLVFLAG_CHECKSUM)
+ {
+ tlvs->checksum = (struct checksum *) pnt;
+ }
+ pnt += length;
+ break;
+
+ case PROTOCOLS_SUPPORTED:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | NLPID |
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * : :
+ */
+ *found |= TLVFLAG_NLPID;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): IPv4 Address length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): Protocols Supported length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_IPV4_ADDR) {
- while (length > value_len) {
- ipv4_addr = (struct in_addr*)pnt;
- zlog_info ("ISIS-TLV (%s) : IP ADDR %s, pnt %p", areatag,
- inet_ntoa (*ipv4_addr), pnt);
- if (!tlvs->ipv4_addrs) tlvs->ipv4_addrs = list_new();
- listnode_add (tlvs->ipv4_addrs, ipv4_addr);
- value_len += 4;
- pnt += 4;
- }
- } else {
- pnt += length;
- }
- break;
-
- case AUTH_INFO:
- *found |= TLVFLAG_AUTH_INFO;
+ if (*expected & TLVFLAG_NLPID)
+ {
+ tlvs->nlpids = (struct nlpids *) (pnt - 1);
+ }
+ pnt += length;
+ break;
+
+ case IPV4_ADDR:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * + IP version 4 address + 4
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * : :
+ */
+ *found |= TLVFLAG_IPV4_ADDR;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): IS-IS Authentication Information",
- areatag);
+ zlog_info ("ISIS-TLV (%s): IPv4 Address length %d",
+ areatag, length);
+#endif /* EXTREME_TLV_DEBUG */
+ if (*expected & TLVFLAG_IPV4_ADDR)
+ {
+ while (length > value_len)
+ {
+ ipv4_addr = (struct in_addr *) pnt;
+ zlog_info ("ISIS-TLV (%s) : IP ADDR %s, pnt %p", areatag,
+ inet_ntoa (*ipv4_addr), pnt);
+ if (!tlvs->ipv4_addrs)
+ tlvs->ipv4_addrs = list_new ();
+ listnode_add (tlvs->ipv4_addrs, ipv4_addr);
+ value_len += 4;
+ pnt += 4;
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case AUTH_INFO:
+ *found |= TLVFLAG_AUTH_INFO;
+#ifdef EXTREME_TLV_DEBUG
+ zlog_info ("ISIS-TLV (%s): IS-IS Authentication Information",
+ areatag);
#endif
- if (*expected & TLVFLAG_AUTH_INFO) {
- tlvs->auth_info.type = *pnt;
- pnt++;
- memcpy (tlvs->auth_info.passwd, pnt, length - 1);
- pnt += length - 1;
- }
- else {
- pnt += length;
- }
- break;
-
- case DYNAMIC_HOSTNAME:
- *found |= TLVFLAG_DYN_HOSTNAME;
+ if (*expected & TLVFLAG_AUTH_INFO)
+ {
+ tlvs->auth_info.type = *pnt;
+ pnt++;
+ memcpy (tlvs->auth_info.passwd, pnt, length - 1);
+ pnt += length - 1;
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case DYNAMIC_HOSTNAME:
+ *found |= TLVFLAG_DYN_HOSTNAME;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): Dynamic Hostname length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): Dynamic Hostname length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_DYN_HOSTNAME) {
- /* the length is also included in the pointed struct */
- tlvs->hostname = (struct hostname*)(pnt - 1);
- }
- pnt += length;
- break;
-
- case TE_ROUTER_ID:
- /* +---------------------------------------------------------------+
- * + Router ID + 4
- * +---------------------------------------------------------------+
- */
- *found |= TLVFLAG_TE_ROUTER_ID;
+ if (*expected & TLVFLAG_DYN_HOSTNAME)
+ {
+ /* the length is also included in the pointed struct */
+ tlvs->hostname = (struct hostname *) (pnt - 1);
+ }
+ pnt += length;
+ break;
+
+ case TE_ROUTER_ID:
+ /* +---------------------------------------------------------------+
+ * + Router ID + 4
+ * +---------------------------------------------------------------+
+ */
+ *found |= TLVFLAG_TE_ROUTER_ID;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): TE Router ID %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): TE Router ID %d", areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_TE_ROUTER_ID) {
- tlvs->router_id = (struct te_router_id*)(pnt);
- }
- pnt += length;
- break;
-
- case IPV4_INT_REACHABILITY:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | 0 | I/E | Default Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Delay Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Expense Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Error Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | ip address | 4
- * +---------------------------------------------------------------+
- * | address mask | 4
- * +---------------------------------------------------------------+
- * : :
- */
- *found |= TLVFLAG_IPV4_INT_REACHABILITY;
+ if (*expected & TLVFLAG_TE_ROUTER_ID)
+ {
+ tlvs->router_id = (struct te_router_id *) (pnt);
+ }
+ pnt += length;
+ break;
+
+ case IPV4_INT_REACHABILITY:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | 0 | I/E | Default Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Delay Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Expense Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Error Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | ip address | 4
+ * +---------------------------------------------------------------+
+ * | address mask | 4
+ * +---------------------------------------------------------------+
+ * : :
+ */
+ *found |= TLVFLAG_IPV4_INT_REACHABILITY;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): IPv4 internal Reachability length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): IPv4 internal Reachability length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_IPV4_INT_REACHABILITY) {
- while (length > value_len) {
- ipv4_reach = (struct ipv4_reachability*)pnt;
- if (!tlvs->ipv4_int_reachs) tlvs->ipv4_int_reachs = list_new();
- listnode_add (tlvs->ipv4_int_reachs, ipv4_reach);
- value_len += 12;
- pnt += 12;
- }
- }
- else {
- pnt += length;
- }
- break;
-
- case IPV4_EXT_REACHABILITY:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | 0 | I/E | Default Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Delay Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Expense Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | S | I/E | Error Metric | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | ip address | 4
- * +---------------------------------------------------------------+
- * | address mask | 4
- * +---------------------------------------------------------------+
- * : :
- */
- *found |= TLVFLAG_IPV4_EXT_REACHABILITY;
+ if (*expected & TLVFLAG_IPV4_INT_REACHABILITY)
+ {
+ while (length > value_len)
+ {
+ ipv4_reach = (struct ipv4_reachability *) pnt;
+ if (!tlvs->ipv4_int_reachs)
+ tlvs->ipv4_int_reachs = list_new ();
+ listnode_add (tlvs->ipv4_int_reachs, ipv4_reach);
+ value_len += 12;
+ pnt += 12;
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case IPV4_EXT_REACHABILITY:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | 0 | I/E | Default Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Delay Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Expense Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | S | I/E | Error Metric | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | ip address | 4
+ * +---------------------------------------------------------------+
+ * | address mask | 4
+ * +---------------------------------------------------------------+
+ * : :
+ */
+ *found |= TLVFLAG_IPV4_EXT_REACHABILITY;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): IPv4 external Reachability length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): IPv4 external Reachability length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_IPV4_EXT_REACHABILITY) {
- while (length > value_len) {
- ipv4_reach = (struct ipv4_reachability*)pnt;
- if (!tlvs->ipv4_ext_reachs)
- tlvs->ipv4_ext_reachs = list_new();
- listnode_add (tlvs->ipv4_ext_reachs, ipv4_reach);
- value_len += 12;
- pnt += 12;
- }
- }
- else {
- pnt += length;
- }
- break;
-
- case TE_IPV4_REACHABILITY:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | TE Metric | 4
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | U/D | sTLV? | Prefix Mask Len | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Prefix | 0-4
- * +---------------------------------------------------------------+
- * | sub tlvs |
- * +---------------------------------------------------------------+
- * : :
- */
- *found |= TLVFLAG_TE_IPV4_REACHABILITY;
+ if (*expected & TLVFLAG_IPV4_EXT_REACHABILITY)
+ {
+ while (length > value_len)
+ {
+ ipv4_reach = (struct ipv4_reachability *) pnt;
+ if (!tlvs->ipv4_ext_reachs)
+ tlvs->ipv4_ext_reachs = list_new ();
+ listnode_add (tlvs->ipv4_ext_reachs, ipv4_reach);
+ value_len += 12;
+ pnt += 12;
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case TE_IPV4_REACHABILITY:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | TE Metric | 4
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | U/D | sTLV? | Prefix Mask Len | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Prefix | 0-4
+ * +---------------------------------------------------------------+
+ * | sub tlvs |
+ * +---------------------------------------------------------------+
+ * : :
+ */
+ *found |= TLVFLAG_TE_IPV4_REACHABILITY;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): IPv4 extended Reachability length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): IPv4 extended Reachability length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_TE_IPV4_REACHABILITY) {
- while (length > value_len) {
- te_ipv4_reach = (struct te_ipv4_reachability*)pnt;
- if (!tlvs->te_ipv4_reachs) tlvs->te_ipv4_reachs = list_new();
- listnode_add (tlvs->te_ipv4_reachs, te_ipv4_reach);
- /* this trickery is permitable since no subtlvs are defined */
- value_len += 5 + ((te_ipv4_reach->control & 0x3F) ?
- ((((te_ipv4_reach->control & 0x3F)-1)>>3)+1) : 0);
- pnt += 5 + ((te_ipv4_reach->control & 0x3F) ?
- ((((te_ipv4_reach->control & 0x3F)-1)>>3)+1) : 0);
- }
- }
- else {
- pnt += length;
- }
- break;
+ if (*expected & TLVFLAG_TE_IPV4_REACHABILITY)
+ {
+ while (length > value_len)
+ {
+ te_ipv4_reach = (struct te_ipv4_reachability *) pnt;
+ if (!tlvs->te_ipv4_reachs)
+ tlvs->te_ipv4_reachs = list_new ();
+ listnode_add (tlvs->te_ipv4_reachs, te_ipv4_reach);
+ /* this trickery is permitable since no subtlvs are defined */
+ value_len += 5 + ((te_ipv4_reach->control & 0x3F) ?
+ ((((te_ipv4_reach->control & 0x3F) -
+ 1) >> 3) + 1) : 0);
+ pnt += 5 + ((te_ipv4_reach->control & 0x3F) ?
+ ((((te_ipv4_reach->control & 0x3F) - 1) >> 3) + 1) : 0);
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
#ifdef HAVE_IPV6
- case IPV6_ADDR:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * + IP version 6 address + 16
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * : :
- */
- *found |= TLVFLAG_IPV6_ADDR;
+ case IPV6_ADDR:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * + IP version 6 address + 16
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * : :
+ */
+ *found |= TLVFLAG_IPV6_ADDR;
#ifdef EXTREME_TLV_DEBUG
- zlog_info ("ISIS-TLV (%s): IPv6 Address length %d",
- areatag,
- length);
+ zlog_info ("ISIS-TLV (%s): IPv6 Address length %d",
+ areatag, length);
#endif /* EXTREME_TLV_DEBUG */
- if (*expected & TLVFLAG_IPV6_ADDR) {
- while (length > value_len) {
- ipv6_addr = (struct in6_addr*)pnt;
- if (!tlvs->ipv6_addrs) tlvs->ipv6_addrs = list_new();
- listnode_add (tlvs->ipv6_addrs, ipv6_addr);
- value_len += 16;
- pnt += 16;
- }
- } else {
- pnt += length;
- }
- break;
-
- case IPV6_REACHABILITY:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Default Metric | 4
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Control Informantion |
- * +---------------------------------------------------------------+
- * | IPv6 Prefix Length |--+
- * +---------------------------------------------------------------+ |
- * | IPv6 Prefix |<-+
- * +---------------------------------------------------------------+
- */
- *found |= TLVFLAG_IPV6_REACHABILITY;
- if (*expected & TLVFLAG_IPV6_REACHABILITY) {
- while (length > value_len) {
- ipv6_reach = (struct ipv6_reachability*)pnt;
- prefix_octets = ((ipv6_reach->prefix_len + 7) / 8);
- value_len += prefix_octets + 6;
- pnt += prefix_octets + 6;
- /* FIXME: sub-tlvs */
- if (!tlvs->ipv6_reachs) tlvs->ipv6_reachs = list_new();
- listnode_add (tlvs->ipv6_reachs, ipv6_reach);
- }
- } else {
- pnt += length;
- }
- break;
+ if (*expected & TLVFLAG_IPV6_ADDR)
+ {
+ while (length > value_len)
+ {
+ ipv6_addr = (struct in6_addr *) pnt;
+ if (!tlvs->ipv6_addrs)
+ tlvs->ipv6_addrs = list_new ();
+ listnode_add (tlvs->ipv6_addrs, ipv6_addr);
+ value_len += 16;
+ pnt += 16;
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
+
+ case IPV6_REACHABILITY:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Default Metric | 4
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Control Informantion |
+ * +---------------------------------------------------------------+
+ * | IPv6 Prefix Length |--+
+ * +---------------------------------------------------------------+ |
+ * | IPv6 Prefix |<-+
+ * +---------------------------------------------------------------+
+ */
+ *found |= TLVFLAG_IPV6_REACHABILITY;
+ if (*expected & TLVFLAG_IPV6_REACHABILITY)
+ {
+ while (length > value_len)
+ {
+ ipv6_reach = (struct ipv6_reachability *) pnt;
+ prefix_octets = ((ipv6_reach->prefix_len + 7) / 8);
+ value_len += prefix_octets + 6;
+ pnt += prefix_octets + 6;
+ /* FIXME: sub-tlvs */
+ if (!tlvs->ipv6_reachs)
+ tlvs->ipv6_reachs = list_new ();
+ listnode_add (tlvs->ipv6_reachs, ipv6_reach);
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+ break;
#endif /* HAVE_IPV6 */
- case WAY3_HELLO:
- /* +---------------------------------------------------------------+
- * | Adjacency state | 1
- * +---------------------------------------------------------------+
- * | Extended Local Circuit ID | 4
- * +---------------------------------------------------------------+
- * | Neighbor System ID (If known) | 0-8
- * (probably 6)
- * +---------------------------------------------------------------+
- * | Neighbor Local Circuit ID (If known) | 4
- * +---------------------------------------------------------------+
- */
- *found |= TLVFLAG_3WAY_HELLO;
- if (*expected & TLVFLAG_3WAY_HELLO) {
- while (length > value_len) {
- /* FIXME: make this work */
+ case WAY3_HELLO:
+ /* +---------------------------------------------------------------+
+ * | Adjacency state | 1
+ * +---------------------------------------------------------------+
+ * | Extended Local Circuit ID | 4
+ * +---------------------------------------------------------------+
+ * | Neighbor System ID (If known) | 0-8
+ * (probably 6)
+ * +---------------------------------------------------------------+
+ * | Neighbor Local Circuit ID (If known) | 4
+ * +---------------------------------------------------------------+
+ */
+ *found |= TLVFLAG_3WAY_HELLO;
+ if (*expected & TLVFLAG_3WAY_HELLO)
+ {
+ while (length > value_len)
+ {
+ /* FIXME: make this work */
/* Adjacency State (one octet):
0 = Up
1 = Initializing
@@ -644,56 +707,58 @@ parse_tlvs (char *areatag, u_char *stream, int size, u_int32_t *expected,
Neighbor System ID if known (zero to eight octets)
Neighbor Extended Local Circuit ID (four octets, if Neighbor
System ID is present) */
- pnt += length;
- }
- } else {
- pnt += length;
- }
-
- break;
- case GRACEFUL_RESTART:
- /* +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Reserved | SA | RA | RR | 1
- * +-------+-------+-------+-------+-------+-------+-------+-------+
- * | Remaining Time | 2
- * +---------------------------------------------------------------+
- * | Restarting Neighbor ID (If known) | 0-8
- * +---------------------------------------------------------------+
- */
- *found |= TLVFLAG_GRACEFUL_RESTART;
- if (*expected & TLVFLAG_GRACEFUL_RESTART) {
- /* FIXME: make this work */
- }
- pnt += length;
- break;
-
- default:
- zlog_warn ("ISIS-TLV (%s): unsupported TLV type %d, length %d",
- areatag,
- type,
- length);
-
- retval = ISIS_WARNING;
- pnt += length;
- break;
+ pnt += length;
+ }
+ }
+ else
+ {
+ pnt += length;
+ }
+
+ break;
+ case GRACEFUL_RESTART:
+ /* +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Reserved | SA | RA | RR | 1
+ * +-------+-------+-------+-------+-------+-------+-------+-------+
+ * | Remaining Time | 2
+ * +---------------------------------------------------------------+
+ * | Restarting Neighbor ID (If known) | 0-8
+ * +---------------------------------------------------------------+
+ */
+ *found |= TLVFLAG_GRACEFUL_RESTART;
+ if (*expected & TLVFLAG_GRACEFUL_RESTART)
+ {
+ /* FIXME: make this work */
+ }
+ pnt += length;
+ break;
+
+ default:
+ zlog_warn ("ISIS-TLV (%s): unsupported TLV type %d, length %d",
+ areatag, type, length);
+
+ retval = ISIS_WARNING;
+ pnt += length;
+ break;
+ }
}
- }
-
+
return retval;
}
int
-add_tlv (u_char tag, u_char len, u_char *value, struct stream *stream)
+add_tlv (u_char tag, u_char len, u_char * value, struct stream *stream)
{
- if (STREAM_SIZE (stream) - stream_get_putp (stream) < len + 2) {
- zlog_warn ("No room for TLV of type %d", tag);
- return ISIS_WARNING;
- }
+ if (STREAM_SIZE (stream) - stream_get_putp (stream) < len + 2)
+ {
+ zlog_warn ("No room for TLV of type %d", tag);
+ return ISIS_WARNING;
+ }
- stream_putc (stream, tag); /* TAG */
- stream_putc (stream, len); /* LENGTH */
- stream_put (stream, value, (int)len); /* VALUE */
+ stream_putc (stream, tag); /* TAG */
+ stream_putc (stream, len); /* LENGTH */
+ stream_put (stream, value, (int) len); /* VALUE */
#ifdef EXTREME_DEBUG
zlog_info ("Added TLV %d len %d", tag, len);
@@ -701,93 +766,96 @@ add_tlv (u_char tag, u_char len, u_char *value, struct stream *stream)
return ISIS_OK;
}
-
int
-tlv_add_area_addrs (struct list *area_addrs, struct stream *stream)
+tlv_add_area_addrs (struct list *area_addrs, struct stream *stream)
{
struct listnode *node;
struct area_addr *area_addr;
- u_char value [255];
+ u_char value[255];
u_char *pos = value;
-
- for (node = listhead (area_addrs); node; nextnode (node)) {
- area_addr = getdata (node);
- if (pos - value + area_addr->addr_len > 255)
- goto err;
- *pos = area_addr->addr_len;
- pos ++;
- memcpy (pos, area_addr->area_addr, (int)area_addr->addr_len);
- pos += area_addr->addr_len;
- }
-
+
+ for (node = listhead (area_addrs); node; nextnode (node))
+ {
+ area_addr = getdata (node);
+ if (pos - value + area_addr->addr_len > 255)
+ goto err;
+ *pos = area_addr->addr_len;
+ pos++;
+ memcpy (pos, area_addr->area_addr, (int) area_addr->addr_len);
+ pos += area_addr->addr_len;
+ }
+
return add_tlv (AREA_ADDRESSES, pos - value, value, stream);
- err:
+err:
zlog_warn ("tlv_add_area_addrs(): TLV longer than 255");
return ISIS_WARNING;
}
-int tlv_add_is_neighs (struct list *is_neighs, struct stream *stream)
+int
+tlv_add_is_neighs (struct list *is_neighs, struct stream *stream)
{
struct listnode *node;
struct is_neigh *is_neigh;
- u_char value [255];
+ u_char value[255];
u_char *pos = value;
int retval;
- *pos = 0; /*is_neigh->virtual; */
- pos ++;
+ *pos = 0; /*is_neigh->virtual; */
+ pos++;
- for (node = listhead (is_neighs); node; nextnode (node)) {
- is_neigh = getdata (node);
- if (pos - value + IS_NEIGHBOURS_LEN > 255) {
- retval = add_tlv (IS_NEIGHBOURS, pos - value, value, stream);
- if (retval != ISIS_OK)
- return retval;
- pos = value;
+ for (node = listhead (is_neighs); node; nextnode (node))
+ {
+ is_neigh = getdata (node);
+ if (pos - value + IS_NEIGHBOURS_LEN > 255)
+ {
+ retval = add_tlv (IS_NEIGHBOURS, pos - value, value, stream);
+ if (retval != ISIS_OK)
+ return retval;
+ pos = value;
+ }
+ *pos = is_neigh->metrics.metric_default;
+ pos++;
+ *pos = is_neigh->metrics.metric_delay;
+ pos++;
+ *pos = is_neigh->metrics.metric_expense;
+ pos++;
+ *pos = is_neigh->metrics.metric_error;
+ pos++;
+ memcpy (pos, is_neigh->neigh_id, ISIS_SYS_ID_LEN + 1);
+ pos += ISIS_SYS_ID_LEN + 1;
}
- *pos = is_neigh->metrics.metric_default;
- pos ++;
- *pos = is_neigh->metrics.metric_delay;
- pos ++;
- *pos = is_neigh->metrics.metric_expense;
- pos ++;
- *pos = is_neigh->metrics.metric_error;
- pos ++;
- memcpy (pos, is_neigh->neigh_id, ISIS_SYS_ID_LEN + 1);
- pos += ISIS_SYS_ID_LEN + 1;
- }
return add_tlv (IS_NEIGHBOURS, pos - value, value, stream);
}
-
int
tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream)
{
struct listnode *node;
u_char *snpa;
- u_char value [255];
+ u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (lan_neighs); node; nextnode (node)) {
- snpa = getdata (node);
- if (pos - value + ETH_ALEN > 255) {
- retval = add_tlv (LAN_NEIGHBOURS, pos - value, value, stream);
- if (retval != ISIS_OK)
- return retval;
- pos = value;
+ for (node = listhead (lan_neighs); node; nextnode (node))
+ {
+ snpa = getdata (node);
+ if (pos - value + ETH_ALEN > 255)
+ {
+ retval = add_tlv (LAN_NEIGHBOURS, pos - value, value, stream);
+ if (retval != ISIS_OK)
+ return retval;
+ pos = value;
+ }
+ memcpy (pos, snpa, ETH_ALEN);
+ pos += ETH_ALEN;
}
- memcpy (pos, snpa, ETH_ALEN);
- pos += ETH_ALEN;
- }
return add_tlv (LAN_NEIGHBOURS, pos - value, value, stream);
}
-
/*
u_char value[255];
u_char *pos = value;
@@ -805,13 +873,13 @@ tlv_add_lan_neighs (struct list *lan_neighs, struct stream *stream)
int
tlv_add_nlpid (struct nlpids *nlpids, struct stream *stream)
{
-
- return add_tlv (PROTOCOLS_SUPPORTED, nlpids->count,
- nlpids->nlpids, stream);
+
+ return add_tlv (PROTOCOLS_SUPPORTED, nlpids->count, nlpids->nlpids, stream);
}
-int tlv_add_authinfo (char auth_type, char auth_len, char *auth_value,
- struct stream *stream)
+int
+tlv_add_authinfo (char auth_type, char auth_len, char *auth_value,
+ struct stream *stream)
{
u_char value[255];
u_char *pos = value;
@@ -825,9 +893,8 @@ int
tlv_add_checksum (struct checksum *checksum, struct stream *stream)
{
u_char value[255];
- u_char *pos = value;
- return add_tlv (CHECKSUM, pos - value,
- value, stream);
+ u_char *pos = value;
+ return add_tlv (CHECKSUM, pos - value, value, stream);
}
int
@@ -839,93 +906,101 @@ tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream)
u_char *pos = value;
int retval;
- for (node = listhead (ip_addrs); node; nextnode (node)) {
- ipv4 = getdata (node);
- if (pos - value + IPV4_MAX_BYTELEN > 255) {
- retval = add_tlv (IPV4_ADDR, pos - value, value, stream);
- if (retval != ISIS_OK)
- return retval;
- pos = value;
+ for (node = listhead (ip_addrs); node; nextnode (node))
+ {
+ ipv4 = getdata (node);
+ if (pos - value + IPV4_MAX_BYTELEN > 255)
+ {
+ retval = add_tlv (IPV4_ADDR, pos - value, value, stream);
+ if (retval != ISIS_OK)
+ return retval;
+ pos = value;
+ }
+ *(u_int32_t *) pos = ipv4->prefix.s_addr;
+ pos += IPV4_MAX_BYTELEN;
}
- *(u_int32_t*)pos = ipv4->prefix.s_addr;
- pos += IPV4_MAX_BYTELEN;
- }
-
+
return add_tlv (IPV4_ADDR, pos - value, value, stream);
}
int
tlv_add_dynamic_hostname (struct hostname *hostname, struct stream *stream)
{
- return add_tlv (DYNAMIC_HOSTNAME, hostname->namelen, hostname->name, stream);
+ return add_tlv (DYNAMIC_HOSTNAME, hostname->namelen, hostname->name,
+ stream);
}
-int
+int
tlv_add_lsp_entries (struct list *lsps, struct stream *stream)
{
struct listnode *node;
struct isis_lsp *lsp;
- u_char value [255];
+ u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (lsps); node; nextnode (node)) {
- lsp = getdata (node);
- if (pos - value + LSP_ENTRIES_LEN > 255) {
- retval = add_tlv (LSP_ENTRIES, pos - value, value, stream);
- if (retval != ISIS_OK)
- return retval;
- pos = value;
+ for (node = listhead (lsps); node; nextnode (node))
+ {
+ lsp = getdata (node);
+ if (pos - value + LSP_ENTRIES_LEN > 255)
+ {
+ retval = add_tlv (LSP_ENTRIES, pos - value, value, stream);
+ if (retval != ISIS_OK)
+ return retval;
+ pos = value;
+ }
+ *((u_int16_t *) pos) = lsp->lsp_header->rem_lifetime;
+ pos += 2;
+ memcpy (pos, lsp->lsp_header->lsp_id, ISIS_SYS_ID_LEN + 2);
+ pos += ISIS_SYS_ID_LEN + 2;
+ *((u_int32_t *) pos) = lsp->lsp_header->seq_num;
+ pos += 4;
+ *((u_int16_t *) pos) = lsp->lsp_header->checksum;
+ pos += 2;
}
- *((u_int16_t*)pos) = lsp->lsp_header->rem_lifetime;
- pos += 2;
- memcpy (pos, lsp->lsp_header->lsp_id, ISIS_SYS_ID_LEN + 2);
- pos += ISIS_SYS_ID_LEN + 2;
- *((u_int32_t*)pos) = lsp->lsp_header->seq_num;
- pos += 4;
- *((u_int16_t*)pos) = lsp->lsp_header->checksum;
- pos += 2;
- }
-
+
return add_tlv (LSP_ENTRIES, pos - value, value, stream);
}
-int
+int
tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct stream *stream)
{
struct listnode *node;
struct ipv4_reachability *reach;
- u_char value [255];
+ u_char value[255];
u_char *pos = value;
int retval;
- for (node = listhead (ipv4_reachs); node; nextnode (node)) {
- reach = getdata (node);
- if (pos - value + IPV4_REACH_LEN > 255) {
- retval = add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream);
- if (retval != ISIS_OK)
- return retval;
- pos = value;
+ for (node = listhead (ipv4_reachs); node; nextnode (node))
+ {
+ reach = getdata (node);
+ if (pos - value + IPV4_REACH_LEN > 255)
+ {
+ retval =
+ add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream);
+ if (retval != ISIS_OK)
+ return retval;
+ pos = value;
+ }
+ *pos = reach->metrics.metric_default;
+ pos++;
+ *pos = reach->metrics.metric_delay;
+ pos++;
+ *pos = reach->metrics.metric_expense;
+ pos++;
+ *pos = reach->metrics.metric_error;
+ pos++;
+ *(u_int32_t *) pos = reach->prefix.s_addr;
+ pos += IPV4_MAX_BYTELEN;
+ *(u_int32_t *) pos = reach->mask.s_addr;
+ pos += IPV4_MAX_BYTELEN;
}
- *pos = reach->metrics.metric_default;
- pos ++;
- *pos = reach->metrics.metric_delay;
- pos ++;
- *pos = reach->metrics.metric_expense;
- pos ++;
- *pos = reach->metrics.metric_error;
- pos ++;
- *(u_int32_t*)pos = reach->prefix.s_addr;
- pos += IPV4_MAX_BYTELEN;
- *(u_int32_t*)pos = reach->mask.s_addr;
- pos += IPV4_MAX_BYTELEN;
- }
-
-
+
+
return add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream);
}
-#ifdef HAVE_IPV6
+#ifdef HAVE_IPV6
int
tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream)
{
@@ -934,19 +1009,21 @@ tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream)
u_char value[255];
u_char *pos = value;
int retval;
-
- for (node = listhead (ipv6_addrs); node; nextnode (node)) {
- ipv6 = getdata (node);
- if (pos - value + IPV6_MAX_BYTELEN > 255) {
- retval = add_tlv (IPV6_ADDR, pos - value, value, stream);
- if (retval != ISIS_OK)
- return retval;
- pos = value;
+
+ for (node = listhead (ipv6_addrs); node; nextnode (node))
+ {
+ ipv6 = getdata (node);
+ if (pos - value + IPV6_MAX_BYTELEN > 255)
+ {
+ retval = add_tlv (IPV6_ADDR, pos - value, value, stream);
+ if (retval != ISIS_OK)
+ return retval;
+ pos = value;
+ }
+ memcpy (pos, ipv6->prefix.s6_addr, IPV6_MAX_BYTELEN);
+ pos += IPV6_MAX_BYTELEN;
}
- memcpy (pos, ipv6->prefix.s6_addr, IPV6_MAX_BYTELEN);
- pos += IPV6_MAX_BYTELEN;
- }
-
+
return add_tlv (IPV6_ADDR, pos - value, value, stream);
}
@@ -958,26 +1035,28 @@ tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream)
u_char value[255];
u_char *pos = value;
int retval, prefix_octets;
-
- for (node = listhead (ipv6_reachs); node; nextnode (node)) {
- ip6reach = getdata (node);
- if (pos - value + IPV6_MAX_BYTELEN + 6 > 255) {
- retval = add_tlv (IPV6_REACHABILITY, pos - value, value, stream);
- if (retval != ISIS_OK)
- return retval;
- pos = value;
+
+ for (node = listhead (ipv6_reachs); node; nextnode (node))
+ {
+ ip6reach = getdata (node);
+ if (pos - value + IPV6_MAX_BYTELEN + 6 > 255)
+ {
+ retval = add_tlv (IPV6_REACHABILITY, pos - value, value, stream);
+ if (retval != ISIS_OK)
+ return retval;
+ pos = value;
+ }
+ *(uint32_t *) pos = ip6reach->metric;
+ pos += 4;
+ *pos = ip6reach->control_info;
+ pos++;
+ prefix_octets = ((ip6reach->prefix_len + 7) / 8);
+ *pos = ip6reach->prefix_len;
+ pos++;
+ memcpy (pos, ip6reach->prefix, prefix_octets);
+ pos += prefix_octets;
}
- *(uint32_t*)pos = ip6reach->metric;
- pos += 4;
- *pos = ip6reach->control_info;
- pos++;
- prefix_octets = ((ip6reach->prefix_len + 7) / 8);
- *pos = ip6reach->prefix_len;
- pos++;
- memcpy (pos, ip6reach->prefix, prefix_octets);
- pos += prefix_octets;
- }
-
+
return add_tlv (IPV6_REACHABILITY, pos - value, value, stream);
}
#endif /* HAVE_IPV6 */
@@ -986,36 +1065,38 @@ int
tlv_add_padding (struct stream *stream)
{
unsigned long putp, endp;
- int fullpads, i, left;
-
+ int fullpads, i, left;
+
/*
* How many times can we add full padding ?
*/
- fullpads = (STREAM_SIZE(stream) - stream_get_endp (stream)) / 257;
- for (i = 0; i < fullpads; i ++) {
- if (!stream_putc (stream, (u_char)PADDING)) /* TAG */
- goto err;
- if (!stream_putc (stream, (u_char)255)) /* LENGHT */
- goto err;
- endp = stream_get_endp (stream);
- putp = stream_get_putp (stream);
- if (putp != endp)
- zlog_warn ("tvl_add_padding endp %ld while putp %ld", endp, putp);
- stream_set_putp (stream, putp + 255); /* VALUE */
- stream->endp = stream->putp;
- }
-
- left = STREAM_SIZE(stream) - stream_get_putp (stream);
-
+ fullpads = (STREAM_SIZE (stream) - stream_get_endp (stream)) / 257;
+ for (i = 0; i < fullpads; i++)
+ {
+ if (!stream_putc (stream, (u_char) PADDING)) /* TAG */
+ goto err;
+ if (!stream_putc (stream, (u_char) 255)) /* LENGHT */
+ goto err;
+ endp = stream_get_endp (stream);
+ putp = stream_get_putp (stream);
+ if (putp != endp)
+ zlog_warn ("tvl_add_padding endp %ld while putp %ld", endp, putp);
+ stream_set_putp (stream, putp + 255); /* VALUE */
+ stream->endp = stream->putp;
+ }
+
+ left = STREAM_SIZE (stream) - stream_get_putp (stream);
+
if (left < 2)
return ISIS_OK;
-
- if (left == 2) {
- stream_putc (stream, PADDING);
- stream_putc (stream, 0);
- return ISIS_OK;
- }
-
+
+ if (left == 2)
+ {
+ stream_putc (stream, PADDING);
+ stream_putc (stream, 0);
+ return ISIS_OK;
+ }
+
stream_putc (stream, PADDING);
stream_putc (stream, left - 2);
stream_set_putp (stream, stream_get_putp (stream) + left - 2);
@@ -1023,7 +1104,7 @@ tlv_add_padding (struct stream *stream)
return ISIS_OK;
- err:
+err:
zlog_warn ("tlv_add_padding(): no room for tlv");
return ISIS_WARNING;
}
diff --git a/isisd/isis_tlv.h b/isisd/isis_tlv.h
index e030385e1..e4fd9e07e 100644
--- a/isisd/isis_tlv.h
+++ b/isisd/isis_tlv.h
@@ -95,86 +95,98 @@
#define IS_NEIGHBOURS_LEN (ISIS_SYS_ID_LEN + 5)
#define LAN_NEIGHBOURS_LEN 6
-#define LSP_ENTRIES_LEN (10 + ISIS_SYS_ID_LEN) /* FIXME: should be entry */
+#define LSP_ENTRIES_LEN (10 + ISIS_SYS_ID_LEN) /* FIXME: should be entry */
#define IPV4_REACH_LEN 12
#define IPV6_REACH_LEN 22
/* struct for neighbor */
-struct is_neigh{
- struct metric metrics;
- u_char neigh_id[ISIS_SYS_ID_LEN + 1];
+struct is_neigh
+{
+ struct metric metrics;
+ u_char neigh_id[ISIS_SYS_ID_LEN + 1];
};
/* struct for te is neighbor */
-struct te_is_neigh{
- u_char neigh_id[ISIS_SYS_ID_LEN + 1];
- u_char te_metric[3];
- u_char sub_tlvs_length;
+struct te_is_neigh
+{
+ u_char neigh_id[ISIS_SYS_ID_LEN + 1];
+ u_char te_metric[3];
+ u_char sub_tlvs_length;
};
/* struct for es neighbors */
-struct es_neigh{
- struct metric metrics;
+struct es_neigh
+{
+ struct metric metrics;
/* approximate position of first, we use the
* length ((uchar*)metric-1) to know all */
- u_char first_es_neigh[ISIS_SYS_ID_LEN];
-
+ u_char first_es_neigh[ISIS_SYS_ID_LEN];
+
};
-struct partition_desig_level2_is{
- struct list *isis_system_ids;
+struct partition_desig_level2_is
+{
+ struct list *isis_system_ids;
};
/* struct for lan neighbors */
-struct lan_neigh{
- u_char LAN_addr[6];
+struct lan_neigh
+{
+ u_char LAN_addr[6];
};
/* struct for LSP entry */
-struct lsp_entry {
- u_int16_t rem_lifetime;
- u_char lsp_id[ISIS_SYS_ID_LEN + 2];
- u_int32_t seq_num;
- u_int16_t checksum;
-} __attribute__((packed));
+struct lsp_entry
+{
+ u_int16_t rem_lifetime;
+ u_char lsp_id[ISIS_SYS_ID_LEN + 2];
+ u_int32_t seq_num;
+ u_int16_t checksum;
+} __attribute__ ((packed));
/* struct for checksum */
-struct checksum {
+struct checksum
+{
u_int16_t checksum;
};
/* ipv4 reachability */
-struct ipv4_reachability {
+struct ipv4_reachability
+{
struct metric metrics;
struct in_addr prefix;
- struct in_addr mask;
+ struct in_addr mask;
};
/* te router id */
-struct te_router_id {
- struct in_addr id;
+struct te_router_id
+{
+ struct in_addr id;
};
/* te ipv4 reachability */
-struct te_ipv4_reachability {
- u_int32_t te_metric;
- u_char control;
- u_char prefix_start; /* since this is variable length by nature it only */
-}; /* points to an approximate location */
+struct te_ipv4_reachability
+{
+ u_int32_t te_metric;
+ u_char control;
+ u_char prefix_start; /* since this is variable length by nature it only */
+}; /* points to an approximate location */
-struct idrp_info {
+struct idrp_info
+{
u_char len;
u_char *value;
};
#ifdef HAVE_IPV6
-struct ipv6_reachability {
- u_int32_t metric;
- u_char control_info;
- u_char prefix_len;
- u_char prefix[16];
+struct ipv6_reachability
+{
+ u_int32_t metric;
+ u_char control_info;
+ u_char prefix_len;
+ u_char prefix[16];
};
#endif /* HAVE_IPV6 */
@@ -190,27 +202,28 @@ struct ipv6_reachability {
/*
* Pointer to each tlv type, filled by parse_tlvs()
*/
-struct tlvs {
- struct list *area_addrs;
- struct list *is_neighs;
- struct list *te_is_neighs;
- struct list *es_neighs;
- struct list *lsp_entries;
- struct list *prefix_neighs;
- struct list *lan_neighs;
- struct checksum *checksum;
- struct nlpids *nlpids;
- struct list *ipv4_addrs;
- struct list *ipv4_int_reachs;
- struct list *ipv4_ext_reachs;
- struct list *te_ipv4_reachs;
- struct hostname *hostname;
- struct te_router_id *router_id;
+struct tlvs
+{
+ struct list *area_addrs;
+ struct list *is_neighs;
+ struct list *te_is_neighs;
+ struct list *es_neighs;
+ struct list *lsp_entries;
+ struct list *prefix_neighs;
+ struct list *lan_neighs;
+ struct checksum *checksum;
+ struct nlpids *nlpids;
+ struct list *ipv4_addrs;
+ struct list *ipv4_int_reachs;
+ struct list *ipv4_ext_reachs;
+ struct list *te_ipv4_reachs;
+ struct hostname *hostname;
+ struct te_router_id *router_id;
#ifdef HAVE_IPV6
- struct list *ipv6_addrs;
- struct list *ipv6_reachs;
+ struct list *ipv6_addrs;
+ struct list *ipv6_reachs;
#endif
- struct isis_passwd auth_info;
+ struct isis_passwd auth_info;
};
/*
@@ -240,32 +253,29 @@ struct tlvs {
#define TLVFLAG_CHECKSUM (1<<20)
#define TLVFLAG_GRACEFUL_RESTART (1<<21)
-void init_tlvs (struct tlvs *tlvs, uint32_t expected);
-void free_tlvs (struct tlvs *tlvs);
-int parse_tlvs (char *areatag, u_char *stream, int size, u_int32_t *expected,
- u_int32_t *found, struct tlvs *tlvs);
-void free_tlv (void *val);
+void init_tlvs (struct tlvs *tlvs, uint32_t expected);
+void free_tlvs (struct tlvs *tlvs);
+int parse_tlvs (char *areatag, u_char * stream, int size,
+ u_int32_t * expected, u_int32_t * found, struct tlvs *tlvs);
+void free_tlv (void *val);
-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_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,
+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_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);
+int tlv_add_authinfo (char auth_type, char authlen, char *auth_value,
+ struct stream *stream);
+int tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream);
+int tlv_add_dynamic_hostname (struct hostname *hostname,
struct stream *stream);
-int tlv_add_authinfo (char auth_type, char authlen, char *auth_value,
- struct stream *stream);
-int tlv_add_ip_addrs (struct list *ip_addrs, struct stream *stream);
-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_lsp_entries (struct list *lsps, struct stream *stream);
+int tlv_add_ipv4_reachs (struct list *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);
+int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream);
+int tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream);
#endif /* HAVE_IPV6 */
-int tlv_add_padding (struct stream *stream);
+int tlv_add_padding (struct stream *stream);
#endif /* _ZEBRA_ISIS_TLV_H */
-
-
-
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index 136d2b525..ad5a0507f 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -44,20 +44,20 @@ struct zclient *zclient = NULL;
extern struct thread_master *master;
-int
+int
isis_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length)
{
struct interface *ifp;
ifp = zebra_interface_add_read (zclient->ibuf);
-
+
zlog_info ("Zebra I/F add: %s index %d flags %ld metric %d mtu %d",
ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
-
+
if (if_is_up (ifp))
isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
-
+
return 0;
}
@@ -69,19 +69,19 @@ isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length)
s = zclient->ibuf;
ifp = zebra_interface_state_read (s);
-
+
if (!ifp)
return 0;
if (if_is_up (ifp))
zlog_warn ("Zebra: got delete of %s, but interface is still up",
- ifp->name);
+ ifp->name);
zlog_info ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d",
ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
if_delete (ifp);
-
+
isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
return 0;
@@ -120,103 +120,104 @@ zebra_interface_if_set_value (struct stream *s, struct interface *ifp)
}
int
-isis_zebra_if_state_up (int command, struct zclient *zclient,
+isis_zebra_if_state_up (int command, struct zclient *zclient,
zebra_size_t length)
{
struct interface *ifp;
-
+
ifp = zebra_interface_if_lookup (zclient->ibuf);
-
+
if (!ifp)
return 0;
-
- if (if_is_up (ifp)) {
- zebra_interface_if_set_value (zclient->ibuf, ifp);
- isis_circuit_update_params (circuit_scan_by_ifp (ifp), ifp);
- return 0;
- }
-
+
+ if (if_is_up (ifp))
+ {
+ zebra_interface_if_set_value (zclient->ibuf, ifp);
+ isis_circuit_update_params (circuit_scan_by_ifp (ifp), ifp);
+ return 0;
+ }
+
zebra_interface_if_set_value (zclient->ibuf, ifp);
isis_csm_state_change (IF_UP_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
-
+
return 0;
}
-
int
-isis_zebra_if_state_down (int command, struct zclient *zclient,
+isis_zebra_if_state_down (int command, struct zclient *zclient,
zebra_size_t length)
{
struct interface *ifp;
-
+
ifp = zebra_interface_if_lookup (zclient->ibuf);
-
+
if (ifp == NULL)
return 0;
-
- if (if_is_up (ifp)) {
- zebra_interface_if_set_value (zclient->ibuf, ifp);
- isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
- }
-
+
+ if (if_is_up (ifp))
+ {
+ zebra_interface_if_set_value (zclient->ibuf, ifp);
+ isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp);
+ }
+
return 0;
}
int
-isis_zebra_if_address_add (int command, struct zclient *zclient,
- zebra_size_t length)
+isis_zebra_if_address_add (int command, struct zclient *zclient,
+ zebra_size_t length)
{
struct connected *c;
struct prefix *p;
u_char buf[BUFSIZ];
- c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
- zclient->ibuf);
-
+ c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD,
+ zclient->ibuf);
+
if (c == NULL)
return 0;
-
+
p = c->address;
-
+
prefix2str (p, buf, BUFSIZ);
#ifdef EXTREME_DEBUG
- if (p->family == AF_INET)
+ if (p->family == AF_INET)
zlog_info ("connected IP address %s", buf);
#ifdef HAVE_IPV6
if (p->family == AF_INET6)
zlog_info ("connected IPv6 address %s", buf);
#endif /* HAVE_IPV6 */
#endif /* EXTREME_DEBUG */
- isis_circuit_add_addr (circuit_scan_by_ifp (c->ifp), c);
+ isis_circuit_add_addr (circuit_scan_by_ifp (c->ifp), c);
return 0;
}
int
-isis_zebra_if_address_del (int command, struct zclient *client,
- zebra_size_t length)
+isis_zebra_if_address_del (int command, struct zclient *client,
+ zebra_size_t length)
{
struct connected *c;
struct interface *ifp;
- c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
- zclient->ibuf);
-
+ c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE,
+ zclient->ibuf);
+
if (c == NULL)
return 0;
-
+
ifp = c->ifp;
-
+
connected_free (c);
-
+
isis_circuit_del_addr (circuit_scan_by_ifp (ifp), c);
-
+
return 0;
}
void
-isis_zebra_route_add_ipv4 (struct prefix *prefix,
- struct isis_route_info *route_info)
+isis_zebra_route_add_ipv4 (struct prefix *prefix,
+ struct isis_route_info *route_info)
{
u_char message, flags;
int psize;
@@ -227,83 +228,89 @@ isis_zebra_route_add_ipv4 (struct prefix *prefix,
if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC))
return;
- if (zclient->redist[ZEBRA_ROUTE_ISIS]) {
- message = 0;
- flags = 0;
-
- SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP);
- SET_FLAG (message, ZAPI_MESSAGE_METRIC);
+ if (zclient->redist[ZEBRA_ROUTE_ISIS])
+ {
+ message = 0;
+ flags = 0;
+
+ SET_FLAG (message, ZAPI_MESSAGE_NEXTHOP);
+ SET_FLAG (message, ZAPI_MESSAGE_METRIC);
#if 0
- SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
+ SET_FLAG (message, ZAPI_MESSAGE_DISTANCE);
#endif
-
- stream = zclient->obuf;
- stream_reset (stream);
- /* Length place holder. */
- stream_putw (stream, 0);
- /* command */
- stream_putc (stream, ZEBRA_IPV4_ROUTE_ADD);
- /* type */
- stream_putc (stream, ZEBRA_ROUTE_ISIS);
- /* flags */
- stream_putc (stream, flags);
- /* message */
- stream_putc (stream, message);
- /* prefix information */
- psize = PSIZE (prefix->prefixlen);
- stream_putc (stream, prefix->prefixlen);
- stream_write (stream, (u_char *)&prefix->u.prefix4, psize);
-
- stream_putc (stream, listcount (route_info->nexthops));
-
- /* Nexthop, ifindex, distance and metric information */
- for (node = listhead (route_info->nexthops); node; nextnode (node)) {
- nexthop = getdata (node);
- /* FIXME: can it be ? */
- if (nexthop->ip.s_addr != INADDR_ANY) {
- stream_putc (stream, ZEBRA_NEXTHOP_IPV4);
- stream_put_in_addr (stream, &nexthop->ip);
- } else {
- stream_putc (stream, ZEBRA_NEXTHOP_IFINDEX);
- stream_putl (stream, nexthop->ifindex);
- }
- }
+
+ stream = zclient->obuf;
+ stream_reset (stream);
+ /* Length place holder. */
+ stream_putw (stream, 0);
+ /* command */
+ stream_putc (stream, ZEBRA_IPV4_ROUTE_ADD);
+ /* type */
+ stream_putc (stream, ZEBRA_ROUTE_ISIS);
+ /* flags */
+ stream_putc (stream, flags);
+ /* message */
+ stream_putc (stream, message);
+ /* prefix information */
+ psize = PSIZE (prefix->prefixlen);
+ stream_putc (stream, prefix->prefixlen);
+ stream_write (stream, (u_char *) & prefix->u.prefix4, psize);
+
+ stream_putc (stream, listcount (route_info->nexthops));
+
+ /* Nexthop, ifindex, distance and metric information */
+ for (node = listhead (route_info->nexthops); node; nextnode (node))
+ {
+ nexthop = getdata (node);
+ /* FIXME: can it be ? */
+ if (nexthop->ip.s_addr != INADDR_ANY)
+ {
+ stream_putc (stream, ZEBRA_NEXTHOP_IPV4);
+ stream_put_in_addr (stream, &nexthop->ip);
+ }
+ else
+ {
+ stream_putc (stream, ZEBRA_NEXTHOP_IFINDEX);
+ stream_putl (stream, nexthop->ifindex);
+ }
+ }
#if 0
- if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
- stream_putc (stream, route_info->depth);
+ if (CHECK_FLAG (message, ZAPI_MESSAGE_DISTANCE))
+ stream_putc (stream, route_info->depth);
#endif
- if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
- stream_putl (stream, route_info->cost);
-
- stream_putw_at (stream, 0, stream_get_endp (stream));
- writen (zclient->sock, stream->data, stream_get_endp (stream));
- }
+ if (CHECK_FLAG (message, ZAPI_MESSAGE_METRIC))
+ stream_putl (stream, route_info->cost);
+
+ stream_putw_at (stream, 0, stream_get_endp (stream));
+ writen (zclient->sock, stream->data, stream_get_endp (stream));
+ }
}
void
-isis_zebra_route_del_ipv4 (struct prefix *prefix,
- struct isis_route_info *route_info)
+isis_zebra_route_del_ipv4 (struct prefix *prefix,
+ struct isis_route_info *route_info)
{
struct zapi_ipv4 api;
struct prefix_ipv4 prefix4;
-
- if (zclient->redist[ZEBRA_ROUTE_ISIS]) {
- api.type = ZEBRA_ROUTE_ISIS;
- api.flags = 0;
- api.message = 0;
- prefix4.family = AF_INET;
- prefix4.prefixlen = prefix->prefixlen;
- prefix4.prefix = prefix->u.prefix4;
- zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, &prefix4, &api);
- }
-
+
+ if (zclient->redist[ZEBRA_ROUTE_ISIS])
+ {
+ api.type = ZEBRA_ROUTE_ISIS;
+ api.flags = 0;
+ api.message = 0;
+ prefix4.family = AF_INET;
+ prefix4.prefixlen = prefix->prefixlen;
+ prefix4.prefix = prefix->u.prefix4;
+ zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, &prefix4, &api);
+ }
+
return;
}
#ifdef HAVE_IPV6
void
isis_zebra_route_add_ipv6 (struct prefix *prefix,
- struct isis_route_info *route_info)
+ struct isis_route_info *route_info)
{
struct zapi_ipv6 api;
struct in6_addr **nexthop_list;
@@ -315,7 +322,7 @@ isis_zebra_route_add_ipv6 (struct prefix *prefix,
if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC))
return;
-
+
api.type = ZEBRA_ROUTE_ISIS;
api.flags = 0;
api.message = 0;
@@ -329,61 +336,66 @@ isis_zebra_route_add_ipv6 (struct prefix *prefix,
#endif
api.nexthop_num = listcount (route_info->nexthops6);
api.ifindex_num = listcount (route_info->nexthops6);
-
+
/* allocate memory for nexthop_list */
size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6);
nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size);
- if (!nexthop_list) {
- zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
- return;
- }
-
+ if (!nexthop_list)
+ {
+ zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
+ return;
+ }
+
/* allocate memory for ifindex_list */
size = sizeof (unsigned int) * listcount (route_info->nexthops6);
ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size);
- if (!ifindex_list) {
- zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
- XFREE (MTYPE_ISIS_TMP, nexthop_list);
- return;
- }
-
+ if (!ifindex_list)
+ {
+ zlog_err ("isis_zebra_add_route_ipv6: out of memory!");
+ XFREE (MTYPE_ISIS_TMP, nexthop_list);
+ return;
+ }
+
/* for each nexthop */
i = 0;
- for (node = listhead (route_info->nexthops6); node; nextnode (node)) {
- nexthop6 = getdata (node);
-
- if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
- !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6)) {
- api.nexthop_num--;
- api.ifindex_num--;
- continue;
+ for (node = listhead (route_info->nexthops6); node; nextnode (node))
+ {
+ nexthop6 = getdata (node);
+
+ if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
+ !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
+ {
+ api.nexthop_num--;
+ api.ifindex_num--;
+ continue;
+ }
+
+ nexthop_list[i] = &nexthop6->ip6;
+ ifindex_list[i] = nexthop6->ifindex;
+ i++;
}
-
- nexthop_list[i] = &nexthop6->ip6;
- ifindex_list[i] = nexthop6->ifindex;
- i++;
- }
-
+
api.nexthop = nexthop_list;
api.ifindex = ifindex_list;
-
- if (api.nexthop_num && api.ifindex_num) {
- prefix6.family = AF_INET6;
- prefix6.prefixlen = prefix->prefixlen;
- memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
- zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, &prefix6, &api);
- SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC);
- }
-
+
+ if (api.nexthop_num && api.ifindex_num)
+ {
+ prefix6.family = AF_INET6;
+ prefix6.prefixlen = prefix->prefixlen;
+ memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
+ zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, &prefix6, &api);
+ SET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC);
+ }
+
XFREE (MTYPE_ISIS_TMP, nexthop_list);
XFREE (MTYPE_ISIS_TMP, ifindex_list);
-
+
return;
}
void
-isis_zebra_route_del_ipv6 (struct prefix *prefix,
- struct isis_route_info *route_info)
+isis_zebra_route_del_ipv6 (struct prefix *prefix,
+ struct isis_route_info *route_info)
{
struct zapi_ipv6 api;
struct in6_addr **nexthop_list;
@@ -395,7 +407,7 @@ isis_zebra_route_del_ipv6 (struct prefix *prefix,
if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC))
return;
-
+
api.type = ZEBRA_ROUTE_ISIS;
api.flags = 0;
api.message = 0;
@@ -403,64 +415,66 @@ isis_zebra_route_del_ipv6 (struct prefix *prefix,
SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
api.nexthop_num = listcount (route_info->nexthops6);
api.ifindex_num = listcount (route_info->nexthops6);
-
+
/* allocate memory for nexthop_list */
size = sizeof (struct isis_nexthop6 *) * listcount (route_info->nexthops6);
nexthop_list = (struct in6_addr **) XMALLOC (MTYPE_ISIS_TMP, size);
- if (!nexthop_list) {
- zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
- return;
- }
-
+ if (!nexthop_list)
+ {
+ zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
+ return;
+ }
+
/* allocate memory for ifindex_list */
size = sizeof (unsigned int) * listcount (route_info->nexthops6);
ifindex_list = (unsigned int *) XMALLOC (MTYPE_ISIS_TMP, size);
- if (!ifindex_list) {
- zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
- XFREE (MTYPE_ISIS_TMP, nexthop_list);
- return;
- }
-
+ if (!ifindex_list)
+ {
+ zlog_err ("isis_zebra_route_del_ipv6: out of memory!");
+ XFREE (MTYPE_ISIS_TMP, nexthop_list);
+ return;
+ }
+
/* for each nexthop */
i = 0;
- for (node = listhead (route_info->nexthops6); node; nextnode (node)) {
- nexthop6 = getdata (node);
-
- if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
- !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6)) {
- api.nexthop_num--;
- api.ifindex_num--;
- continue;
+ for (node = listhead (route_info->nexthops6); node; nextnode (node))
+ {
+ nexthop6 = getdata (node);
+
+ if (!IN6_IS_ADDR_LINKLOCAL (&nexthop6->ip6) &&
+ !IN6_IS_ADDR_UNSPECIFIED (&nexthop6->ip6))
+ {
+ api.nexthop_num--;
+ api.ifindex_num--;
+ continue;
+ }
+
+ nexthop_list[i] = &nexthop6->ip6;
+ ifindex_list[i] = nexthop6->ifindex;
+ i++;
}
-
- nexthop_list[i] = &nexthop6->ip6;
- ifindex_list[i] = nexthop6->ifindex;
- i++;
- }
-
+
api.nexthop = nexthop_list;
api.ifindex = ifindex_list;
-
- if (api.nexthop_num && api.ifindex_num) {
- prefix6.family = AF_INET6;
- prefix6.prefixlen = prefix->prefixlen;
- memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
- zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, &prefix6, &api);
- UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC);
- }
-
+
+ if (api.nexthop_num && api.ifindex_num)
+ {
+ prefix6.family = AF_INET6;
+ prefix6.prefixlen = prefix->prefixlen;
+ memcpy (&prefix6.prefix, &prefix->u.prefix6, sizeof (struct in6_addr));
+ zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, &prefix6, &api);
+ UNSET_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNC);
+ }
+
XFREE (MTYPE_ISIS_TMP, nexthop_list);
- XFREE (MTYPE_ISIS_TMP, ifindex_list);
+ XFREE (MTYPE_ISIS_TMP, ifindex_list);
}
-
#endif /* HAVE_IPV6 */
-
-
void
isis_zebra_route_update (struct prefix *prefix,
- struct isis_route_info *route_info)
+ struct isis_route_info *route_info)
{
if (zclient->sock < 0)
return;
@@ -468,27 +482,29 @@ isis_zebra_route_update (struct prefix *prefix,
if (!zclient->redist[ZEBRA_ROUTE_ISIS])
return;
- if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE)) {
- if (prefix->family == AF_INET)
- isis_zebra_route_add_ipv4 (prefix, route_info);
+ if (CHECK_FLAG (route_info->flag, ISIS_ROUTE_FLAG_ACTIVE))
+ {
+ if (prefix->family == AF_INET)
+ isis_zebra_route_add_ipv4 (prefix, route_info);
#ifdef HAVE_IPV6
- else if (prefix->family == AF_INET6)
- isis_zebra_route_add_ipv6 (prefix, route_info);
+ else if (prefix->family == AF_INET6)
+ isis_zebra_route_add_ipv6 (prefix, route_info);
#endif /* HAVE_IPV6 */
- } else {
- if (prefix->family == AF_INET)
- isis_zebra_route_del_ipv4 (prefix, route_info);
+ }
+ else
+ {
+ if (prefix->family == AF_INET)
+ isis_zebra_route_del_ipv4 (prefix, route_info);
#ifdef HAVE_IPV6
- else if (prefix->family == AF_INET6)
- isis_zebra_route_del_ipv6 (prefix, route_info);
+ else if (prefix->family == AF_INET6)
+ isis_zebra_route_del_ipv6 (prefix, route_info);
#endif /* HAVE_IPV6 */
- }
+ }
return;
}
-
int
-isis_zebra_read_ipv4 (int command, struct zclient *zclient,
+isis_zebra_read_ipv4 (int command, struct zclient *zclient,
zebra_size_t length)
{
struct stream *stream;
@@ -501,42 +517,43 @@ isis_zebra_read_ipv4 (int command, struct zclient *zclient,
memset (&p, 0, sizeof (struct prefix_ipv4));
ifindex = 0;
- api.type = stream_getc (stream);
- api.flags = stream_getc (stream);
+ api.type = stream_getc (stream);
+ api.flags = stream_getc (stream);
api.message = stream_getc (stream);
p.family = AF_INET;
p.prefixlen = stream_getc (stream);
stream_get (&p.prefix, stream, PSIZE (p.prefixlen));
-
- if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP)) {
+
+ if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
+ {
api.nexthop_num = stream_getc (stream);
nexthop.s_addr = stream_get_ipv4 (stream);
- }
- if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX)) {
- api.ifindex_num = stream_getc (stream);
- ifindex = stream_getl (stream);
- }
+ }
+ if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
+ {
+ api.ifindex_num = stream_getc (stream);
+ ifindex = stream_getl (stream);
+ }
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
api.distance = stream_getc (stream);
if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
api.metric = stream_getl (stream);
else
api.metric = 0;
-
- if (command == ZEBRA_IPV4_ROUTE_ADD) {
- zlog_info ("IPv4 Route add from Z");
- }
+
+ if (command == ZEBRA_IPV4_ROUTE_ADD)
+ {
+ zlog_info ("IPv4 Route add from Z");
+ }
return 0;
}
-
-int
-isis_zebra_read_ipv6 (int command, struct zclient *zclient,
+int
+isis_zebra_read_ipv6 (int command, struct zclient *zclient,
zebra_size_t length)
{
-
return 0;
}
@@ -550,16 +567,15 @@ isis_distribute_list_update (int routetype)
}
int
-isis_redistribute_default_set(int routetype, int metric_type, int metric_value)
+isis_redistribute_default_set (int routetype, int metric_type,
+ int metric_value)
{
return 0;
}
-
void
isis_zebra_init ()
{
-
zclient = zclient_new ();
zclient_init (zclient, ZEBRA_ROUTE_ISIS);
zclient->interface_add = isis_zebra_if_add;
@@ -581,17 +597,9 @@ isis_zebra_init ()
void
isis_zebra_finish ()
{
-
zclient_stop (zclient);
zclient_free (zclient);
zclient = (struct zclient *) NULL;
return;
}
-
-
-
-
-
-
-
diff --git a/isisd/isis_zebra.h b/isisd/isis_zebra.h
index fabf72005..0dce79957 100644
--- a/isisd/isis_zebra.h
+++ b/isisd/isis_zebra.h
@@ -26,8 +26,8 @@ extern struct zclient *zclient;
void isis_zebra_init (void);
void isis_zebra_finish (void);
-void isis_zebra_route_update (struct prefix *prefix,
- struct isis_route_info *route_info);
+void isis_zebra_route_update (struct prefix *prefix,
+ struct isis_route_info *route_info);
int isis_distribute_list_update (int routetype);
#endif /* _ZEBRA_ISIS_ZEBRA_H */
diff --git a/isisd/isisd.c b/isisd/isisd.c
index 8d0b3a212..3c499dc3c 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -56,19 +56,16 @@
#ifdef TOPOLOGY_GENERATE
#include "spgrid.h"
-u_char DEFAULT_TOPOLOGY_BASEIS[6] = {0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00};
+u_char DEFAULT_TOPOLOGY_BASEIS[6] = { 0xFE, 0xED, 0xFE, 0xED, 0x00, 0x00 };
#endif /* TOPOLOGY_GENERATE */
-
struct isis *isis = NULL;
struct thread_master *master;
-
void
isis_new (unsigned long process_id)
{
-
- isis = XMALLOC (MTYPE_ISIS, sizeof(struct isis));
+ isis = XMALLOC (MTYPE_ISIS, sizeof (struct isis));
bzero (isis, sizeof (struct isis));
/*
* Default values
@@ -86,15 +83,14 @@ isis_new (unsigned long process_id)
/*
* uncomment the next line for full debugs
*/
- /* isis->debugs = 0xFFFF; */
+ /* isis->debugs = 0xFFFF; */
}
struct isis_area *
isis_area_create ()
{
-
struct isis_area *area;
-
+
area = XMALLOC (MTYPE_ISIS_AREA, sizeof (struct isis_area));
memset (area, 0, sizeof (struct isis_area));
@@ -111,7 +107,7 @@ isis_area_create ()
*/
area->lspdb[0] = lsp_db_init ();
area->lspdb[1] = lsp_db_init ();
-
+
spftree_area_init (area);
area->route_table = route_table_init ();
#ifdef HAVE_IPV6
@@ -119,17 +115,17 @@ isis_area_create ()
#endif /* HAVE_IPV6 */
area->circuit_list = list_new ();
area->area_addrs = list_new ();
- THREAD_TIMER_ON(master, area->t_tick, lsp_tick, area, 1);
+ THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
area->flags.maxindex = -1;
/*
* Default values
*/
- area->max_lsp_lifetime[0] = MAX_AGE; /* 1200 */
- area->max_lsp_lifetime[1] = MAX_AGE; /* 1200 */
+ area->max_lsp_lifetime[0] = MAX_AGE; /* 1200 */
+ area->max_lsp_lifetime[1] = MAX_AGE; /* 1200 */
area->lsp_gen_interval[0] = LSP_GEN_INTERVAL_DEFAULT;
area->lsp_gen_interval[1] = LSP_GEN_INTERVAL_DEFAULT;
- area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900 */
- area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900 */
+ area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900 */
+ area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900 */
area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
area->dynhostname = 1;
@@ -149,81 +145,83 @@ isis_area_lookup (char *area_tag)
{
struct isis_area *area;
struct listnode *node;
-
+
LIST_LOOP (isis->area_list, area, node)
if ((area->area_tag == NULL && area_tag == NULL) ||
- (area->area_tag && area_tag && strcmp (area->area_tag, area_tag) == 0))
- return area;
-
+ (area->area_tag && area_tag
+ && strcmp (area->area_tag, area_tag) == 0))
+ return area;
+
return NULL;
}
-int
+int
isis_area_get (struct vty *vty, char *area_tag)
{
-
struct isis_area *area;
-
+
area = isis_area_lookup (area_tag);
-
- if (area) {
- vty->node = ISIS_NODE;
- vty->index = area;
- return CMD_SUCCESS;
- }
-
+
+ if (area)
+ {
+ vty->node = ISIS_NODE;
+ vty->index = area;
+ return CMD_SUCCESS;
+ }
+
area = isis_area_create ();
area->area_tag = strdup (area_tag);
listnode_add (isis->area_list, area);
-
+
zlog_info ("new IS-IS area instance %s", area->area_tag);
vty->node = ISIS_NODE;
vty->index = area;
-
+
return CMD_SUCCESS;
}
int
isis_area_destroy (struct vty *vty, char *area_tag)
{
-
struct isis_area *area;
struct listnode *node;
struct isis_circuit *circuit;
area = isis_area_lookup (area_tag);
-
- if (area == NULL) {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (area->circuit_list) {
- node = listhead (area->circuit_list);
- while (node) {
- circuit = getdata (node);
- nextnode (node);
- isis_circuit_del (circuit);
+ if (area == NULL)
+ {
+ vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (area->circuit_list)
+ {
+ node = listhead (area->circuit_list);
+ while (node)
+ {
+ circuit = getdata (node);
+ nextnode (node);
+ isis_circuit_del (circuit);
+ }
+ list_delete (area->circuit_list);
}
- list_delete (area->circuit_list);
- }
listnode_delete (isis->area_list, area);
- THREAD_TIMER_OFF(area->t_tick);
+ THREAD_TIMER_OFF (area->t_tick);
if (area->t_remove_aged)
thread_cancel (area->t_remove_aged);
- THREAD_TIMER_OFF(area->t_lsp_refresh[0]);
- THREAD_TIMER_OFF(area->t_lsp_refresh[1]);
+ THREAD_TIMER_OFF (area->t_lsp_refresh[0]);
+ THREAD_TIMER_OFF (area->t_lsp_refresh[1]);
XFREE (MTYPE_ISIS_AREA, area);
-
+
return CMD_SUCCESS;
}
-int
-area_net_title (struct vty *vty , char *net_title)
+int
+area_net_title (struct vty *vty, char *net_title)
{
-
struct isis_area *area;
struct area_addr *addr;
struct area_addr *addrp;
@@ -232,62 +230,73 @@ area_net_title (struct vty *vty , char *net_title)
u_char buff[255];
area = vty->index;
- if (!area) {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!area)
+ {
+ vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
/* We check that we are not over the maximal number of addresses */
- if (listcount (area->area_addrs) >= isis->max_area_addrs) {
- vty_out (vty, "Maximum of area addresses (%d) already reached %s",
- isis->max_area_addrs, VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (listcount (area->area_addrs) >= isis->max_area_addrs)
+ {
+ vty_out (vty, "Maximum of area addresses (%d) already reached %s",
+ isis->max_area_addrs, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
addr = XMALLOC (MTYPE_ISIS_AREA_ADDR, sizeof (struct area_addr));
addr->addr_len = dotformat2buff (buff, net_title);
memcpy (addr->area_addr, buff, addr->addr_len);
#ifdef EXTREME_DEBUG
- zlog_info ("added area address %s for area %s (address length %d)",
+ zlog_info ("added area address %s for area %s (address length %d)",
net_title, area->area_tag, addr->addr_len);
#endif /* EXTREME_DEBUG */
- if (addr->addr_len < 8 || addr->addr_len > 20) {
- zlog_warn ("area address must be at least 8..20 octets long (%d)",
- addr->addr_len);
- XFREE (MTYPE_ISIS_AREA_ADDR, addr);
- return CMD_WARNING;
- }
-
- if (isis->sysid_set == 0) {
- /*
- * First area address - get the SystemID for this router
- */
- memcpy (isis->sysid, GETSYSID(addr, ISIS_SYS_ID_LEN), ISIS_SYS_ID_LEN);
- isis->sysid_set = 1;
- zlog_info ("Router has SystemID %s", sysid_print (isis->sysid));
- } else {
- /*
- * Check that the SystemID portions match
- */
- if (memcmp (isis->sysid, GETSYSID(addr, ISIS_SYS_ID_LEN),
- ISIS_SYS_ID_LEN)) {
- vty_out (vty, "System ID must not change when defining additional area"
- " addresses%s", VTY_NEWLINE);
+ if (addr->addr_len < 8 || addr->addr_len > 20)
+ {
+ zlog_warn ("area address must be at least 8..20 octets long (%d)",
+ addr->addr_len);
XFREE (MTYPE_ISIS_AREA_ADDR, addr);
return CMD_WARNING;
}
- /* now we see that we don't already have this address */
- LIST_LOOP (area->area_addrs, addrp, node) {
- if ((addrp->addr_len+ ISIS_SYS_ID_LEN + 1) == (addr->addr_len)) {
- if (!memcmp (addrp->area_addr, addr->area_addr,addr->addr_len)) {
- XFREE (MTYPE_ISIS_AREA_ADDR, addr);
- return CMD_SUCCESS; /* silent fail */
- }
- }
+ if (isis->sysid_set == 0)
+ {
+ /*
+ * First area address - get the SystemID for this router
+ */
+ memcpy (isis->sysid, GETSYSID (addr, ISIS_SYS_ID_LEN), ISIS_SYS_ID_LEN);
+ isis->sysid_set = 1;
+ zlog_info ("Router has SystemID %s", sysid_print (isis->sysid));
}
+ else
+ {
+ /*
+ * Check that the SystemID portions match
+ */
+ if (memcmp (isis->sysid, GETSYSID (addr, ISIS_SYS_ID_LEN),
+ ISIS_SYS_ID_LEN))
+ {
+ vty_out (vty,
+ "System ID must not change when defining additional area"
+ " addresses%s", VTY_NEWLINE);
+ XFREE (MTYPE_ISIS_AREA_ADDR, addr);
+ return CMD_WARNING;
+ }
- }
+ /* now we see that we don't already have this address */
+ LIST_LOOP (area->area_addrs, addrp, node)
+ {
+ if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == (addr->addr_len))
+ {
+ if (!memcmp (addrp->area_addr, addr->area_addr, addr->addr_len))
+ {
+ XFREE (MTYPE_ISIS_AREA_ADDR, addr);
+ return CMD_SUCCESS; /* silent fail */
+ }
+ }
+ }
+
+ }
/*
* Forget the systemID part of the address
*/
@@ -295,10 +304,11 @@ area_net_title (struct vty *vty , char *net_title)
listnode_add (area->area_addrs, addr);
/* only now we can safely generate our LSPs for this area */
- if (listcount(area->area_addrs) > 0) {
- lsp_l1_generate (area);
- lsp_l2_generate (area);
- }
+ if (listcount (area->area_addrs) > 0)
+ {
+ lsp_l1_generate (area);
+ lsp_l2_generate (area);
+ }
return CMD_SUCCESS;
}
@@ -307,48 +317,50 @@ int
area_clear_net_title (struct vty *vty, char *net_title)
{
struct isis_area *area;
- struct area_addr addr, *addrp = NULL;
+ struct area_addr addr, *addrp = NULL;
struct listnode *node;
u_char buff[255];
area = vty->index;
- if (!area) {
- vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ if (!area)
+ {
+ vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
addr.addr_len = dotformat2buff (buff, net_title);
- if (addr.addr_len < 8 || addr.addr_len > 20) {
- vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
- addr.addr_len, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- memcpy(addr.area_addr, buff, (int)addr.addr_len);
-
+ if (addr.addr_len < 8 || addr.addr_len > 20)
+ {
+ vty_out (vty, "Unsupported area address length %d, should be 8...20 %s",
+ addr.addr_len, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ memcpy (addr.area_addr, buff, (int) addr.addr_len);
+
LIST_LOOP (area->area_addrs, addrp, node)
if (addrp->addr_len == addr.addr_len &&
!memcmp (addrp->area_addr, addr.area_addr, addr.addr_len))
- break;
-
- if (!addrp) {
- vty_out (vty, "No area address %s for area %s %s", net_title,
- area->area_tag, VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ break;
+
+ if (!addrp)
+ {
+ vty_out (vty, "No area address %s for area %s %s", net_title,
+ area->area_tag, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
listnode_delete (area->area_addrs, addrp);
-
+
return CMD_SUCCESS;
}
-
/*
* 'show clns neighbors' command
*/
int
-show_clns_neigh (struct vty *vty, char detail)
+show_clns_neigh (struct vty *vty, char detail)
{
struct listnode *node_area, *node_circ;
struct isis_area *area;
@@ -356,53 +368,69 @@ show_clns_neigh (struct vty *vty, char detail)
struct list *db;
int i;
- if (!isis) {
- vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ if (!isis)
+ {
+ vty_out (vty, "IS-IS Routing Process not enabled%s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
for (node_area = listhead (isis->area_list); node_area;
- nextnode (node_area)) {
- area = getdata (node_area);
- vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
-
- if (detail==ISIS_UI_LEVEL_BRIEF)
- vty_out (vty, " System Id Interface L State "
- "Holdtime SNPA%s", VTY_NEWLINE);
-
- for (node_circ = listhead (area->circuit_list); node_circ;
- nextnode (node_circ)) {
- circuit = getdata (node_circ);
- if (circuit->circ_type == CIRCUIT_T_BROADCAST) {
- for (i = 0; i < 2; i++) {
- db = circuit->u.bc.adjdb[i];
- if (db && db->count) {
- if (detail == ISIS_UI_LEVEL_BRIEF)
- isis_adjdb_iterate (db, (void (*) (struct isis_adjacency *,
- void *))
- isis_adj_print_vty, vty);
- if (detail == ISIS_UI_LEVEL_DETAIL)
- isis_adjdb_iterate (db, (void (*) (struct isis_adjacency *,
- void *))
- isis_adj_print_vty_detail, vty);
- if (detail == ISIS_UI_LEVEL_EXTENSIVE)
- isis_adjdb_iterate (db, (void (*) (struct isis_adjacency *,
- void *))
- isis_adj_print_vty_extensive, vty);
- }
- }
- } else if (circuit->circ_type == CIRCUIT_T_P2P &&
- circuit->u.p2p.neighbor) {
- if (detail==ISIS_UI_LEVEL_BRIEF)
- isis_adj_p2p_print_vty (circuit->u.p2p.neighbor, vty);
- if (detail==ISIS_UI_LEVEL_DETAIL)
- isis_adj_p2p_print_vty_detail (circuit->u.p2p.neighbor, vty);
- if (detail==ISIS_UI_LEVEL_EXTENSIVE)
- isis_adj_p2p_print_vty_extensive (circuit->u.p2p.neighbor, vty);
- }
+ nextnode (node_area))
+ {
+ area = getdata (node_area);
+ vty_out (vty, "Area %s:%s", area->area_tag, VTY_NEWLINE);
+
+ if (detail == ISIS_UI_LEVEL_BRIEF)
+ vty_out (vty, " System Id Interface L State "
+ "Holdtime SNPA%s", VTY_NEWLINE);
+
+ for (node_circ = listhead (area->circuit_list); node_circ;
+ nextnode (node_circ))
+ {
+ circuit = getdata (node_circ);
+ if (circuit->circ_type == CIRCUIT_T_BROADCAST)
+ {
+ for (i = 0; i < 2; i++)
+ {
+ db = circuit->u.bc.adjdb[i];
+ if (db && db->count)
+ {
+ if (detail == ISIS_UI_LEVEL_BRIEF)
+ isis_adjdb_iterate (db,
+ (void (*)
+ (struct isis_adjacency *,
+ void *)) isis_adj_print_vty,
+ vty);
+ if (detail == ISIS_UI_LEVEL_DETAIL)
+ isis_adjdb_iterate (db,
+ (void (*)
+ (struct isis_adjacency *,
+ void *))
+ isis_adj_print_vty_detail, vty);
+ if (detail == ISIS_UI_LEVEL_EXTENSIVE)
+ isis_adjdb_iterate (db,
+ (void (*)
+ (struct isis_adjacency *,
+ void *))
+ isis_adj_print_vty_extensive,
+ vty);
+ }
+ }
+ }
+ else if (circuit->circ_type == CIRCUIT_T_P2P &&
+ circuit->u.p2p.neighbor)
+ {
+ if (detail == ISIS_UI_LEVEL_BRIEF)
+ isis_adj_p2p_print_vty (circuit->u.p2p.neighbor, vty);
+ if (detail == ISIS_UI_LEVEL_DETAIL)
+ isis_adj_p2p_print_vty_detail (circuit->u.p2p.neighbor, vty);
+ if (detail == ISIS_UI_LEVEL_EXTENSIVE)
+ isis_adj_p2p_print_vty_extensive (circuit->u.p2p.neighbor,
+ vty);
+ }
+ }
}
- }
-
+
return CMD_SUCCESS;
}
@@ -413,7 +441,7 @@ DEFUN (show_clns_neighbors,
"clns network information\n"
"CLNS neighbor adjacencies\n")
{
- return show_clns_neigh(vty, ISIS_UI_LEVEL_BRIEF);
+ return show_clns_neigh (vty, ISIS_UI_LEVEL_BRIEF);
}
ALIAS (show_clns_neighbors,
@@ -431,7 +459,7 @@ DEFUN (show_clns_neighbors_detail,
"CLNS neighbor adjacencies\n"
"show detailed information\n")
{
- return show_clns_neigh(vty, ISIS_UI_LEVEL_DETAIL);
+ return show_clns_neigh (vty, ISIS_UI_LEVEL_DETAIL);
}
ALIAS (show_clns_neighbors_detail,
@@ -441,53 +469,49 @@ ALIAS (show_clns_neighbors_detail,
"IS-IS network information\n"
"IS-IS neighbor adjacencies\n"
"show detailed information\n")
-
/*
* 'isis debug', 'show debugging'
*/
-
void
print_debug (struct vty *vty, int flags, int onoff)
{
char onoffs[4];
if (onoff)
- strcpy (onoffs,"on");
+ strcpy (onoffs, "on");
else
- strcpy (onoffs,"off");
+ strcpy (onoffs, "off");
if (flags & DEBUG_ADJ_PACKETS)
- vty_out (vty,"IS-IS Adjacency related packets debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS Adjacency related packets debugging is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_CHECKSUM_ERRORS)
- vty_out (vty,"IS-IS checksum errors debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS checksum errors debugging is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_LOCAL_UPDATES)
- vty_out (vty,"IS-IS local updates debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS local updates debugging is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_PROTOCOL_ERRORS)
- vty_out (vty,"IS-IS protocol errors debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS protocol errors debugging is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_SNP_PACKETS)
- vty_out (vty,"IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS CSNP/PSNP packets debugging is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_SPF_EVENTS)
- vty_out (vty,"IS-IS SPF events debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS SPF events debugging is %s%s", onoffs, VTY_NEWLINE);
if (flags & DEBUG_SPF_STATS)
- vty_out (vty,"IS-IS SPF Timing and Statistics Data debugging is %s%s",
- onoffs, VTY_NEWLINE);
+ vty_out (vty, "IS-IS SPF Timing and Statistics Data debugging is %s%s",
+ onoffs, VTY_NEWLINE);
if (flags & DEBUG_SPF_TRIGGERS)
- vty_out (vty,"IS-IS SPF triggering events debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS SPF triggering events debugging is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_UPDATE_PACKETS)
- vty_out (vty,"IS-IS Update related packet debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS Update related packet debugging is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_RTE_EVENTS)
- vty_out (vty,"IS-IS Route related debuggin is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS Route related debuggin is %s%s", onoffs,
+ VTY_NEWLINE);
if (flags & DEBUG_EVENTS)
- vty_out (vty,"IS-IS Event debugging is %s%s", onoffs,
- VTY_NEWLINE);
+ vty_out (vty, "IS-IS Event debugging is %s%s", onoffs, VTY_NEWLINE);
}
@@ -497,17 +521,16 @@ DEFUN (show_debugging,
SHOW_STR
"State of each debugging option\n")
{
- vty_out (vty,"IS-IS:%s", VTY_NEWLINE);
+ vty_out (vty, "IS-IS:%s", VTY_NEWLINE);
print_debug (vty, isis->debugs, 1);
return CMD_SUCCESS;
}
/* Debug node. */
-static struct cmd_node debug_node =
-{
+static struct cmd_node debug_node = {
DEBUG_NODE,
- "",
- 1
+ "",
+ 1
};
static int
@@ -516,61 +539,61 @@ config_write_debug (struct vty *vty)
int write = 0;
int flags = isis->debugs;
- if (flags & DEBUG_ADJ_PACKETS) {
- vty_out (vty, "debug isis adj-packets%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_CHECKSUM_ERRORS) {
- vty_out (vty, "debug isis checksum-errors%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_LOCAL_UPDATES) {
- vty_out (vty, "debug isis local-updates%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_PROTOCOL_ERRORS) {
- vty_out (vty, "debug isis protocol-errors%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_SNP_PACKETS) {
- vty_out (vty, "debug isis snp-packets%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_SPF_EVENTS) {
- vty_out (vty, "debug isis spf-events%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_SPF_STATS) {
- vty_out (vty, "debug isis spf-statistics%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_SPF_TRIGGERS) {
- vty_out (vty, "debug isis spf-triggers%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_UPDATE_PACKETS) {
- vty_out (vty, "debug isis update-packets%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_RTE_EVENTS) {
- vty_out (vty, "debug isis route-events%s",
- VTY_NEWLINE);
- write++;
- }
- if (flags & DEBUG_EVENTS) {
- vty_out (vty, "debug isis events%s",
- VTY_NEWLINE);
- write++;
- }
+ if (flags & DEBUG_ADJ_PACKETS)
+ {
+ vty_out (vty, "debug isis adj-packets%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_CHECKSUM_ERRORS)
+ {
+ vty_out (vty, "debug isis checksum-errors%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_LOCAL_UPDATES)
+ {
+ vty_out (vty, "debug isis local-updates%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_PROTOCOL_ERRORS)
+ {
+ vty_out (vty, "debug isis protocol-errors%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_SNP_PACKETS)
+ {
+ vty_out (vty, "debug isis snp-packets%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_SPF_EVENTS)
+ {
+ vty_out (vty, "debug isis spf-events%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_SPF_STATS)
+ {
+ vty_out (vty, "debug isis spf-statistics%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_SPF_TRIGGERS)
+ {
+ vty_out (vty, "debug isis spf-triggers%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_UPDATE_PACKETS)
+ {
+ vty_out (vty, "debug isis update-packets%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_RTE_EVENTS)
+ {
+ vty_out (vty, "debug isis route-events%s", VTY_NEWLINE);
+ write++;
+ }
+ if (flags & DEBUG_EVENTS)
+ {
+ vty_out (vty, "debug isis events%s", VTY_NEWLINE);
+ write++;
+ }
return write;
}
@@ -580,11 +603,10 @@ DEFUN (debug_isis_adj,
"debug isis adj-packets",
DEBUG_STR
"IS-IS information\n"
- "IS-IS Adjacency related packets\n"
- )
+ "IS-IS Adjacency related packets\n")
{
isis->debugs |= DEBUG_ADJ_PACKETS;
- print_debug (vty,DEBUG_ADJ_PACKETS,1);
+ print_debug (vty, DEBUG_ADJ_PACKETS, 1);
return CMD_SUCCESS;
}
@@ -594,24 +616,20 @@ DEFUN (no_debug_isis_adj,
"no debug isis adj-packets",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS Adjacency related packets\n"
- )
+ "IS-IS Adjacency related packets\n")
{
-
isis->debugs &= ~DEBUG_ADJ_PACKETS;
print_debug (vty, DEBUG_ADJ_PACKETS, 0);
return CMD_SUCCESS;
}
-
DEFUN (debug_isis_csum,
debug_isis_csum_cmd,
"debug isis checksum-errors",
DEBUG_STR
"IS-IS information\n"
- "IS-IS LSP checksum errors\n"
- )
+ "IS-IS LSP checksum errors\n")
{
isis->debugs |= DEBUG_CHECKSUM_ERRORS;
print_debug (vty, DEBUG_CHECKSUM_ERRORS, 1);
@@ -624,12 +642,11 @@ DEFUN (no_debug_isis_csum,
"no debug isis checksum-errors",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS LSP checksum errors\n"
- )
+ "IS-IS LSP checksum errors\n")
{
isis->debugs &= ~DEBUG_CHECKSUM_ERRORS;
print_debug (vty, DEBUG_CHECKSUM_ERRORS, 0);
-
+
return CMD_SUCCESS;
}
@@ -638,8 +655,7 @@ DEFUN (debug_isis_lupd,
"debug isis local-updates",
DEBUG_STR
"IS-IS information\n"
- "IS-IS local update packets\n"
- )
+ "IS-IS local update packets\n")
{
isis->debugs |= DEBUG_LOCAL_UPDATES;
print_debug (vty, DEBUG_LOCAL_UPDATES, 1);
@@ -652,22 +668,20 @@ DEFUN (no_debug_isis_lupd,
"no debug isis local-updates",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS local update packets\n"
- )
+ "IS-IS local update packets\n")
{
isis->debugs &= ~DEBUG_LOCAL_UPDATES;
- print_debug (vty, DEBUG_LOCAL_UPDATES , 0);
-
+ print_debug (vty, DEBUG_LOCAL_UPDATES, 0);
+
return CMD_SUCCESS;
}
DEFUN (debug_isis_err,
debug_isis_err_cmd,
- "debug isis protocol-errors",
+ "debug isis protocol-errors",
DEBUG_STR
"IS-IS information\n"
- "IS-IS LSP protocol errors\n"
- )
+ "IS-IS LSP protocol errors\n")
{
isis->debugs |= DEBUG_PROTOCOL_ERRORS;
print_debug (vty, DEBUG_PROTOCOL_ERRORS, 1);
@@ -680,12 +694,11 @@ DEFUN (no_debug_isis_err,
"no debug isis protocol-errors",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS LSP protocol errors\n"
- )
+ "IS-IS LSP protocol errors\n")
{
isis->debugs &= ~DEBUG_PROTOCOL_ERRORS;
print_debug (vty, DEBUG_PROTOCOL_ERRORS, 0);
-
+
return CMD_SUCCESS;
}
@@ -694,8 +707,7 @@ DEFUN (debug_isis_snp,
"debug isis snp-packets",
DEBUG_STR
"IS-IS information\n"
- "IS-IS CSNP/PSNP packets\n"
- )
+ "IS-IS CSNP/PSNP packets\n")
{
isis->debugs |= DEBUG_SNP_PACKETS;
print_debug (vty, DEBUG_SNP_PACKETS, 1);
@@ -708,24 +720,20 @@ DEFUN (no_debug_isis_snp,
"no debug isis snp-packets",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS CSNP/PSNP packets\n"
- )
+ "IS-IS CSNP/PSNP packets\n")
{
- isis->debugs &= ~DEBUG_SNP_PACKETS ;
+ isis->debugs &= ~DEBUG_SNP_PACKETS;
print_debug (vty, DEBUG_SNP_PACKETS, 0);
-
+
return CMD_SUCCESS;
}
-
-
DEFUN (debug_isis_upd,
debug_isis_upd_cmd,
"debug isis update-packets",
DEBUG_STR
"IS-IS information\n"
- "IS-IS Update related packets\n"
- )
+ "IS-IS Update related packets\n")
{
isis->debugs |= DEBUG_UPDATE_PACKETS;
print_debug (vty, DEBUG_UPDATE_PACKETS, 1);
@@ -738,26 +746,23 @@ DEFUN (no_debug_isis_upd,
"no debug isis update-packets",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS Update related packets\n"
- )
+ "IS-IS Update related packets\n")
{
isis->debugs &= ~DEBUG_UPDATE_PACKETS;
print_debug (vty, DEBUG_UPDATE_PACKETS, 0);
-
+
return CMD_SUCCESS;
}
-
DEFUN (debug_isis_spfevents,
debug_isis_spfevents_cmd,
"debug isis spf-events",
DEBUG_STR
"IS-IS information\n"
- "IS-IS Shortest Path First Events\n"
- )
+ "IS-IS Shortest Path First Events\n")
{
isis->debugs |= DEBUG_SPF_EVENTS;
- print_debug (vty, DEBUG_SPF_EVENTS , 1);
+ print_debug (vty, DEBUG_SPF_EVENTS, 1);
return CMD_SUCCESS;
}
@@ -767,12 +772,11 @@ DEFUN (no_debug_isis_spfevents,
"no debug isis spf-events",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS Shortest Path First Events\n"
- )
+ "IS-IS Shortest Path First Events\n")
{
isis->debugs &= ~DEBUG_SPF_EVENTS;
- print_debug (vty, DEBUG_SPF_EVENTS , 0);
-
+ print_debug (vty, DEBUG_SPF_EVENTS, 0);
+
return CMD_SUCCESS;
}
@@ -782,8 +786,7 @@ DEFUN (debug_isis_spfstats,
"debug isis spf-statistics ",
DEBUG_STR
"IS-IS information\n"
- "IS-IS SPF Timing and Statistic Data\n"
- )
+ "IS-IS SPF Timing and Statistic Data\n")
{
isis->debugs |= DEBUG_SPF_STATS;
print_debug (vty, DEBUG_SPF_STATS, 1);
@@ -796,12 +799,11 @@ DEFUN (no_debug_isis_spfstats,
"no debug isis spf-statistics",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS SPF Timing and Statistic Data\n"
- )
+ "IS-IS SPF Timing and Statistic Data\n")
{
isis->debugs &= ~DEBUG_SPF_STATS;
print_debug (vty, DEBUG_SPF_STATS, 0);
-
+
return CMD_SUCCESS;
}
@@ -810,8 +812,7 @@ DEFUN (debug_isis_spftrigg,
"debug isis spf-triggers",
DEBUG_STR
"IS-IS information\n"
- "IS-IS SPF triggering events\n"
- )
+ "IS-IS SPF triggering events\n")
{
isis->debugs |= DEBUG_SPF_TRIGGERS;
print_debug (vty, DEBUG_SPF_TRIGGERS, 1);
@@ -824,12 +825,11 @@ DEFUN (no_debug_isis_spftrigg,
"no debug isis spf-triggers",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS SPF triggering events\n"
- )
+ "IS-IS SPF triggering events\n")
{
isis->debugs &= ~DEBUG_SPF_TRIGGERS;
print_debug (vty, DEBUG_SPF_TRIGGERS, 0);
-
+
return CMD_SUCCESS;
}
@@ -838,8 +838,7 @@ DEFUN (debug_isis_rtevents,
"debug isis route-events",
DEBUG_STR
"IS-IS information\n"
- "IS-IS Route related events\n"
- )
+ "IS-IS Route related events\n")
{
isis->debugs |= DEBUG_RTE_EVENTS;
print_debug (vty, DEBUG_RTE_EVENTS, 1);
@@ -852,12 +851,11 @@ DEFUN (no_debug_isis_rtevents,
"no debug isis route-events",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS Route related events\n"
- )
+ "IS-IS Route related events\n")
{
isis->debugs &= ~DEBUG_RTE_EVENTS;
print_debug (vty, DEBUG_RTE_EVENTS, 0);
-
+
return CMD_SUCCESS;
}
@@ -866,8 +864,7 @@ DEFUN (debug_isis_events,
"debug isis events",
DEBUG_STR
"IS-IS information\n"
- "IS-IS Events\n"
- )
+ "IS-IS Events\n")
{
isis->debugs |= DEBUG_EVENTS;
print_debug (vty, DEBUG_EVENTS, 1);
@@ -880,16 +877,14 @@ DEFUN (no_debug_isis_events,
"no debug isis events",
UNDEBUG_STR
"IS-IS information\n"
- "IS-IS Events\n"
- )
+ "IS-IS Events\n")
{
isis->debugs &= ~DEBUG_EVENTS;
print_debug (vty, DEBUG_EVENTS, 0);
-
+
return CMD_SUCCESS;
}
-
DEFUN (show_hostname,
show_hostname_cmd,
"show isis hostname",
@@ -898,51 +893,47 @@ DEFUN (show_hostname,
"IS-IS Dynamic hostname mapping\n")
{
dynhn_print_all (vty);
-
+
return CMD_SUCCESS;
}
-
DEFUN (show_database,
show_database_cmd,
"show isis database",
- SHOW_STR
- "IS-IS information\n"
- "IS-IS link state database\n")
+ SHOW_STR "IS-IS information\n" "IS-IS link state database\n")
{
struct listnode *node;
struct isis_area *area;
- int level,lsp_count;
+ int level, lsp_count;
if (isis->area_list->count == 0)
return CMD_SUCCESS;
-
- for (node = listhead (isis->area_list); node; nextnode (node)) {
- area = getdata (node);
- vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
- VTY_NEWLINE);
- for (level=0;level<ISIS_LEVELS;level++) {
- if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) {
- vty_out (vty,"IS-IS Level-%d link-state database:%s", level+1,
- VTY_NEWLINE);
-
- lsp_count = lsp_print_all (vty, area->lspdb[level],
- ISIS_UI_LEVEL_BRIEF,
- area->dynhostname);
-
- vty_out (vty,"%s %u LSPs%s%s",
- VTY_NEWLINE,
- lsp_count,
- VTY_NEWLINE,
- VTY_NEWLINE);
- }
+
+ for (node = listhead (isis->area_list); node; nextnode (node))
+ {
+ area = getdata (node);
+ vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
+ VTY_NEWLINE);
+ for (level = 0; level < ISIS_LEVELS; level++)
+ {
+ if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
+ {
+ vty_out (vty, "IS-IS Level-%d link-state database:%s",
+ level + 1, VTY_NEWLINE);
+
+ lsp_count = lsp_print_all (vty, area->lspdb[level],
+ ISIS_UI_LEVEL_BRIEF,
+ area->dynhostname);
+
+ vty_out (vty, "%s %u LSPs%s%s",
+ VTY_NEWLINE, lsp_count, VTY_NEWLINE, VTY_NEWLINE);
+ }
+ }
}
- }
return CMD_SUCCESS;
}
-
DEFUN (show_database_detail,
show_database_detail_cmd,
"show isis database detail",
@@ -957,27 +948,27 @@ DEFUN (show_database_detail,
if (isis->area_list->count == 0)
return CMD_SUCCESS;
- for (node = listhead (isis->area_list); node; nextnode (node)) {
- area = getdata (node);
- vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
- VTY_NEWLINE);
- for (level=0;level<ISIS_LEVELS;level++) {
- if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0) {
- vty_out (vty,"IS-IS Level-%d Link State Database:%s", level+1,
- VTY_NEWLINE);
-
- lsp_count = lsp_print_all (vty, area->lspdb[level],
- ISIS_UI_LEVEL_DETAIL,
- area->dynhostname);
-
- vty_out (vty,"%s %u LSPs%s%s",
- VTY_NEWLINE,
- lsp_count,
- VTY_NEWLINE,
- VTY_NEWLINE);
- }
+ for (node = listhead (isis->area_list); node; nextnode (node))
+ {
+ area = getdata (node);
+ vty_out (vty, "Area %s:%s", area->area_tag ? area->area_tag : "null",
+ VTY_NEWLINE);
+ for (level = 0; level < ISIS_LEVELS; level++)
+ {
+ if (area->lspdb[level] && dict_count (area->lspdb[level]) > 0)
+ {
+ vty_out (vty, "IS-IS Level-%d Link State Database:%s",
+ level + 1, VTY_NEWLINE);
+
+ lsp_count = lsp_print_all (vty, area->lspdb[level],
+ ISIS_UI_LEVEL_DETAIL,
+ area->dynhostname);
+
+ vty_out (vty, "%s %u LSPs%s%s",
+ VTY_NEWLINE, lsp_count, VTY_NEWLINE, VTY_NEWLINE);
+ }
+ }
}
- }
return CMD_SUCCESS;
}
@@ -988,13 +979,11 @@ DEFUN (show_database_detail,
DEFUN (router_isis,
router_isis_cmd,
"router isis WORD",
- ROUTER_STR
+ ROUTER_STR
"ISO IS-IS\n"
"ISO Routing area tag")
{
-
return isis_area_get (vty, argv[0]);
-
}
/*
@@ -1003,11 +992,7 @@ DEFUN (router_isis,
DEFUN (no_router_isis,
no_router_isis_cmd,
"no router isis WORD",
- "no\n"
- ROUTER_STR
- "ISO IS-IS\n"
- "ISO Routing area tag")
-
+ "no\n" ROUTER_STR "ISO IS-IS\n" "ISO Routing area tag")
{
return isis_area_destroy (vty, argv[0]);
}
@@ -1019,12 +1004,11 @@ DEFUN (net,
net_cmd,
"net WORD",
"A Network Entity Title for this process (OSI only)\n"
- "XX.XXXX. ... .XXX.XX Network entity title (NET)\n" )
+ "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
{
return area_net_title (vty, argv[0]);
}
-
/*
* 'no net' command
*/
@@ -1033,7 +1017,7 @@ DEFUN (no_net,
"no net WORD",
NO_STR
"A Network Entity Title for this process (OSI only)\n"
- "XX.XXXX. ... .XXX.XX Network entity title (NET)\n" )
+ "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
{
return area_clear_net_title (vty, argv[0]);
}
@@ -1042,27 +1026,29 @@ DEFUN (area_passwd,
area_passwd_cmd,
"area-password WORD",
"Configure the authentication password for an area\n"
- "Area password\n" )
+ "Area password\n")
{
struct isis_area *area;
int len;
area = vty->index;
- if (!area) {
- vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ if (!area)
+ {
+ vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
len = strlen (argv[0]);
- if (len > 254) {
- vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- area->area_passwd.len = (u_char)len;
+ if (len > 254)
+ {
+ vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ area->area_passwd.len = (u_char) len;
area->area_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
strncpy (area->area_passwd.passwd, argv[0], 255);
-
+
return CMD_SUCCESS;
}
@@ -1073,49 +1059,50 @@ DEFUN (no_area_passwd,
"Configure the authentication password for an area\n")
{
struct isis_area *area;
-
+
area = vty->index;
- if (!area) {
- vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ if (!area)
+ {
+ vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
memset (&area->area_passwd, 0, sizeof (struct isis_passwd));
return CMD_SUCCESS;
}
-
DEFUN (domain_passwd,
domain_passwd_cmd,
"domain-password WORD",
"Set the authentication password for a routing domain\n"
- "Routing domain password\n" )
+ "Routing domain password\n")
{
struct isis_area *area;
int len;
area = vty->index;
- if (!area) {
- vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ if (!area)
+ {
+ vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
len = strlen (argv[0]);
- if (len > 254) {
- vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- area->domain_passwd.len = (u_char)len;
+ if (len > 254)
+ {
+ vty_out (vty, "Too long area password (>254)%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ area->domain_passwd.len = (u_char) len;
area->domain_passwd.type = ISIS_PASSWD_TYPE_CLEARTXT;
strncpy (area->domain_passwd.passwd, argv[0], 255);
-
+
return CMD_SUCCESS;
}
-
DEFUN (no_domain_passwd,
no_domain_passwd_cmd,
"no domain-password WORD",
@@ -1123,16 +1110,17 @@ DEFUN (no_domain_passwd,
"Set the authentication password for a routing domain\n")
{
struct isis_area *area;
-
+
area = vty->index;
- if (!area) {
- vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
+ if (!area)
+ {
+ vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
memset (&area->domain_passwd, 0, sizeof (struct isis_passwd));
-
+
return CMD_SUCCESS;
}
@@ -1149,19 +1137,21 @@ DEFUN (is_type,
area = vty->index;
- if (!area) {
- vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ if (!area)
+ {
+ vty_out (vty, "Cant find IS-IS instance%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
- type = string2circuit_t (argv[0]);
- if (!type) {
- vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
- return CMD_SUCCESS;
- }
+ type = string2circuit_t (argv[0]);
+ if (!type)
+ {
+ vty_out (vty, "Unknown IS level %s", VTY_NEWLINE);
+ return CMD_SUCCESS;
+ }
isis_event_system_type_change (area, type);
-
+
return CMD_SUCCESS;
}
@@ -1174,18 +1164,17 @@ DEFUN (no_is_type,
"Act as both a station router and an area router\n"
"Act as an area router only\n")
{
-
struct isis_area *area;
int type;
area = vty->index;
assert (area);
-
+
/*
* Put the is-type back to default. Which is level-1-2 on first
* circuit for the area level-1 for the rest
*/
- if (getdata (listhead (isis->area_list)) == area )
+ if (getdata (listhead (isis->area_list)) == area)
type = IS_LEVEL_1_AND_2;
else
type = IS_LEVEL_1;
@@ -1206,7 +1195,7 @@ DEFUN (lsp_gen_interval,
area = vty->index;
assert (area);
-
+
interval = atoi (argv[0]);
area->lsp_gen_interval[0] = interval;
area->lsp_gen_interval[1] = interval;
@@ -1218,14 +1207,13 @@ DEFUN (no_lsp_gen_interval,
no_lsp_gen_interval_cmd,
"no lsp-gen-interval",
NO_STR
- "Minimum interval between regenerating same LSP\n"
- )
+ "Minimum interval between regenerating same LSP\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
-
+
area->lsp_gen_interval[0] = LSP_GEN_INTERVAL_DEFAULT;
area->lsp_gen_interval[1] = LSP_GEN_INTERVAL_DEFAULT;
@@ -1237,23 +1225,21 @@ ALIAS (no_lsp_gen_interval,
"no lsp-gen-interval <1-120>",
NO_STR
"Minimum interval between regenerating same LSP\n"
- "Minimum interval in seconds\n"
- )
+ "Minimum interval in seconds\n")
DEFUN (lsp_gen_interval_l1,
lsp_gen_interval_l1_cmd,
"lsp-gen-interval level-1 <1-120>",
"Minimum interval between regenerating same LSP\n"
"Set interval for level 1 only\n"
- "Minimum interval in seconds\n"
- )
+ "Minimum interval in seconds\n")
{
struct isis_area *area;
uint16_t interval;
area = vty->index;
assert (area);
-
+
interval = atoi (argv[0]);
area->lsp_gen_interval[0] = interval;
@@ -1265,15 +1251,13 @@ DEFUN (no_lsp_gen_interval_l1,
"no lsp-gen-interval level-1",
NO_STR
"Minimum interval between regenerating same LSP\n"
- "Set interval for level 1 only\n"
-
- )
+ "Set interval for level 1 only\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
-
+
area->lsp_gen_interval[0] = LSP_GEN_INTERVAL_DEFAULT;
return CMD_SUCCESS;
@@ -1285,24 +1269,21 @@ ALIAS (no_lsp_gen_interval_l1,
NO_STR
"Minimum interval between regenerating same LSP\n"
"Set interval for level 1 only\n"
- "Minimum interval in seconds\n"
- )
-
+ "Minimum interval in seconds\n")
DEFUN (lsp_gen_interval_l2,
lsp_gen_interval_l2_cmd,
"lsp-gen-interval level-2 <1-120>",
"Minimum interval between regenerating same LSP\n"
"Set interval for level 2 only\n"
- "Minimum interval in seconds\n"
- )
+ "Minimum interval in seconds\n")
{
struct isis_area *area;
int interval;
area = vty->index;
assert (area);
-
+
interval = atoi (argv[0]);
area->lsp_gen_interval[1] = interval;
@@ -1314,15 +1295,14 @@ DEFUN (no_lsp_gen_interval_l2,
"no lsp-gen-interval level-2",
NO_STR
"Minimum interval between regenerating same LSP\n"
- "Set interval for level 2 only\n"
- )
+ "Set interval for level 2 only\n")
{
struct isis_area *area;
int interval;
area = vty->index;
assert (area);
-
+
interval = atoi (argv[0]);
area->lsp_gen_interval[1] = LSP_GEN_INTERVAL_DEFAULT;
@@ -1335,9 +1315,7 @@ ALIAS (no_lsp_gen_interval_l2,
NO_STR
"Minimum interval between regenerating same LSP\n"
"Set interval for level 2 only\n"
- "Minimum interval in seconds\n"
- )
-
+ "Minimum interval in seconds\n")
DEFUN (metric_style,
metric_style_cmd,
@@ -1350,7 +1328,7 @@ DEFUN (metric_style,
area = vty->index;
assert (area);
- if (!strcmp(argv[0],"wide"))
+ if (!strcmp (argv[0], "wide"))
area->newmetric = 1;
else
area->newmetric = 0;
@@ -1371,7 +1349,7 @@ DEFUN (no_metric_style,
area = vty->index;
assert (area);
- if (!strcmp(argv[0],"wide"))
+ if (!strcmp (argv[0], "wide"))
area->newmetric = 0;
else
area->newmetric = 1;
@@ -1383,15 +1361,15 @@ DEFUN (dynamic_hostname,
dynamic_hostname_cmd,
"hostname dynamic",
"Dynamic hostname for IS-IS\n"
- "Dynamic hostname\n")
+ "Dynamic hostname\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
-
+
area->dynhostname = 1;
-
+
return CMD_SUCCESS;
}
@@ -1400,15 +1378,15 @@ DEFUN (no_dynamic_hostname,
"no hostname dynamic",
NO_STR
"Dynamic hostname for IS-IS\n"
- "Dynamic hostname\n")
+ "Dynamic hostname\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
-
+
area->dynhostname = 0;
-
+
return CMD_SUCCESS;
}
@@ -1420,12 +1398,12 @@ DEFUN (spf_interval,
{
struct isis_area *area;
u_int16_t interval;
-
+
area = vty->index;
interval = atoi (argv[0]);
area->min_spf_interval[0] = interval;
area->min_spf_interval[1] = interval;
-
+
return CMD_SUCCESS;
}
@@ -1433,16 +1411,15 @@ DEFUN (no_spf_interval,
no_spf_interval_cmd,
"no spf-interval",
NO_STR
- "Minimum interval between SPF calculations\n"
- )
+ "Minimum interval between SPF calculations\n")
{
struct isis_area *area;
-
+
area = vty->index;
area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
-
+
return CMD_SUCCESS;
}
@@ -1451,8 +1428,7 @@ ALIAS (no_spf_interval,
"no spf-interval <1-120>",
NO_STR
"Minimum interval between SPF calculations\n"
- "Minimum interval between consecutive SPFs in seconds\n"
- )
+ "Minimum interval between consecutive SPFs in seconds\n")
DEFUN (spf_interval_l1,
spf_interval_l1_cmd,
@@ -1463,11 +1439,11 @@ DEFUN (spf_interval_l1,
{
struct isis_area *area;
u_int16_t interval;
-
+
area = vty->index;
interval = atoi (argv[0]);
area->min_spf_interval[0] = interval;
-
+
return CMD_SUCCESS;
}
@@ -1479,11 +1455,11 @@ DEFUN (no_spf_interval_l1,
"Set interval for level 1 only\n")
{
struct isis_area *area;
-
+
area = vty->index;
area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL;
-
+
return CMD_SUCCESS;
}
@@ -1504,11 +1480,11 @@ DEFUN (spf_interval_l2,
{
struct isis_area *area;
u_int16_t interval;
-
+
area = vty->index;
interval = atoi (argv[0]);
area->min_spf_interval[1] = interval;
-
+
return CMD_SUCCESS;
}
@@ -1520,11 +1496,11 @@ DEFUN (no_spf_interval_l2,
"Set interval for level 2 only\n")
{
struct isis_area *area;
-
+
area = vty->index;
area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL;
-
+
return CMD_SUCCESS;
}
@@ -1536,7 +1512,6 @@ ALIAS (no_spf_interval,
"Set interval for level 2 only\n"
"Minimum interval between consecutive SPFs in seconds\n")
-
#ifdef TOPOLOGY_GENERATE
DEFUN (topology_generate_grid,
topology_generate_grid_cmd,
@@ -1558,15 +1533,16 @@ DEFUN (topology_generate_grid,
area = vty->index;
assert (area);
- if (!spgrid_check_params (vty, argc, argv)) {
- if (area->topology)
- list_delete (area->topology);
- area->topology = list_new();
- memcpy(area->top_params,vty->buf,200);
- gen_spgrid_topology (vty, area->topology);
- remove_topology_lsps (area);
- generate_topology_lsps (area);
- }
+ if (!spgrid_check_params (vty, argc, argv))
+ {
+ if (area->topology)
+ list_delete (area->topology);
+ area->topology = list_new ();
+ memcpy (area->top_params, vty->buf, 200);
+ gen_spgrid_topology (vty, area->topology);
+ remove_topology_lsps (area);
+ generate_topology_lsps (area);
+ }
return CMD_SUCCESS;
}
@@ -1582,14 +1558,18 @@ DEFUN (show_isis_topology,
struct listnode *node;
struct listnode *node2;
struct arc *arc;
- LIST_LOOP (isis->area_list, area, node) {
- if (area->topology) {
- vty_out (vty, "Topology for isis area:%s%s",area->area_tag, VTY_NEWLINE);
- LIST_LOOP (area->topology, arc, node2) {
- vty_out (vty, "a %ld %ld %ld%s",arc->from_node, arc->to_node,
- arc->distance, VTY_NEWLINE);
+ LIST_LOOP (isis->area_list, area, node)
+ {
+ if (area->topology)
+ {
+ vty_out (vty, "Topology for isis area:%s%s", area->area_tag,
+ VTY_NEWLINE);
+ LIST_LOOP (area->topology, arc, node2)
+ {
+ vty_out (vty, "a %ld %ld %ld%s", arc->from_node, arc->to_node,
+ arc->distance, VTY_NEWLINE);
+ }
}
- }
}
return CMD_SUCCESS;
}
@@ -1597,13 +1577,13 @@ DEFUN (show_isis_topology,
/*
* 'topology base-is' command
*/
-DEFUN (topology_baseis ,
+DEFUN (topology_baseis,
topology_baseis_cmd,
"topology base-is WORD",
"Topology for IS-IS\n"
"Topology for IS-IS\n"
"A Network IS Base for this topology"
- "XX.XXXX.XXXX.XX Network entity title (NET)\n" )
+ "XX.XXXX.XXXX.XX Network entity title (NET)\n")
{
struct isis_area *area;
u_char buff[ISIS_SYS_ID_LEN];
@@ -1611,10 +1591,11 @@ DEFUN (topology_baseis ,
area = vty->index;
assert (area);
- if (sysid2buff (buff, argv[0])) {
- sysid2buff (area->topology_baseis, argv[0]);
- }
-
+ if (sysid2buff (buff, argv[0]))
+ {
+ sysid2buff (area->topology_baseis, argv[0]);
+ }
+
return CMD_SUCCESS;
}
@@ -1626,14 +1607,14 @@ DEFUN (no_topology_baseis,
"no topology base-is WORD",
NO_STR
"A Network Entity Title for this process (OSI only)"
- "XX.XXXX. ... .XXX.XX Network entity title (NET)\n" )
+ "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
- memcpy(area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
+ memcpy (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS, ISIS_SYS_ID_LEN);
return CMD_SUCCESS;
}
@@ -1643,41 +1624,41 @@ DEFUN (lsp_lifetime,
lsp_lifetime_cmd,
"lsp-lifetime <380-65535>",
"Maximum LSP lifetime\n"
- "LSP lifetime in seconds\n"
- )
+ "LSP lifetime in seconds\n")
{
struct isis_area *area;
uint16_t interval;
area = vty->index;
assert (area);
-
+
interval = atoi (argv[0]);
- if (interval < ISIS_MIN_LSP_LIFETIME) {
- vty_out (vty, "LSP lifetime (%us) below %us%s",
- interval,
- ISIS_MIN_LSP_LIFETIME,
- VTY_NEWLINE);
+ if (interval < ISIS_MIN_LSP_LIFETIME)
+ {
+ vty_out (vty, "LSP lifetime (%us) below %us%s",
+ interval, ISIS_MIN_LSP_LIFETIME, VTY_NEWLINE);
- return CMD_WARNING;
- }
+ return CMD_WARNING;
+ }
area->max_lsp_lifetime[0] = interval;
area->max_lsp_lifetime[1] = interval;
- area->lsp_refresh[0] = interval-300;
- area->lsp_refresh[1] = interval-300;
+ area->lsp_refresh[0] = interval - 300;
+ area->lsp_refresh[1] = interval - 300;
- if (area->t_lsp_refresh[0]) {
- thread_cancel (area->t_lsp_refresh[0]);
- thread_execute (master, lsp_refresh_l1, area, 0);
- }
+ if (area->t_lsp_refresh[0])
+ {
+ thread_cancel (area->t_lsp_refresh[0]);
+ thread_execute (master, lsp_refresh_l1, area, 0);
+ }
- if (area->t_lsp_refresh[1]) {
- thread_cancel (area->t_lsp_refresh[1]);
- thread_execute (master, lsp_refresh_l2, area, 0);
- }
+ if (area->t_lsp_refresh[1])
+ {
+ thread_cancel (area->t_lsp_refresh[1]);
+ thread_execute (master, lsp_refresh_l2, area, 0);
+ }
return CMD_SUCCESS;
@@ -1687,18 +1668,17 @@ DEFUN (no_lsp_lifetime,
no_lsp_lifetime_cmd,
"no lsp-lifetime",
NO_STR
- "LSP lifetime in seconds\n"
- )
+ "LSP lifetime in seconds\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
-
- area->max_lsp_lifetime[0] = MAX_AGE; /* 1200s */
- area->max_lsp_lifetime[1] = MAX_AGE; /* 1200s */
- area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900s */
- area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900s */
+
+ area->max_lsp_lifetime[0] = MAX_AGE; /* 1200s */
+ area->max_lsp_lifetime[1] = MAX_AGE; /* 1200s */
+ area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900s */
+ area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900s */
return CMD_SUCCESS;
}
@@ -1708,36 +1688,33 @@ ALIAS (no_lsp_lifetime,
"no lsp-lifetime <380-65535>",
NO_STR
"Maximum LSP lifetime\n"
- "LSP lifetime in seconds\n"
- )
+ "LSP lifetime in seconds\n")
DEFUN (lsp_lifetime_l1,
lsp_lifetime_l1_cmd,
"lsp-lifetime level-1 <380-65535>",
"Maximum LSP lifetime for Level 1 only\n"
- "LSP lifetime for Level 1 only in seconds\n"
- )
+ "LSP lifetime for Level 1 only in seconds\n")
{
struct isis_area *area;
uint16_t interval;
area = vty->index;
assert (area);
-
+
interval = atoi (argv[0]);
- if (interval < ISIS_MIN_LSP_LIFETIME) {
- vty_out (vty, "Level-1 LSP lifetime (%us) below %us%s",
- interval,
- ISIS_MIN_LSP_LIFETIME,
- VTY_NEWLINE);
+ if (interval < ISIS_MIN_LSP_LIFETIME)
+ {
+ vty_out (vty, "Level-1 LSP lifetime (%us) below %us%s",
+ interval, ISIS_MIN_LSP_LIFETIME, VTY_NEWLINE);
- return CMD_WARNING;
- }
+ return CMD_WARNING;
+ }
area->max_lsp_lifetime[0] = interval;
- area->lsp_refresh[0] = interval-300;
+ area->lsp_refresh[0] = interval - 300;
return CMD_SUCCESS;
}
@@ -1746,16 +1723,15 @@ DEFUN (no_lsp_lifetime_l1,
no_lsp_lifetime_l1_cmd,
"no lsp-lifetime level-1",
NO_STR
- "LSP lifetime for Level 1 only in seconds\n"
- )
+ "LSP lifetime for Level 1 only in seconds\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
-
- area->max_lsp_lifetime[0] = MAX_AGE; /* 1200s */
- area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900s */
+
+ area->max_lsp_lifetime[0] = MAX_AGE; /* 1200s */
+ area->lsp_refresh[0] = MAX_LSP_GEN_INTERVAL; /* 900s */
return CMD_SUCCESS;
}
@@ -1765,33 +1741,29 @@ ALIAS (no_lsp_lifetime_l1,
"no lsp-lifetime level-1 <380-65535>",
NO_STR
"Maximum LSP lifetime for Level 1 only\n"
- "LSP lifetime for Level 1 only in seconds\n"
- )
+ "LSP lifetime for Level 1 only in seconds\n")
DEFUN (lsp_lifetime_l2,
lsp_lifetime_l2_cmd,
"lsp-lifetime level-2 <380-65535>",
"Maximum LSP lifetime for Level 2 only\n"
- "LSP lifetime for Level 2 only in seconds\n"
- )
+ "LSP lifetime for Level 2 only in seconds\n")
{
struct isis_area *area;
uint16_t interval;
area = vty->index;
assert (area);
-
- interval = atoi (argv[0]);
- if (interval < ISIS_MIN_LSP_LIFETIME) {
- vty_out (vty, "Level-2 LSP lifetime (%us) below %us%s",
- interval,
- ISIS_MIN_LSP_LIFETIME,
- VTY_NEWLINE);
+ interval = atoi (argv[0]);
- return CMD_WARNING;
- }
+ if (interval < ISIS_MIN_LSP_LIFETIME)
+ {
+ vty_out (vty, "Level-2 LSP lifetime (%us) below %us%s",
+ interval, ISIS_MIN_LSP_LIFETIME, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
area->max_lsp_lifetime[1] = interval;
area->lsp_refresh[1] = interval - 300;
@@ -1803,16 +1775,15 @@ DEFUN (no_lsp_lifetime_l2,
no_lsp_lifetime_l2_cmd,
"no lsp-lifetime level-2",
NO_STR
- "LSP lifetime for Level 2 only in seconds\n"
- )
+ "LSP lifetime for Level 2 only in seconds\n")
{
struct isis_area *area;
area = vty->index;
assert (area);
-
- area->max_lsp_lifetime[1] = MAX_AGE; /* 1200s */
- area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900s */
+
+ area->max_lsp_lifetime[1] = MAX_AGE; /* 1200s */
+ area->lsp_refresh[1] = MAX_LSP_GEN_INTERVAL; /* 900s */
return CMD_SUCCESS;
}
@@ -1822,127 +1793,149 @@ ALIAS (no_lsp_lifetime_l2,
"no lsp-lifetime level-2 <380-65535>",
NO_STR
"Maximum LSP lifetime for Level 2 only\n"
- "LSP lifetime for Level 2 only in seconds\n"
- )
-
-
-
+ "LSP lifetime for Level 2 only in seconds\n")
/* IS-IS configuration write function */
int
isis_config_write (struct vty *vty)
{
int write = 0;
-
- if (isis != NULL) {
- struct isis_area *area;
- struct listnode *node;
- struct listnode *node2;
-
- LIST_LOOP (isis->area_list, area, node) {
- /* ISIS - Area name */
- vty_out (vty, "router isis %s%s",area->area_tag, VTY_NEWLINE);
- write++;
- /* ISIS - Net */
- if (listcount (area->area_addrs) > 0) {
- struct area_addr *area_addr;
- LIST_LOOP (area->area_addrs, area_addr, node2) {
- vty_out (vty, " net %s%s",
- isonet_print (area_addr->area_addr,
- area_addr->addr_len + ISIS_SYS_ID_LEN + 1),
- VTY_NEWLINE);
- write ++;
- }
- }
- /* ISIS - Dynamic hostname - Defaults to true so only display if false*/
- if (!area->dynhostname) {
- vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
- write ++;
- }
- /* ISIS - Metric-Style - when true displays wide */
- if (area->newmetric) {
- vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
- write ++;
- }
- /* ISIS - Area is-type (level-1-2 is default) */
- if (area->is_type == IS_LEVEL_1) {
- vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
- write ++;
- } else {if (area->is_type == IS_LEVEL_2) {
- vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
- write ++;
- }}
- /* ISIS - Lsp generation interval */
- if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1]) {
- if (area->lsp_gen_interval[0] != LSP_GEN_INTERVAL_DEFAULT) {
- vty_out (vty, " lsp-gen-interval %d%s", area->lsp_gen_interval[0],
- VTY_NEWLINE);
- write ++;
- }} else {
- if (area->lsp_gen_interval[0] != LSP_GEN_INTERVAL_DEFAULT) {
- vty_out (vty, " lsp-gen-interval level-1 %d%s",
- area->lsp_gen_interval[0], VTY_NEWLINE);
- write ++;
- }
- if (area->lsp_gen_interval[1] != LSP_GEN_INTERVAL_DEFAULT) {
- vty_out (vty, " lsp-gen-interval level-2 %d%s",
- area->lsp_gen_interval[1], VTY_NEWLINE);
- write ++;
- }
- }
- /* ISIS - LSP lifetime */
- if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1]) {
- if (area->max_lsp_lifetime[0] != MAX_AGE) {
- vty_out (vty, " lsp-lifetime %u%s", area->max_lsp_lifetime[0],
- VTY_NEWLINE);
- write ++;
- }} else {
- if (area->max_lsp_lifetime[0] != MAX_AGE) {
- vty_out (vty, " lsp-lifetime level-1 %u%s", area->max_lsp_lifetime[0],
- VTY_NEWLINE);
- write ++;
- }
- if (area->max_lsp_lifetime[1] != MAX_AGE) {
- vty_out (vty, " lsp-lifetime level-2 %u%s", area->max_lsp_lifetime[1],
- VTY_NEWLINE);
- write ++;
- }
- }
- #ifdef TOPOLOGY_GENERATE
- /* seems we save the whole command line here */
- if (area->top_params) {
- vty_out (vty, " %s%s",area->top_params, VTY_NEWLINE);
- write ++;
- }
- if (memcmp(area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
- ISIS_SYS_ID_LEN)) {
- vty_out (vty, " topology base_is %s%s",
- sysid_print (area->topology_baseis), VTY_NEWLINE);
- write ++;
- }
+ if (isis != NULL)
+ {
+ struct isis_area *area;
+ struct listnode *node;
+ struct listnode *node2;
+
+ LIST_LOOP (isis->area_list, area, node)
+ {
+ /* ISIS - Area name */
+ vty_out (vty, "router isis %s%s", area->area_tag, VTY_NEWLINE);
+ write++;
+ /* ISIS - Net */
+ if (listcount (area->area_addrs) > 0)
+ {
+ struct area_addr *area_addr;
+ LIST_LOOP (area->area_addrs, area_addr, node2)
+ {
+ vty_out (vty, " net %s%s",
+ isonet_print (area_addr->area_addr,
+ area_addr->addr_len + ISIS_SYS_ID_LEN +
+ 1), VTY_NEWLINE);
+ write++;
+ }
+ }
+ /* ISIS - Dynamic hostname - Defaults to true so only display if false */
+ if (!area->dynhostname)
+ {
+ vty_out (vty, " no hostname dynamic%s", VTY_NEWLINE);
+ write++;
+ }
+ /* ISIS - Metric-Style - when true displays wide */
+ if (area->newmetric)
+ {
+ vty_out (vty, " metric-style wide%s", VTY_NEWLINE);
+ write++;
+ }
+ /* ISIS - Area is-type (level-1-2 is default) */
+ if (area->is_type == IS_LEVEL_1)
+ {
+ vty_out (vty, " is-type level-1%s", VTY_NEWLINE);
+ write++;
+ }
+ else
+ {
+ if (area->is_type == IS_LEVEL_2)
+ {
+ vty_out (vty, " is-type level-2-only%s", VTY_NEWLINE);
+ write++;
+ }
+ }
+ /* ISIS - Lsp generation interval */
+ if (area->lsp_gen_interval[0] == area->lsp_gen_interval[1])
+ {
+ if (area->lsp_gen_interval[0] != LSP_GEN_INTERVAL_DEFAULT)
+ {
+ vty_out (vty, " lsp-gen-interval %d%s",
+ area->lsp_gen_interval[0], VTY_NEWLINE);
+ write++;
+ }
+ }
+ else
+ {
+ if (area->lsp_gen_interval[0] != LSP_GEN_INTERVAL_DEFAULT)
+ {
+ vty_out (vty, " lsp-gen-interval level-1 %d%s",
+ area->lsp_gen_interval[0], VTY_NEWLINE);
+ write++;
+ }
+ if (area->lsp_gen_interval[1] != LSP_GEN_INTERVAL_DEFAULT)
+ {
+ vty_out (vty, " lsp-gen-interval level-2 %d%s",
+ area->lsp_gen_interval[1], VTY_NEWLINE);
+ write++;
+ }
+ }
+ /* ISIS - LSP lifetime */
+ if (area->max_lsp_lifetime[0] == area->max_lsp_lifetime[1])
+ {
+ if (area->max_lsp_lifetime[0] != MAX_AGE)
+ {
+ vty_out (vty, " lsp-lifetime %u%s", area->max_lsp_lifetime[0],
+ VTY_NEWLINE);
+ write++;
+ }
+ }
+ else
+ {
+ if (area->max_lsp_lifetime[0] != MAX_AGE)
+ {
+ vty_out (vty, " lsp-lifetime level-1 %u%s",
+ area->max_lsp_lifetime[0], VTY_NEWLINE);
+ write++;
+ }
+ if (area->max_lsp_lifetime[1] != MAX_AGE)
+ {
+ vty_out (vty, " lsp-lifetime level-2 %u%s",
+ area->max_lsp_lifetime[1], VTY_NEWLINE);
+ write++;
+ }
+ }
+#ifdef TOPOLOGY_GENERATE
+ /* seems we save the whole command line here */
+ if (area->top_params)
+ {
+ vty_out (vty, " %s%s", area->top_params, VTY_NEWLINE);
+ write++;
+ }
+
+ if (memcmp (area->topology_baseis, DEFAULT_TOPOLOGY_BASEIS,
+ ISIS_SYS_ID_LEN))
+ {
+ vty_out (vty, " topology base_is %s%s",
+ sysid_print (area->topology_baseis), VTY_NEWLINE);
+ write++;
+ }
- #endif /* TOPOLOGY_GENERATE */
+#endif /* TOPOLOGY_GENERATE */
+ }
}
- }
-
+
return write;
}
-struct cmd_node isis_node =
-{
+struct cmd_node isis_node = {
ISIS_NODE,
"%s(config-router)# ",
1
};
-void
+void
isis_init ()
{
-
/* Install IS-IS top node */
install_node (&isis_node, isis_config_write);
-
+
install_element (VIEW_NODE, &show_clns_neighbors_cmd);
install_element (VIEW_NODE, &show_isis_neighbors_cmd);
install_element (VIEW_NODE, &show_clns_neighbors_detail_cmd);
@@ -1962,7 +1955,7 @@ isis_init ()
install_element (ENABLE_NODE, &show_database_detail_cmd);
install_element (ENABLE_NODE, &show_debugging_cmd);
- install_node(&debug_node, config_write_debug);
+ install_node (&debug_node, config_write_debug);
install_element (ENABLE_NODE, &debug_isis_adj_cmd);
install_element (ENABLE_NODE, &no_debug_isis_adj_cmd);
@@ -2046,7 +2039,7 @@ isis_init ()
install_element (ISIS_NODE, &spf_interval_l2_cmd);
install_element (ISIS_NODE, &no_spf_interval_l2_cmd);
install_element (ISIS_NODE, &no_spf_interval_l2_arg_cmd);
-
+
install_element (ISIS_NODE, &lsp_lifetime_cmd);
install_element (ISIS_NODE, &no_lsp_lifetime_cmd);
install_element (ISIS_NODE, &no_lsp_lifetime_arg_cmd);
@@ -2070,14 +2063,8 @@ isis_init ()
install_element (ENABLE_NODE, &show_isis_topology_cmd);
#endif /* TOPOLOGY_GENERATE */
- isis_new(0);
+ isis_new (0);
isis_circuit_init ();
isis_zebra_init ();
isis_spf_cmds_init ();
}
-
-
-
-
-
-
diff --git a/isisd/isisd.h b/isisd/isisd.h
index 3ca421adc..f1093cc2c 100644
--- a/isisd/isisd.h
+++ b/isisd/isisd.h
@@ -32,7 +32,8 @@
/* If you want topology stuff compiled in */
/* #define TOPOLOGY_GENERATE */
-struct rmap{
+struct rmap
+{
char *name;
struct route_map *map;
};
@@ -41,58 +42,62 @@ struct isis
{
u_long process_id;
int sysid_set;
- u_char sysid[ISIS_SYS_ID_LEN]; /* SystemID for this IS */
- struct list *area_list; /* list of IS-IS areas */
+ u_char sysid[ISIS_SYS_ID_LEN]; /* SystemID for this IS */
+ struct list *area_list; /* list of IS-IS areas */
struct list *init_circ_list;
- struct list *nexthops; /* IPv4 next hops from this IS */
+ struct list *nexthops; /* IPv4 next hops from this IS */
#ifdef HAVE_IPV6
- struct list *nexthops6; /* IPv6 next hops from this IS */
-#endif /* HAVE_IPV6 */
- u_char max_area_addrs; /* maximumAreaAdresses */
- struct area_addr *man_area_addrs; /* manualAreaAddresses */
- u_int32_t debugs; /* bitmap for debug */
- time_t uptime; /* when did we start */
-
+ struct list *nexthops6; /* IPv6 next hops from this IS */
+#endif /* HAVE_IPV6 */
+ u_char max_area_addrs; /* maximumAreaAdresses */
+ struct area_addr *man_area_addrs; /* manualAreaAddresses */
+ u_int32_t debugs; /* bitmap for debug */
+ time_t uptime; /* when did we start */
+
/* Redistributed external information. */
struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
/* Redistribute metric info. */
- struct {
- int type; /* Internal or External */
- int value; /* metric value */
- } dmetric [ZEBRA_ROUTE_MAX + 1];
+ struct
+ {
+ int type; /* Internal or External */
+ int value; /* metric value */
+ } dmetric[ZEBRA_ROUTE_MAX + 1];
- struct {
+ struct
+ {
char *name;
struct route_map *map;
- } rmap [ZEBRA_ROUTE_MAX + 1];
+ } rmap[ZEBRA_ROUTE_MAX + 1];
#ifdef HAVE_IPV6
- struct {
- struct {
+ struct
+ {
+ struct
+ {
char *name;
struct route_map *map;
- } rmap [ZEBRA_ROUTE_MAX + 1];
+ } rmap[ZEBRA_ROUTE_MAX + 1];
} inet6_afmode;
#endif
};
-struct isis_area
+struct isis_area
{
- struct isis *isis; /* back pointer */
- dict_t *lspdb[ISIS_LEVELS]; /* link-state dbs */
- struct isis_spftree *spftree[ISIS_LEVELS]; /* The v4 SPTs */
- struct route_table *route_table; /* IPv4 routes */
+ struct isis *isis; /* back pointer */
+ dict_t *lspdb[ISIS_LEVELS]; /* link-state dbs */
+ struct isis_spftree *spftree[ISIS_LEVELS]; /* The v4 SPTs */
+ struct route_table *route_table; /* IPv4 routes */
#ifdef HAVE_IPV6
- struct isis_spftree *spftree6[ISIS_LEVELS]; /* The v4 SPTs */
- struct route_table *route_table6; /* IPv6 routes */
+ struct isis_spftree *spftree6[ISIS_LEVELS]; /* The v4 SPTs */
+ struct route_table *route_table6; /* IPv6 routes */
#endif
int min_bcast_mtu;
- struct list *circuit_list; /* IS-IS circuits */
- struct flags flags;
- struct thread *t_tick; /* LSP walker */
- struct thread *t_remove_aged;
+ struct list *circuit_list; /* IS-IS circuits */
+ struct flags flags;
+ struct thread *t_tick; /* LSP walker */
+ struct thread *t_remove_aged;
int lsp_regenerate_pending[ISIS_LEVELS];
struct thread *t_lsp_refresh[ISIS_LEVELS];
-
+
/*
* Configurables
*/
@@ -101,34 +106,34 @@ struct isis_area
/* do we support dynamic hostnames? */
char dynhostname;
/* do we support new style metrics? */
- char newmetric;
+ char newmetric;
/* identifies the routing instance */
- char *area_tag;
+ char *area_tag;
/* area addresses for this area */
- struct list *area_addrs;
- u_int16_t max_lsp_lifetime[ISIS_LEVELS];
- char is_type; /* level-1 level-1-2 or level-2-only */
+ struct list *area_addrs;
+ u_int16_t max_lsp_lifetime[ISIS_LEVELS];
+ char is_type; /* level-1 level-1-2 or level-2-only */
u_int16_t lsp_refresh[ISIS_LEVELS];
/* minimum time allowed before lsp retransmission */
u_int16_t lsp_gen_interval[ISIS_LEVELS];
/* min interval between between consequtive SPFs */
- u_int16_t min_spf_interval[ISIS_LEVELS];
+ u_int16_t min_spf_interval[ISIS_LEVELS];
/* the percentage of LSP mtu size used, before generating a new frag */
- int lsp_frag_threshold;
+ int lsp_frag_threshold;
int ip_circuits;
#ifdef HAVE_IPV6
int ipv6_circuits;
-#endif /* HAVE_IPV6 */
+#endif /* HAVE_IPV6 */
/* Counters */
u_int32_t circuit_state_changes;
#ifdef TOPOLOGY_GENERATE
- struct list *topology;
- char topology_baseis[ISIS_SYS_ID_LEN]; /* is for the first is emulated */
- char top_params[200]; /* FIXME: what is reasonable? */
-#endif /* TOPOLOGY_GENERATE */
+ struct list *topology;
+ char topology_baseis[ISIS_SYS_ID_LEN]; /* is for the first is emulated */
+ char top_params[200]; /* FIXME: what is reasonable? */
+#endif /* TOPOLOGY_GENERATE */
};
-void isis_init(void);
+void isis_init (void);
struct isis_area *isis_area_lookup (char *);
#define DEBUG_ADJ_PACKETS (1<<0)
diff --git a/isisd/iso_checksum.c b/isisd/iso_checksum.c
index d0bb8a75d..e65f6ef67 100644
--- a/isisd/iso_checksum.c
+++ b/isisd/iso_checksum.c
@@ -46,8 +46,8 @@
*/
int
-iso_csum_verify (u_char *buffer, int len, uint16_t *csum)
-{
+iso_csum_verify (u_char * buffer, int len, uint16_t * csum)
+{
u_int8_t *p;
u_int32_t c0;
u_int32_t c1;
@@ -70,28 +70,28 @@ iso_csum_verify (u_char *buffer, int len, uint16_t *csum)
*/
if (c0 == 0 || c1 == 0)
return 1;
-
+
/*
* Otherwise initialize to zero and calculate...
*/
c0 = 0;
c1 = 0;
- for (i = 0; i < len; i++) {
- c0 = c0 + *(p++);
- c1 += c0;
- }
+ for (i = 0; i < len; i++)
+ {
+ c0 = c0 + *(p++);
+ c1 += c0;
+ }
c0 = c0 % 255;
c1 = c1 % 255;
-
- if ( c0 == 0 && c1 == 0)
+
+ if (c0 == 0 && c1 == 0)
return 0;
return 1;
}
-
/*
* Creates the checksum. *csum points to the position of the checksum in the
* PDU.
@@ -102,7 +102,7 @@ iso_csum_verify (u_char *buffer, int len, uint16_t *csum)
*/
#define FIXED_CODE
u_int16_t
-iso_csum_create (u_char *buffer, int len, u_int16_t n)
+iso_csum_create (u_char * buffer, int len, u_int16_t n)
{
u_int8_t *p;
@@ -112,7 +112,7 @@ iso_csum_create (u_char *buffer, int len, u_int16_t n)
u_int32_t c0;
u_int32_t c1;
u_int16_t checksum;
- u_int16_t *csum;
+ u_int16_t *csum;
int i;
checksum = 0;
@@ -120,40 +120,46 @@ iso_csum_create (u_char *buffer, int len, u_int16_t n)
/*
* Zero the csum in the packet.
*/
- csum = (u_int16_t*)(buffer + n);
+ csum = (u_int16_t *) (buffer + n);
*(csum) = checksum;
/* for the limitation of our implementation */
- if (len > 5000) {
- return 0;
- }
+ if (len > 5000)
+ {
+ return 0;
+ }
p = buffer;
c0 = 0;
c1 = 0;
- for (i = 0; i < len; i++) {
- c0 = c0 + *(p++);
- c1 += c0;
- }
+ for (i = 0; i < len; i++)
+ {
+ c0 = c0 + *(p++);
+ c1 += c0;
+ }
c0 = c0 % 255;
c1 = c1 % 255;
- mul = (len - n)*(c0);
-
+ mul = (len - n) * (c0);
+
#ifdef FIXED_CODE
x = mul - c0 - c1;
y = c1 - mul - 1;
- if ( y >= 0 ) y++;
- if ( x < 0 ) x--;
+ if (y >= 0)
+ y++;
+ if (x < 0)
+ x--;
x %= 255;
y %= 255;
- if (x == 0) x = 255;
- if (y == 0) y = 255;
+ if (x == 0)
+ x = 255;
+ if (y == 0)
+ y = 255;
x &= 0x00FF;
@@ -166,12 +172,14 @@ iso_csum_create (u_char *buffer, int len, u_int16_t n)
y = c1 - mul - 1;
y %= 255;
- if (x == 0) x = 255;
- if (y == 0) y = 255;
+ if (x == 0)
+ x = 255;
+ if (y == 0)
+ y = 255;
checksum = ((y << 8) | x);
#endif
-
+
/*
* Now we write this to the packet
*/
@@ -181,12 +189,8 @@ iso_csum_create (u_char *buffer, int len, u_int16_t n)
return checksum;
}
-
int
-iso_csum_modify (u_char *buffer, int len, uint16_t *csum)
+iso_csum_modify (u_char * buffer, int len, uint16_t * csum)
{
-
return 0;
}
-
-
diff --git a/isisd/iso_checksum.h b/isisd/iso_checksum.h
index cf600a86e..ba0d1983a 100644
--- a/isisd/iso_checksum.h
+++ b/isisd/iso_checksum.h
@@ -23,7 +23,7 @@
#ifndef _ZEBRA_ISO_CSUM_H
#define _ZEBRA_ISO_CSUM_H
-int iso_csum_verify (u_char *buffer, int len, uint16_t *csum);
-u_int16_t iso_csum_create (u_char *buffer, int len, u_int16_t n);
+int iso_csum_verify (u_char * buffer, int len, uint16_t * csum);
+u_int16_t iso_csum_create (u_char * buffer, int len, u_int16_t n);
#endif /* _ZEBRA_ISO_CSUM_H */