summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_encap_tlv.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-09-07 15:58:18 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-09-09 19:50:58 +0200
commit937652c6e43fc74ba969bbace475bdf929cdc5d0 (patch)
treef2cdea6d59fa9e2f20eafc512fe21203f6acdd6b /bgpd/bgp_encap_tlv.c
parentMerge pull request #1118 from opensourcerouting/attr-kill-master (diff)
downloadfrr-937652c6e43fc74ba969bbace475bdf929cdc5d0.tar.xz
frr-937652c6e43fc74ba969bbace475bdf929cdc5d0.zip
*: fix be32 reading / 24-bit left shift
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_encap_tlv.c')
-rw-r--r--bgpd/bgp_encap_tlv.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/bgpd/bgp_encap_tlv.c b/bgpd/bgp_encap_tlv.c
index 5c0cc40f1..445750161 100644
--- a/bgpd/bgp_encap_tlv.c
+++ b/bgpd/bgp_encap_tlv.c
@@ -22,6 +22,7 @@
#include "memory.h"
#include "prefix.h"
#include "filter.h"
+#include "stream.h"
#include "bgpd.h"
#include "bgp_attr.h"
@@ -470,8 +471,7 @@ static int subtlv_decode_encap_l2tpv3_over_ip(
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__,
@@ -491,8 +491,7 @@ static int subtlv_decode_encap_gre(struct bgp_attr_encap_subtlv *subtlv,
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;
}
@@ -545,8 +544,7 @@ static int subtlv_decode_color(struct bgp_attr_encap_subtlv *subtlv,
__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;
}
@@ -580,16 +578,13 @@ subtlv_decode_remote_endpoint(struct bgp_attr_encap_subtlv *subtlv,
}
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;
}