0xFFFFFF04 "no-peer"
For other values, "AS:VAL" format is used. */
-static void set_community_string(struct community *com, bool make_json)
+static void set_community_string(struct community *com, bool make_json,
+ bool translate_alias)
{
int i;
char *str;
val = comval & 0xFFFF;
char buf[32];
snprintf(buf, sizeof(buf), "%u:%d", as, val);
- const char *com2alias = bgp_community2alias(buf);
+ const char *com2alias =
+ translate_alias ? bgp_community2alias(buf)
+ : buf;
strlcat(str, com2alias, len);
if (make_json) {
/* Make string. */
if (!find->str)
- set_community_string(find, false);
+ set_community_string(find, false, true);
return find;
}
{
struct community *ret;
+ if (!*com)
+ return;
+
if ((*com)->refcnt)
(*com)->refcnt--;
return new;
}
-/* Retrun string representation of communities attribute. */
-char *community_str(struct community *com, bool make_json)
+/* Return string representation of communities attribute. */
+char *community_str(struct community *com, bool make_json, bool translate_alias)
{
if (!com)
return NULL;
XFREE(MTYPE_COMMUNITY_STR, com->str);
if (!com->str)
- set_community_string(com, make_json);
+ set_community_string(com, make_json, translate_alias);
return com->str;
}
return false;
}
-/* If two aspath have same value then return 1 else return 0. This
- function is used by hash package. */
bool community_cmp(const struct community *com1, const struct community *com2)
{
if (com1 == NULL && com2 == NULL)
"BGP Community Hash");
}
+static void community_hash_free(void *data)
+{
+ struct community *com = data;
+
+ community_free(&com);
+}
+
void community_finish(void)
{
+ hash_clean(comhash, community_hash_free);
hash_free(comhash);
comhash = NULL;
}
return hash_lookup(aggregate->community_hash, community);
}
-static void *bgp_aggr_communty_hash_alloc(void *p)
+static void *bgp_aggr_community_hash_alloc(void *p)
{
struct community *ref = (struct community *)p;
struct community *community = NULL;
/* Insert community into hash.
*/
aggr_community = hash_get(aggregate->community_hash, community,
- bgp_aggr_communty_hash_alloc);
+ bgp_aggr_community_hash_alloc);
}
/* Increment reference counter.