From 64c410dff0ff2617a5813525043d0012c03318f6 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 | 53 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c index 2882c862..bc67d5f8 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,7 +222,7 @@ 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) return res; @@ -297,10 +326,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