/*
 *	Netlink FreeBSD-specific functions
 *
 *	(c) 2022 Alexander Chernikov <melifaro@FreeBSD.org>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_NETLINK_SYS_H_
#define _BIRD_NETLINK_SYS_H_

#include <netlink/netlink.h>
#include <netlink/netlink_route.h>

#ifndef	AF_MPLS
#define	AF_MPLS	39
#endif

#ifndef	SO_RCVBUFFORCE
#define	SO_RCVBUFFORCE	SO_RCVBUF
#endif


/* Missing definitions from <linux/if_link.h> */

enum {
  IFLA_BR_UNSPEC,
  IFLA_BR_FORWARD_DELAY,
  IFLA_BR_HELLO_TIME,
  IFLA_BR_MAX_AGE,
  IFLA_BR_AGEING_TIME,
  IFLA_BR_STP_STATE,
  IFLA_BR_PRIORITY,
  IFLA_BR_VLAN_FILTERING,
  IFLA_BR_VLAN_PROTOCOL,
  IFLA_BR_GROUP_FWD_MASK,
  IFLA_BR_ROOT_ID,
  IFLA_BR_BRIDGE_ID,
  IFLA_BR_ROOT_PORT,
  IFLA_BR_ROOT_PATH_COST,
  IFLA_BR_TOPOLOGY_CHANGE,
  IFLA_BR_TOPOLOGY_CHANGE_DETECTED,
  IFLA_BR_HELLO_TIMER,
  IFLA_BR_TCN_TIMER,
  IFLA_BR_TOPOLOGY_CHANGE_TIMER,
  IFLA_BR_GC_TIMER,
  IFLA_BR_GROUP_ADDR,
  IFLA_BR_FDB_FLUSH,
  IFLA_BR_MCAST_ROUTER,
  IFLA_BR_MCAST_SNOOPING,
  IFLA_BR_MCAST_QUERY_USE_IFADDR,
  IFLA_BR_MCAST_QUERIER,
  IFLA_BR_MCAST_HASH_ELASTICITY,
  IFLA_BR_MCAST_HASH_MAX,
  IFLA_BR_MCAST_LAST_MEMBER_CNT,
  IFLA_BR_MCAST_STARTUP_QUERY_CNT,
  IFLA_BR_MCAST_LAST_MEMBER_INTVL,
  IFLA_BR_MCAST_MEMBERSHIP_INTVL,
  IFLA_BR_MCAST_QUERIER_INTVL,
  IFLA_BR_MCAST_QUERY_INTVL,
  IFLA_BR_MCAST_QUERY_RESPONSE_INTVL,
  IFLA_BR_MCAST_STARTUP_QUERY_INTVL,
  IFLA_BR_NF_CALL_IPTABLES,
  IFLA_BR_NF_CALL_IP6TABLES,
  IFLA_BR_NF_CALL_ARPTABLES,
  IFLA_BR_VLAN_DEFAULT_PVID,
  IFLA_BR_PAD,
  IFLA_BR_VLAN_STATS_ENABLED,
  IFLA_BR_MCAST_STATS_ENABLED,
  IFLA_BR_MCAST_IGMP_VERSION,
  IFLA_BR_MCAST_MLD_VERSION,
  IFLA_BR_VLAN_STATS_PER_PORT,
  IFLA_BR_MULTI_BOOLOPT,
  IFLA_BR_MCAST_QUERIER_STATE,
  IFLA_BR_FDB_N_LEARNED,
  IFLA_BR_FDB_MAX_LEARNED,
};

enum {
  IFLA_VXLAN_UNSPEC,
  IFLA_VXLAN_ID,
  IFLA_VXLAN_GROUP,       /* group or remote address */
  IFLA_VXLAN_LINK,
  IFLA_VXLAN_LOCAL,
  IFLA_VXLAN_TTL,
  IFLA_VXLAN_TOS,
  IFLA_VXLAN_LEARNING,
  IFLA_VXLAN_AGEING,
  IFLA_VXLAN_LIMIT,
  IFLA_VXLAN_PORT_RANGE,  /* source port */
  IFLA_VXLAN_PROXY,
  IFLA_VXLAN_RSC,
  IFLA_VXLAN_L2MISS,
  IFLA_VXLAN_L3MISS,
  IFLA_VXLAN_PORT,        /* destination port */
  IFLA_VXLAN_GROUP6,
  IFLA_VXLAN_LOCAL6,
  IFLA_VXLAN_UDP_CSUM,
  IFLA_VXLAN_UDP_ZERO_CSUM6_TX,
  IFLA_VXLAN_UDP_ZERO_CSUM6_RX,
  IFLA_VXLAN_REMCSUM_TX,
  IFLA_VXLAN_REMCSUM_RX,
  IFLA_VXLAN_GBP,
  IFLA_VXLAN_REMCSUM_NOPARTIAL,
  IFLA_VXLAN_COLLECT_METADATA,
  IFLA_VXLAN_LABEL,
  IFLA_VXLAN_GPE,
  IFLA_VXLAN_TTL_INHERIT,
  IFLA_VXLAN_DF,
  IFLA_VXLAN_VNIFILTER, /* only applicable with COLLECT_METADATA mode */
  IFLA_VXLAN_LOCALBYPASS,
  IFLA_VXLAN_LABEL_POLICY, /* IPv6 flow label policy; ifla_vxlan_label_policy */
};


/* Missing definitions from <linux/if_bridge.h> */

struct bridge_vlan_info {
  u16 flags;
  u16 vid;
};

enum {
  IFLA_BRIDGE_FLAGS,
  IFLA_BRIDGE_MODE,
  IFLA_BRIDGE_VLAN_INFO,
  IFLA_BRIDGE_VLAN_TUNNEL_INFO,
  IFLA_BRIDGE_MRP,
  IFLA_BRIDGE_CFM,
  IFLA_BRIDGE_MST,
};

enum {
  IFLA_BRIDGE_VLAN_TUNNEL_UNSPEC,
  IFLA_BRIDGE_VLAN_TUNNEL_ID,
  IFLA_BRIDGE_VLAN_TUNNEL_VID,
  IFLA_BRIDGE_VLAN_TUNNEL_FLAGS,
};


static inline int
netlink_error_to_os(int error)
{
	return (error);
}

#endif
