summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog5
-rw-r--r--bgpd/bgp_attr.c23
-rw-r--r--bgpd/bgp_attr.h3
3 files changed, 16 insertions, 15 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 2267e0fa..d5822fac 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 b30c86ae..28f01609 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -453,6 +453,7 @@ bgp_attr_intern (struct attr *attr)
return find;
}
+
/* Make network statement's attribute. */
struct attr *
bgp_attr_default_set (struct attr *attr, u_char origin)
@@ -463,14 +464,16 @@ bgp_attr_default_set (struct attr *attr, u_char 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->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 @@ bgp_attr_default_intern (u_char origin)
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 @@ bgp_attr_aggregate_intern (struct bgp *bgp, u_char origin,
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 124c450e..0734bc27 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -32,6 +32,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#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 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
/* 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
{