once and whether the new value should replace what is existing or
not.
*/
-static bool ecommunity_add_val_internal(struct ecommunity *ecom, const void *eval,
- bool unique, bool overwrite, uint8_t ecom_size)
+static bool ecommunity_add_val_internal(struct ecommunity *ecom,
+ const void *eval,
+ bool unique, bool overwrite,
+ uint8_t ecom_size)
{
int c, ins_idx;
const struct ecommunity_val *eval4 = (struct ecommunity_val *)eval;
- const struct ecommunity_val_ipv6 *eval6 = (struct ecommunity_val_ipv6 *)eval;
+ const struct ecommunity_val_ipv6 *eval6 =
+ (struct ecommunity_val_ipv6 *)eval;
/* When this is fist value, just add it. */
if (ecom->val == NULL) {
if (p[0] == eval4->val[0] &&
p[1] == eval4->val[1]) {
if (overwrite) {
- memcpy(p, eval4->val, ecom_size);
+ memcpy(p, eval4->val,
+ ecom_size);
return true;
}
return false;
if (p[0] == eval6->val[0] &&
p[1] == eval6->val[1]) {
if (overwrite) {
- memcpy(p, eval6->val, ecom_size);
+ memcpy(p, eval6->val,
+ ecom_size);
return true;
}
return false;
}
/* Add a new Extended Communities value to Extended Communities
- Attribute structure. When the value is already exists in the
- structure, we don't add the value. Newly added value is sorted by
- numerical order. When the value is added to the structure return 1
- else return 0. */
+ * Attribute structure. When the value is already exists in the
+ * structure, we don't add the value. Newly added value is sorted by
+ * numerical order. When the value is added to the structure return 1
+ * else return 0.
+ */
bool ecommunity_add_val(struct ecommunity *ecom, struct ecommunity_val *eval,
bool unique, bool overwrite)
{
overwrite, ECOMMUNITY_SIZE);
}
-bool ecommunity_add_val_ipv6(struct ecommunity *ecom, struct ecommunity_val_ipv6 *eval,
- bool unique, bool overwrite)
+bool ecommunity_add_val_ipv6(struct ecommunity *ecom,
+ struct ecommunity_val_ipv6 *eval,
+ bool unique, bool overwrite)
{
return ecommunity_add_val_internal(ecom, (const void *)eval, unique,
overwrite, IPV6_ECOMMUNITY_SIZE);
}
/* This function takes pointer to Extended Communites strucutre then
- create a new Extended Communities structure by uniq and sort each
- Extended Communities value. */
+ * create a new Extended Communities structure by uniq and sort each
+ * Extended Communities value.
+ */
struct ecommunity *ecommunity_uniq_sort(struct ecommunity *ecom)
{
return ecommunity_uniq_sort_internal(ecom, ECOMMUNITY_SIZE);
if (ecom == NULL)
ecom = ecommunity_new();
eval.val[1] = type;
- ecommunity_add_val_internal(ecom, (void *)&eval, false, false,
+ ecommunity_add_val_internal(ecom, (void *)&eval,
+ false, false,
ecom->unit_size);
break;
case ecommunity_token_val6:
}
/* Convert string to extended community attribute.
-
- When type is already known, please specify both str and type. str
- should not include keyword such as "rt" and "soo". Type is
- ECOMMUNITY_ROUTE_TARGET or ECOMMUNITY_SITE_ORIGIN.
- keyword_included should be zero.
-
- For example route-map's "set extcommunity" command case:
-
- "rt 100:1 100:2 100:3" -> str = "100:1 100:2 100:3"
- type = ECOMMUNITY_ROUTE_TARGET
- keyword_included = 0
-
- "soo 100:1" -> str = "100:1"
- type = ECOMMUNITY_SITE_ORIGIN
- keyword_included = 0
-
- When string includes keyword for each extended community value.
- Please specify keyword_included as non-zero value.
-
- For example standard extcommunity-list case:
-
- "rt 100:1 rt 100:2 soo 100:1" -> str = "rt 100:1 rt 100:2 soo 100:1"
- type = 0
- keyword_include = 1
-*/
+ *
+ * When type is already known, please specify both str and type. str
+ * should not include keyword such as "rt" and "soo". Type is
+ * ECOMMUNITY_ROUTE_TARGET or ECOMMUNITY_SITE_ORIGIN.
+ * keyword_included should be zero.
+ *
+ * For example route-map's "set extcommunity" command case:
+ *
+ * "rt 100:1 100:2 100:3" -> str = "100:1 100:2 100:3"
+ * type = ECOMMUNITY_ROUTE_TARGET
+ * keyword_included = 0
+ *
+ * "soo 100:1" -> str = "100:1"
+ * type = ECOMMUNITY_SITE_ORIGIN
+ * keyword_included = 0
+ *
+ * When string includes keyword for each extended community value.
+ * Please specify keyword_included as non-zero value.
+ *
+ * For example standard extcommunity-list case:
+ *
+ * "rt 100:1 rt 100:2 soo 100:1" -> str = "rt 100:1 rt 100:2 soo 100:1"
+ * type = 0
+ * keyword_include = 1
+ */
struct ecommunity *ecommunity_str2com(const char *str, int type,
int keyword_included)
{
eas.as |= (*pnt++);
pnt = ptr_get_be32(pnt, &eas.val);
- len = snprintf(buf, bufsz, "%s%u:%u", prefix, eas.as, eas.val);
+ len = snprintf(buf, bufsz, "%s%u:%u", prefix, eas.as,
+ eas.val);
} else {
/* this is an IPv6 ext community
* first 16 bytes stands for IPv6 addres
eip6.val = (*pnt++ << 8);
eip6.val |= (*pnt++);
- inet_ntop(AF_INET6, &eip6.ip, buf_local, sizeof(buf_local));
+ inet_ntop(AF_INET6, &eip6.ip, buf_local,
+ sizeof(buf_local));
len = snprintf(buf, bufsz, "%s%s:%u", prefix,
buf_local, eip6.val);
}
format,
ecom->unit_size);
snprintf(encbuf, sizeof(encbuf), "%s", buf);
- } else if (sub_type == ECOMMUNITY_FLOWSPEC_REDIRECT_IPV6) {
+ } else if (sub_type ==
+ ECOMMUNITY_FLOWSPEC_REDIRECT_IPV6) {
char buf[64];
memset(buf, 0, sizeof(buf));
ECOMMUNITY_ROUTE_TARGET,
ECOMMUNITY_FORMAT_DISPLAY,
ecom->unit_size);
- snprintf(encbuf, sizeof(encbuf), "FS:redirect VRF %s", buf);
+ snprintf(encbuf, sizeof(encbuf),
+ "FS:redirect VRF %s", buf);
} else if (sub_type == ECOMMUNITY_REDIRECT_VRF) {
char buf[16];
memset(buf, 0, sizeof(buf));
- ecommunity_rt_soo_str(buf, sizeof(buf), (const uint8_t *)pnt,
- type &
- ~ECOMMUNITY_ENCODE_TRANS_EXP,
- ECOMMUNITY_ROUTE_TARGET,
- ECOMMUNITY_FORMAT_DISPLAY);
+ ecommunity_rt_soo_str(buf, sizeof(buf),
+ (const uint8_t *)pnt,
+ type &
+ ~ECOMMUNITY_ENCODE_TRANS_EXP,
+ ECOMMUNITY_ROUTE_TARGET,
+ ECOMMUNITY_FORMAT_DISPLAY);
+ snprintf(encbuf, sizeof(encbuf),
+ "FS:redirect VRF %s", buf);
snprintf(encbuf, sizeof(encbuf),
"FS:redirect VRF %s", buf);
- snprintf(encbuf, sizeof(encbuf), "FS:redirect VRF %s", buf);
} else if (type != ECOMMUNITY_ENCODE_TRANS_EXP)
unk_ecom = 1;
else if (sub_type == ECOMMUNITY_TRAFFIC_ACTION) {
return HASHWALK_CONTINUE;
}
-static int snprintf_bgp_pbr_match_val(char *str, int len, struct bgp_pbr_match_val *mval,
+static int snprintf_bgp_pbr_match_val(char *str, int len,
+ struct bgp_pbr_match_val *mval,
const char *prepend)
{
char *ptr = str;
api_action_redirect_ip->u.zr.duplicate
= ecom_eval->val[7];
continue;
- } else if (p->u.prefix_flowspec.family == AF_INET) {
+ } else if (p->u.prefix_flowspec.family ==
+ AF_INET) {
api_action->action = ACTION_REDIRECT_IP;
api_action->u.zr.redirect_ip_v4.s_addr =
path->attr->nexthop.s_addr;
api_action->u.zr.duplicate =
ecom_eval->val[7];
api_action_redirect_ip = api_action;
- } else if (p->u.prefix_flowspec.family == AF_INET6) {
+ } else if (p->u.prefix_flowspec.family ==
+ AF_INET6) {
api_action->action = ACTION_REDIRECT_IP;
memcpy(&api_action->u
.zr.redirect_ip_v6,
afi);
if (ret != 0)
continue;
- if ((api_action->action == ACTION_TRAFFICRATE) &&
- api->actions[i].u.r.rate == 0)
+ if ((api_action->action == ACTION_TRAFFICRATE)
+ && api->actions[i].u.r.rate == 0)
discard_action_found = true;
}
api->action_num++;
prefix2str(p, buff, 64),
api->dst_prefix_offset);
else
- delta = snprintf(ptr, len, "@dst %s", prefix2str(p, buff, 64));
+ delta = snprintf(ptr, len, "@dst %s",
+ prefix2str(p, buff, 64));
len -= delta;
ptr += delta;
}
if (api->match_packet_length_num)
INCREMENT_DISPLAY(ptr, nb_items, len);
for (i = 0; i < api->match_packet_length_num; i++) {
- delta = snprintf_bgp_pbr_match_val(ptr, len, &api->packet_length[i],
+ delta = snprintf_bgp_pbr_match_val(ptr, len,
+ &api->packet_length[i],
i > 0 ? NULL : "@plen ");
len -= delta;
ptr += delta;
if (api->match_flowlabel_num)
INCREMENT_DISPLAY(ptr, nb_items, len);
for (i = 0; i < api->match_flowlabel_num; i++) {
- delta = snprintf_bgp_pbr_match_val(ptr, len, &api->flow_label[i],
+ delta = snprintf_bgp_pbr_match_val(ptr, len,
+ &api->flow_label[i],
i > 0 ? NULL : "@flowlabel ");
len -= delta;
ptr += delta;
if (bpm->unique == 0) {
bpm->unique = ++bgp_pbr_match_counter_unique;
/* 0 value is forbidden */
- snprintf(bpm->ipset_name, sizeof(bpm->ipset_name), "match%p", bpm);
+ snprintf(bpm->ipset_name, sizeof(bpm->ipset_name),
+ "match%p", bpm);
bpm->entry_hash = hash_create_size(8,
bgp_pbr_match_entry_hash_key,
bgp_pbr_match_entry_hash_equal,