#ifndef _NET_TRILL_H
#define _NET_TRILL_H
#include <sys/types.h>
#include <sys/param.h>
#include <sys/ethernet.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ALL_RBRIDGES { 0x01, 0x80, 0xC2, 0x00, 0x02, 0x00 }
#define ALL_ISIS_RBRIDGES { 0x01, 0x80, 0xC2, 0x00, 0x02, 0x01 }
#define ALL_ESADI_RBRIDGES { 0x01, 0x80, 0xC2, 0x00, 0x02, 0x02 }
#define TRILL_PROTOCOL_VERS 0
#define TRILL_DEFAULT_HOPS 21
#define RBRIDGE_NICKNAME_MIN 0x0000
#define RBRIDGE_NICKNAME_MAX 0xFFFF
#define RBRIDGE_NICKNAME_NONE RBRIDGE_NICKNAME_MIN
#define RBRIDGE_NICKNAME_MINRES 0xFFC0
#define RBRIDGE_NICKNAME_MAXRES (RBRIDGE_NICKNAME_MAX - 1)
#define RBRIDGE_NICKNAME_UNUSED RBRIDGE_NICKNAME_MAX
#define MIN_RBRIDGE_RANDOM_NICKNAME (RBRIDGE_NICKNAME_NONE + 1)
#define MAX_RBRIDGE_RANDOM_NICKNAME (RBRIDGE_NICKNAME_MINRES - 1)
#define TRILL_BASE (0x54524c00)
#define TRILL_SETNICK (TRILL_BASE + 0)
#define TRILL_GETNICK (TRILL_BASE + 1)
#define TRILL_ADDNICK (TRILL_BASE + 2)
#define TRILL_DELNICK (TRILL_BASE + 3)
#define TRILL_DELALL (TRILL_BASE + 4)
#define TRILL_HWADDR (TRILL_BASE + 5)
#define TRILL_TREEROOT (TRILL_BASE + 6)
#define TRILL_NEWBRIDGE (TRILL_BASE + 7)
#define TRILL_VLANFWDER (TRILL_BASE + 8)
#define TRILL_DESIGVLAN (TRILL_BASE + 9)
#define TRILL_LISTNICK (TRILL_BASE + 10)
#define TRILL_GETBRIDGE (TRILL_BASE + 11)
#define TRILL_PORTFLUSH (TRILL_BASE + 12)
#define TRILL_NICKFLUSH (TRILL_BASE + 13)
#define TRILL_GETMTU (TRILL_BASE + 14)
typedef struct trill_header {
#ifdef _BIT_FIELDS_HTOL
uint8_t th_version : 2;
uint8_t th_reserved : 2;
uint8_t th_multidest : 1;
uint8_t th_optslen_hi : 3;
#else
uint8_t th_optslen_hi : 3;
uint8_t th_multidest : 1;
uint8_t th_reserved : 2;
uint8_t th_version : 2;
#endif
#ifdef _BIT_FIELDS_HTOL
uint8_t th_optslen_lo : 2;
uint8_t th_hopcount : 6;
#else
uint8_t th_hopcount : 6;
uint8_t th_optslen_lo : 2;
#endif
uint16_t th_egressnick;
uint16_t th_ingressnick;
} trill_header_t;
#define TRILL_HDR_ALIGN (sizeof (uint16_t))
#define SET_TRILL_OPTS_LEN(hdr_p, val) \
do { \
(hdr_p)->th_optslen_lo = (val)&0x03; \
(hdr_p)->th_optslen_hi = (val)>>2; \
_NOTE(CONSTANTCONDITION) \
} while (0)
#define GET_TRILL_OPTS_LEN(hdr_p) \
((hdr_p)->th_optslen_lo|((hdr_p)->th_optslen_hi<<2))
typedef struct trill_nickinfo_s {
uint16_t tni_nick;
ether_addr_t tni_adjsnpa;
datalink_id_t tni_linkid;
uint16_t tni_adjcount;
uint16_t tni_dtrootcount;
} trill_nickinfo_t;
typedef struct trill_listnick_s {
uint16_t tln_nick;
ether_addr_t tln_nexthop;
datalink_id_t tln_linkid;
boolean_t tln_ours;
} trill_listnick_t;
#define TNI_ADJNICKSPTR(v) ((uint16_t *)((trill_nickinfo_t *)(v)+1))
#define TNI_ADJNICK(v, n) (TNI_ADJNICKSPTR(v)[(n)])
#define TNI_DTROOTNICKSPTR(v) (TNI_ADJNICKSPTR(v)+(v)->tni_adjcount)
#define TNI_DTROOTNICK(v, n) (TNI_DTROOTNICKSPTR(v)[(n)])
#define TNI_VLANFILTERSPTR(v) (TNI_DTROOTNICKSPTR(v)+(v)->tni_dtrootcount)
#define TNI_VLANFILTERMAP(v, n) \
(((uint8_t *)(TNI_VLANFILTERSPTR(v)))+((n)*((1<<12)/NBBY)))
#define TNI_TOTALSIZE(v) (sizeof (trill_nickinfo_t) + \
(sizeof (uint16_t) * (v)->tni_adjcount) + \
(sizeof (uint16_t) * (v)->tni_dtrootcount) + \
(((1<<12)/NBBY) * (v)->tni_adjcount))
#define TRILL_TCI_BPDU 0xFFFF
#ifdef __cplusplus
}
#endif
#endif