126 lines
2.6 KiB
C
126 lines
2.6 KiB
C
|
|
#ifndef _POLICY_H
|
||
|
|
#define _POLICY_H
|
||
|
|
|
||
|
|
#ifdef __cpluscplus
|
||
|
|
extern "C"
|
||
|
|
{
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#include "raw_packet.h"
|
||
|
|
|
||
|
|
enum traffic_type
|
||
|
|
{
|
||
|
|
TRAFFIC_TYPE_NONE = 0,
|
||
|
|
TRAFFIC_TYPE_RAW = 1,
|
||
|
|
TRAFFIC_TYPE_DECRYPTED = 2,
|
||
|
|
};
|
||
|
|
|
||
|
|
enum forward_type
|
||
|
|
{
|
||
|
|
FORWARD_TYPE_NONE = 0,
|
||
|
|
FORWARD_TYPE_STEERING = 1,
|
||
|
|
FORWARD_TYPE_MIRRORING = 2,
|
||
|
|
};
|
||
|
|
|
||
|
|
enum session_action
|
||
|
|
{
|
||
|
|
SESSION_ACTION_BYPASS = 0,
|
||
|
|
SESSION_ACTION_FORWARD = 1,
|
||
|
|
SESSION_ACTION_BLOCK = 2,
|
||
|
|
};
|
||
|
|
|
||
|
|
enum session_action_reason
|
||
|
|
{
|
||
|
|
ACTION_BYPASS_DUE_DEFAULT = 0x00,
|
||
|
|
|
||
|
|
ACTION_BYPASS_DUE_NO_AVAILABLE_SF = 0x11,
|
||
|
|
ACTION_BYPASS_DUE_HEALTH_SF_LIMIT = 0x12,
|
||
|
|
ACTION_BYPASS_DUE_UNAVAILABLE_ACTION = 0x13,
|
||
|
|
ACTION_BYPASS_DUE_FAILURE_ACTION = 0x14,
|
||
|
|
ACTION_BYPASS_DUE_INVALID_POLICY = 0x15,
|
||
|
|
|
||
|
|
ACTION_BLOCK_DUE_UNAVAILABLE_ACTION = 0x21,
|
||
|
|
ACTION_BLOCK_DUE_FAILURE_ACTION = 0x22,
|
||
|
|
|
||
|
|
ACTION_FORWAED_DUE_SELECTED_AVAILABLE_SF = 0x31,
|
||
|
|
};
|
||
|
|
|
||
|
|
enum package_method
|
||
|
|
{
|
||
|
|
PACKAGE_METHOD_NONE = 0,
|
||
|
|
PACKAGE_METHOD_LAYER2_SWITCH = 1,
|
||
|
|
PACKAGE_METHOD_LAYER3_SWITCH = 2,
|
||
|
|
PACKAGE_METHOD_VXLAN_G = 3,
|
||
|
|
};
|
||
|
|
|
||
|
|
enum health_check_method
|
||
|
|
{
|
||
|
|
HEALTH_CHECK_METHOD_NONE = 0,
|
||
|
|
HEALTH_CHECK_METHOD_IN_BAND_BFD = 1,
|
||
|
|
HEALTH_CHECK_METHOD_BFD = 2,
|
||
|
|
HEALTH_CHECK_METHOD_HTTP = 3,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct health_check
|
||
|
|
{
|
||
|
|
enum health_check_method method;
|
||
|
|
|
||
|
|
char url[128];
|
||
|
|
char address[64];
|
||
|
|
int port;
|
||
|
|
int retires;
|
||
|
|
int interval_ms;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct connectivity
|
||
|
|
{
|
||
|
|
enum package_method method;
|
||
|
|
int int_vlan_tag;
|
||
|
|
int ext_vlan_tag;
|
||
|
|
char dest_ip[64];
|
||
|
|
};
|
||
|
|
|
||
|
|
struct selected_sf
|
||
|
|
{
|
||
|
|
int sff_profile_id;
|
||
|
|
enum forward_type sff_forward_type;
|
||
|
|
|
||
|
|
int sf_profile_id;
|
||
|
|
enum session_action sf_action;
|
||
|
|
enum session_action_reason sf_action_reason;
|
||
|
|
struct connectivity sf_connectivity;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct selected_chaining
|
||
|
|
{
|
||
|
|
int policy_id;
|
||
|
|
enum traffic_type traffic_type;
|
||
|
|
|
||
|
|
struct selected_sf *chaining;
|
||
|
|
int chaining_size;
|
||
|
|
int chaining_index;
|
||
|
|
};
|
||
|
|
|
||
|
|
// return NULL : error
|
||
|
|
// return !NULL : success
|
||
|
|
struct policy_enforcer *policy_enforcer_create(const char *instance, const char *profile, int thread_num, void *logger);
|
||
|
|
void policy_enforcer_destory(struct policy_enforcer *enforcer);
|
||
|
|
|
||
|
|
// return 0 : success
|
||
|
|
// return -1 : error
|
||
|
|
int policy_enforcer_register(struct policy_enforcer *enforcer);
|
||
|
|
|
||
|
|
struct selected_chaining *selected_chaining_create(int chaining_size);
|
||
|
|
void selected_chaining_destory(struct selected_chaining *chaining);
|
||
|
|
void selected_chaining_dump(struct selected_chaining *chaining);
|
||
|
|
void selected_chaining_bref(struct selected_chaining *chaining);
|
||
|
|
|
||
|
|
// return value need be free by selected_chaining_destory()
|
||
|
|
struct selected_chaining *policy_enforce_select_chaining(struct policy_enforcer *enforcer, struct raw_pkt_parser *parser, int policy_id, int dir_is_internal);
|
||
|
|
|
||
|
|
#ifdef __cpluscplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif
|