From a3ac30fd374a665c67ca0718ce9999f8f0c03be2 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 1 Oct 2019 19:06:27 +0200 Subject: WIP --- lib/tunnel_encaps.c | 20 ++++++++++++++++++++ lib/tunnel_encaps.h | 6 ++++++ 2 files changed, 26 insertions(+) (limited to 'lib') diff --git a/lib/tunnel_encaps.c b/lib/tunnel_encaps.c index 590cf958..b77bc710 100644 --- a/lib/tunnel_encaps.c +++ b/lib/tunnel_encaps.c @@ -58,7 +58,19 @@ int decode_tunnel_ep(const void *p, size_t sub_tlv_len, struct tunnel_encap *enc encap->ep.asn = get_u32(p); u16 af = get_u16(p + 4); + encap->ep.af = af; switch (af) { + case 0: + if (sub_tlv_len != 6) { + log(L_TRACE "WG: Fam 0 len error %d", sub_tlv_len); + return -1; + } + if (encap->ep.asn != 0) { + log(L_TRACE "WG: Fam 0 asn error %d", sub_tlv_len); + return -1; + } + encap->ep.ip = IP6_NONE; + return 0; case NET_IP4: if (sub_tlv_len != 10) { log(L_TRACE "WG: IPv4 len error %d", sub_tlv_len); @@ -289,3 +301,11 @@ int format_tunnel_encap(const eattr *a, byte *buf, uint size) return pos - buf; } + +void register_format_tunnel_encap(int type, format_tunnel_encap_fn cb) +{ +} + +void unregister_format_tunnel_encap(int type, format_tunnel_encap_fn cb) +{ +} diff --git a/lib/tunnel_encaps.h b/lib/tunnel_encaps.h index 7358947e..12a905db 100644 --- a/lib/tunnel_encaps.h +++ b/lib/tunnel_encaps.h @@ -19,6 +19,7 @@ /* Tunnel Encapsulation */ struct tunnel_endpoint { u32 asn; + u16 af; ip_addr ip; }; @@ -32,8 +33,13 @@ struct tunnel_encap { u16 flags; }; +typedef int (*format_tunnel_encap_fn)(const struct tunnel_encap *, byte *buf, uint size); + int decode_tunnel_encap(const eattr *e, struct tunnel_encap *encap, struct pool *pool); int format_tunnel_encap(const eattr *a, byte *buf, uint size); +void register_format_tunnel_encap(int type, format_tunnel_encap_fn cb); +void unregister_format_tunnel_encap(int type, format_tunnel_encap_fn cb); + #endif /* _BIRD_TUNNEL_ENCAPS_ */ -- cgit v1.2.3