#include "memory.h"
#include "prefix.h"
#include "filter.h"
+#include "stream.h"
#include "bgpd.h"
#include "bgp_attr.h"
assert(total <= 0xff);
new = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + total);
+ sizeof(struct bgp_attr_encap_subtlv) + total);
assert(new);
new->type = BGP_ENCAP_SUBTLV_TYPE_ENCAPSULATION;
new->length = total;
assert(total <= 0xff);
new = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + total);
+ sizeof(struct bgp_attr_encap_subtlv) + total);
assert(new);
new->type = BGP_ENCAP_SUBTLV_TYPE_ENCAPSULATION;
new->length = total;
assert(total <= 0xff);
new = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + total);
+ sizeof(struct bgp_attr_encap_subtlv) + total);
assert(new);
new->type = BGP_ENCAP_SUBTLV_TYPE_ENCAPSULATION;
new->length = total;
assert(total <= 0xff);
new = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + total);
+ sizeof(struct bgp_attr_encap_subtlv) + total);
assert(new);
new->type = BGP_ENCAP_SUBTLV_TYPE_PROTO_TYPE;
new->length = total;
assert(total <= 0xff);
new = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + total);
+ sizeof(struct bgp_attr_encap_subtlv) + total);
assert(new);
new->type = BGP_ENCAP_SUBTLV_TYPE_COLOR;
new->length = total;
assert(total <= 0xff);
new = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + total);
+ sizeof(struct bgp_attr_encap_subtlv) + total);
assert(new);
new->type = BGP_ENCAP_SUBTLV_TYPE_IPSEC_TA;
new->length = total;
assert(total <= 0xff);
new = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + total);
+ sizeof(struct bgp_attr_encap_subtlv) + total);
assert(new);
new->type = BGP_ENCAP_SUBTLV_TYPE_REMOTE_ENDPOINT;
new->length = total;
if (attr->encap_subtlvs)
XFREE(MTYPE_ENCAP_TLV, attr->encap_subtlvs);
tlv = XCALLOC(MTYPE_ENCAP_TLV,
- sizeof(struct bgp_attr_encap_subtlv) - 1 + 12);
+ sizeof(struct bgp_attr_encap_subtlv) + 12);
tlv->type = 1; /* encapsulation type */
tlv->length = 12;
if (bet->vnid) {
return -1;
}
- st->sessionid = (subtlv->value[0] << 24) | (subtlv->value[1] << 16)
- | (subtlv->value[2] << 8) | subtlv->value[3];
+ ptr_get_be32(subtlv->value, &st->sessionid);
st->cookie_length = subtlv->length - 4;
if (st->cookie_length > sizeof(st->cookie)) {
zlog_debug("%s, subtlv length %d is greater than %d", __func__,
subtlv->length);
return -1;
}
- st->gre_key = (subtlv->value[0] << 24) | (subtlv->value[1] << 16)
- | (subtlv->value[2] << 8) | subtlv->value[3];
+ ptr_get_be32(subtlv->value, &st->gre_key);
return 0;
}
__func__);
return -1;
}
- st->color = (subtlv->value[4] << 24) | (subtlv->value[5] << 16)
- | (subtlv->value[6] << 8) | subtlv->value[7];
+ ptr_get_be32(subtlv->value + 4, &st->color);
return 0;
}
}
if (subtlv->length == 8) {
st->family = AF_INET;
- st->ip_address.v4.s_addr =
- ((subtlv->value[0] << 24) | (subtlv->value[1] << 16)
- | (subtlv->value[2] << 8) | subtlv->value[3]);
+ memcpy(&st->ip_address.v4.s_addr, subtlv->value, 4);
} else {
st->family = AF_INET6;
memcpy(&(st->ip_address.v6.s6_addr), subtlv->value, 16);
}
i = subtlv->length - 4;
- st->as4 = ((subtlv->value[i] << 24) | (subtlv->value[i + 1] << 16)
- | (subtlv->value[i + 2] << 8) | subtlv->value[i + 3]);
+ ptr_get_be32(subtlv->value + i, &st->as4);
return 0;
}