summaryrefslogtreecommitdiff
path: root/lib/tunnel_encaps.h
blob: 12a905dbc723f7902670fbac327b12130bfe61ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef _BIRD_TUNNEL_ENCAPS_
#define _BIRD_TUNNEL_ENCAPS_

#include "nest/route.h"
#include "sysdep/linux/wireguard.h"

#define BA_TUNNEL_ENCAP		0x17

#define BGP_TUNNEL_ENCAP_A_SUB_TLV_ENCAP         1
#define BGP_TUNNEL_ENCAP_A_SUB_TLV_COLOR         4
#define BGP_TUNNEL_ENCAP_A_SUB_TLV_TUNNEL_EP     6
#define BGP_TUNNEL_ENCAP_A_SUB_TLV_UDP_DEST_PORT 8

#define FLAG_BGP_TUNNEL_ENCAP_A_SUB_TLV_ENCAP         (1<<BGP_TUNNEL_ENCAP_A_SUB_TLV_ENCAP)
#define FLAG_BGP_TUNNEL_ENCAP_A_SUB_TLV_COLOR         (1<<BGP_TUNNEL_ENCAP_A_SUB_TLV_COLOR)
#define FLAG_BGP_TUNNEL_ENCAP_A_SUB_TLV_TUNNEL_EP     (1<<BGP_TUNNEL_ENCAP_A_SUB_TLV_TUNNEL_EP)
#define FLAG_BGP_TUNNEL_ENCAP_A_SUB_TLV_UDP_DEST_PORT (1<<BGP_TUNNEL_ENCAP_A_SUB_TLV_UDP_DEST_PORT)

/* Tunnel Encapsulation */
struct tunnel_endpoint {
  u32 asn;
  u16 af;
  ip_addr ip;
};

struct tunnel_encap {
  int type;
  void *encap;
  size_t encap_len;
  struct tunnel_endpoint ep;
  u32 color;
  u16 udp_dest_port;
  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_ */