From 659ef444ad3ea6cd470101f99f1267eb7f6fdf4b Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 9 Mar 2019 00:05:15 +0100 Subject: Wireguard: Extended color community --- proto/wireguard/wireguard.c | 59 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c index 2882c862..c7345c46 100644 --- a/proto/wireguard/wireguard.c +++ b/proto/wireguard/wireguard.c @@ -50,10 +50,15 @@ dump(void *ptr, size_t len) #define BGP_TUNNEL_ENCAP_A_SUB_TLV_REMOTE_EP 6 #define BGP_TUNNEL_ENCAP_A_SUB_TLV_UDP_DEST_PORT 8 +#define FLAG_BGP_TUNNEL_ENCAP_A_SUB_TLV_ENCAP (1<u.ptr->data; int len = e->u.ptr->length; @@ -193,10 +224,12 @@ int decode_tunnel_encap(const eattr *e, wg_key *pubkey, u32 *as4, ip_addr *remot } for (u8 *cur = p + 4; cur < p + 4 + value_length;) { - int res = decode_sub_tlv(cur, value_length, pubkey, as4, remote_ep, udp_port); + int res = decode_sub_tlv(cur, value_length, pubkey, as4, remote_ep, color, udp_port, flags); - if (res < 0) + if (res < 0) { + log(L_TRACE "WG: decode error %d", res); return res; + } cur += res; } @@ -297,10 +330,12 @@ wg_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *n, u32 remote_ep_as4 = 0; ip_addr remote_ep_addr = IPA_NONE; u16 udp_dest_port = 0; + u32 color = 0; + u16 flags = 0; t = ea_find(new->attrs->eattrs, EA_CODE(PROTOCOL_BGP, BA_TUNNEL_ENCAP)); - if (t && t->u.ptr && decode_tunnel_encap(t, &pubkey, &remote_ep_as4, &remote_ep_addr, &udp_dest_port) == 0) { - log(L_TRACE "WG: Attr %x %x %d", t->flags, t->type, t->u.ptr->length); + if (t && t->u.ptr && decode_tunnel_encap(t, &pubkey, &remote_ep_as4, &remote_ep_addr, &color, &udp_dest_port, &flags) == 0) { + log(L_TRACE "WG: Attr %x %x %d %04x", t->flags, t->type, t->u.ptr->length, flags); struct wg_device *dev = NULL; -- cgit v1.2.3