Something went wrong. Try again.
forked from cz-nic/bird
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105/* * BIRD Internet Routing Daemon -- EVPN Net Type * * (c) 2023 Ondrej Zajicek <santiago@crfreenet.org> * (c) 2023 CZ.NIC z.s.p.o. * * Can be freely distributed and used under the terms of the GNU GPL. */
#ifndef _BIRD_EVPN_NET_H_#define _BIRD_EVPN_NET_H_
enum evpn_net_type { NET_EVPN_EAD = 1, NET_EVPN_MAC = 2, NET_EVPN_IMET = 3, NET_EVPN_ES = 4, NET_EVPN_MAX};
enum evpn_esi_type { EVPN_ESI_MANUAL = 0, EVPN_ESI_LACP = 1, EVPN_ESI_MAX};
#define EVPN_TAG_MAX 0xffffffff#define EVPN_VNI_MAX 0x00ffffff#define EVPN_VID_MAX 0x00000fff
/* * EVPN ESI */
typedef struct evpn_esi { u8 type; u8 value[9];} evpn_esi;
#define EVPN_ESI_NONE ((evpn_esi){ })
static inline bool evpn_esi_equal(evpn_esi a, evpn_esi b){ return !memcmp(&a, &b, sizeof(evpn_esi)); }
static inline bool evpn_esi_zero(evpn_esi a){ return !memcmp(&a, &EVPN_ESI_NONE, sizeof(evpn_esi)); }
static inline bool evpn_esi_nonzero(evpn_esi a){ return !evpn_esi_zero(a); }
static inline int evpn_esi_compare(evpn_esi a, evpn_esi b){ return memcmp(&a, &b, sizeof(evpn_esi)); }
/* * MAC address */
typedef struct mac_addr { u8 addr[6];} mac_addr;
#define MAC_NONE ((mac_addr){ })
static inline mac_addr mac_from_u64(u64 a){ a = htobe64(a); mac_addr result; memcpy(result.addr, (u8 *)&a + 2, sizeof(mac_addr)); return result;}
static inline u64 mac_to_u64(mac_addr a){ u64 result = 0; memcpy((u8 *)&result + 2, a.addr, sizeof(mac_addr)); return be64toh(result);}
static inline bool mac_equal(mac_addr a, mac_addr b){ return !memcmp(&a, &b, sizeof(mac_addr)); }
static inline bool mac_zero(mac_addr a){ return !memcmp(&a, &MAC_NONE, sizeof(mac_addr)); }
static inline bool mac_nonzero(mac_addr a){ return !mac_zero(a); }
static inline int mac_compare(mac_addr a, mac_addr b){ return memcmp(&a, &b, sizeof(mac_addr)); }
static inline bool mac_is_unicast(mac_addr a){ return !(a.addr[0] & 0x01); }
/* * EVPN net functions */
union net_addr_evpn;uint evpn_format(char *buf, uint blen, const union net_addr_evpn *n);
#endif