[bgpd] Use defines for default weight

2007-04-22 Sebastien Tandel <sebastien@tandel.be>

	* bgp_attr.h : Definition of BGP_ATTR_DEFAULT_WEIGHT.
	* bgp_attr.c : (bgp_attr_default_intern) now uses
	  bgp_attr_default_set instead of duplicating the same code.
	  (general) Use of BGP_ATTR_DEFAULT_WEIGHT. Replace two 16 by
	  IPV6_MAX_BYTELEN.
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index b30c86a..28f0160 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -453,6 +453,7 @@
   return find;
 }
 
+
 /* Make network statement's attribute. */
 struct attr *
 bgp_attr_default_set (struct attr *attr, u_char origin)
@@ -463,14 +464,16 @@
   attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);
   attr->aspath = aspath_empty ();
   attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
-  attr->weight = 32768;
+  attr->weight = BGP_ATTR_DEFAULT_WEIGHT;
   attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
 #ifdef HAVE_IPV6
-  attr->mp_nexthop_len = 16;
+  attr->mp_nexthop_len = IPV6_MAX_BYTELEN;
 #endif
+
   return attr;
 }
 
+
 /* Make network statement's attribute. */
 struct attr *
 bgp_attr_default_intern (u_char origin)
@@ -478,17 +481,7 @@
   struct attr attr;
   struct attr *new;
 
-  memset (&attr, 0, sizeof (struct attr));
-
-  attr.origin = origin;
-  attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);
-  attr.aspath = aspath_empty ();
-  attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
-  attr.weight = 32768;
-  attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
-#ifdef HAVE_IPV6
-  attr.mp_nexthop_len = 16;
-#endif
+  bgp_attr_default_set(&attr, origin);
 
   new = bgp_attr_intern (&attr);
   aspath_unintern (new->aspath);
@@ -525,9 +518,9 @@
       attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
     }
 
-  attr.weight = 32768;
+  attr.weight = BGP_ATTR_DEFAULT_WEIGHT;
 #ifdef HAVE_IPV6
-  attr.mp_nexthop_len = 16;
+  attr.mp_nexthop_len = IPV6_MAX_BYTELEN;
 #endif
   if (! as_set)
     attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);