#ifndef _INET_ILB_H
#define _INET_ILB_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
ILB_CREATE_RULE,
ILB_DESTROY_RULE,
ILB_ENABLE_RULE,
ILB_DISABLE_RULE,
ILB_NUM_RULES,
ILB_NUM_SERVERS,
ILB_RULE_NAMES,
ILB_LIST_RULE,
ILB_LIST_SERVERS,
ILB_ADD_SERVERS,
ILB_DEL_SERVERS,
ILB_ENABLE_SERVERS,
ILB_DISABLE_SERVERS,
ILB_LIST_NAT_TABLE,
ILB_LIST_STICKY_TABLE
} ilb_cmd_t;
typedef enum {
ILB_ALG_IMPL_ROUNDROBIN = 1,
ILB_ALG_IMPL_HASH_IP,
ILB_ALG_IMPL_HASH_IP_SPORT,
ILB_ALG_IMPL_HASH_IP_VIP
} ilb_algo_impl_t;
typedef enum {
ILB_TOPO_IMPL_DSR = 1,
ILB_TOPO_IMPL_NAT,
ILB_TOPO_IMPL_HALF_NAT
} ilb_topo_impl_t;
#define ILB_RULE_NAMESZ 20
#define ILB_SERVER_NAMESZ 20
typedef struct {
ilb_cmd_t cmd;
char name[ILB_RULE_NAMESZ];
uint32_t flags;
} ilb_name_cmd_t;
#define ILB_RULE_ENABLED 0x1
#define ILB_RULE_STICKY 0x2
#define ILB_RULE_ALLRULES 0x4
#define ILB_RULE_BUSY 0x8
typedef struct {
ilb_cmd_t cmd;
char name[ILB_RULE_NAMESZ];
uint32_t ip_ver;
in6_addr_t vip;
char vip_itf[LIFNAMSIZ];
uint32_t proto;
in_port_t min_port;
in_port_t max_port;
ilb_algo_impl_t algo;
ilb_topo_impl_t topo;
char servers_itf[LIFNAMSIZ];
in6_addr_t nat_src_start;
in6_addr_t nat_src_end;
uint32_t flags;
in6_addr_t sticky_mask;
uint32_t conn_drain_timeout;
uint32_t nat_expiry;
uint32_t sticky_expiry;
} ilb_rule_cmd_t;
typedef struct {
ilb_cmd_t cmd;
char name[ILB_RULE_NAMESZ];
uint32_t num;
} ilb_num_servers_cmd_t;
typedef struct {
ilb_cmd_t cmd;
uint32_t num;
} ilb_num_rules_cmd_t;
typedef struct {
ilb_cmd_t cmd;
uint32_t num_names;
char buf[ILB_RULE_NAMESZ];
} ilb_rule_names_cmd_t;
#define ILB_SERVER_ENABLED 0x1
typedef struct {
char name[ILB_SERVER_NAMESZ];
in6_addr_t addr;
in_port_t min_port;
in_port_t max_port;
uint32_t flags;
int err;
} ilb_server_info_t;
typedef struct {
ilb_cmd_t cmd;
char name[ILB_RULE_NAMESZ];
uint32_t num_servers;
ilb_server_info_t servers[1];
} ilb_servers_info_cmd_t;
typedef struct {
in6_addr_t addr;
int err;
} ilb_server_arg_t;
typedef struct {
ilb_cmd_t cmd;
char name[ILB_RULE_NAMESZ];
uint32_t num_servers;
ilb_server_arg_t servers[1];
} ilb_servers_cmd_t;
#define ILB_LIST_BEGIN 0x1
#define ILB_LIST_CONT 0x2
#define ILB_LIST_END 0x4
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack(4)
#endif
typedef struct {
uint32_t proto;
in6_addr_t in_local;
in6_addr_t in_global;
in6_addr_t out_local;
in6_addr_t out_global;
in_port_t in_local_port;
in_port_t in_global_port;
in_port_t out_local_port;
in_port_t out_global_port;
int64_t create_time;
int64_t last_access_time;
uint64_t pkt_cnt;
} ilb_nat_entry_t;
typedef struct {
ilb_cmd_t cmd;
uint32_t flags;
uint32_t num_nat;
ilb_nat_entry_t entries[1];
} ilb_list_nat_cmd_t;
typedef struct {
char rule_name[ILB_RULE_NAMESZ];
in6_addr_t req_addr;
in6_addr_t srv_addr;
int64_t expiry_time;
} ilb_sticky_entry_t;
typedef struct {
ilb_cmd_t cmd;
uint32_t flags;
uint32_t num_sticky;
ilb_sticky_entry_t entries[1];
} ilb_list_sticky_cmd_t;
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
#pragma pack()
#endif
#ifdef __cplusplus
}
#endif
#endif