[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/ChangeLog b/bgpd/ChangeLog
index 2267e0f..d5822fa 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -11,6 +11,11 @@
transit_hash_cmp, attrhash_key_make, attrhash_cmp,
bgp_attr_hash_alloc) conforms to quagga hash API. Defines
_hash_[alloc|key|cmp] with void * arguments as defined by the API.
+ * 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.
2007-04-15 Sebastien Tandel <sebastien@tandel.be>
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);
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index 124c450..0734bc2 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -32,6 +32,7 @@
#define BGP_MED_MAX UINT32_MAX
+
/* BGP Attribute type range. */
#define BGP_ATTR_TYPE_RANGE 256
#define BGP_ATTR_BITMAP_SIZE (BGP_ATTR_TYPE_RANGE / BITMAP_NBBY)
@@ -45,6 +46,8 @@
/* BGP attribute header must bigger than 2. */
#define BGP_ATTR_MIN_LEN 2 /* Attribute flag and type. */
+#define BGP_ATTR_DEFAULT_WEIGHT 32768
+
/* BGP attribute structure. */
struct attr
{