summaryrefslogtreecommitdiff
path: root/include/mrl_main.h
blob: 913146860143c58c7a194a6660269051cb80fb77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef __MRL_MAIN_H_
#define __MRL_MAIN_H_
#include <arpa/inet.h>
#include <sys/types.h>


#include "stream_inc/stream_rawpkt.h"
#include "MESA_prof_load.h"
#include "MESA_handle_logger.h"
#include "MESA_htable.h"
#include "MESA_list_queue.h"
#include "Maat_rule.h"
#include "Maat_command.h"

#include "mrl_utils.h"

struct mrl_global_cfg
{
    //log info
    char mrl_log_path[MRL_MAX_PATH];
    int mrl_log_level;

    //detect info
    //TODO �¸��汾��Ҫ������̨̽���������һ̨����һ̨����
    char dest_ip[MRL_STR_IP_LEN];
    uint16_t dest_port;
    uint16_t local_port;
    
    //socket info
    char mgw_ip[MRL_STR_IP_LEN];
    char mrl_ip[MRL_STR_IP_LEN];
    uint16_t mgw_port;//mgw listen udp port
    uint16_t mrl_port;//mrl listen udp port

    //maat info
    char Maat_table_path[MRL_MAX_PATH];  
    char Maat_stat_path[MRL_MAX_PATH];
    unsigned int Maat_max_threads;

    char nominee_redis_ip[MRL_STR_IP_LEN];    
    uint16_t nominee_redis_port;  
    int nominee_redis_index;
    char snat_candidate_redis_ip[MRL_STR_IP_LEN];    
    uint16_t snat_candidate_redis_port;  
    int snat_candidate_redis_index;

    char dnat_policy_redis_ip[MRL_STR_IP_LEN];    
    uint16_t dnat_policy_redis_port;  
    int dnat_policy_redis_index;
    char dnat_candidate_redis_ip[MRL_STR_IP_LEN];    
    uint16_t dnat_candidate_redis_port;  
    int dnat_candidate_redis_index;

    char vxlan_info_redis_ip[MRL_STR_IP_LEN];    
    uint16_t vxlan_info_redis_port;  
    int vxlan_info_redis_index;
    char mrl_ip_redis_ip[MRL_STR_IP_LEN];    
    uint16_t mrl_ip_redis_port;  
    int mrl_ip_redis_index;


    //htable info
    unsigned int ht_slot_size;
    unsigned int ht_max_element_num;
    unsigned int ht_mutex_num;

    //candidate info
    char ip_location[MRL_LOCATION_LEN];

    //vxlan_info
    char link_identity_path[MRL_MAX_PATH];
};

struct mrl_global_instance
{
    void *mrl_log_handle;
    struct mrl_global_cfg mrl_cfg;
    Maat_feather_t nominee_feather;
    Maat_feather_t snat_candidate_feather;
    
    Maat_feather_t dnat_policy_feather;
    Maat_feather_t dnat_candidate_feather;
    
    Maat_feather_t vxlan_info_feather;
    Maat_feather_t mrl_ip_feather;
    
    MESA_htable_handle ht_link_identity;//��ŵ�ǰjson���д��ڵ�link_identity
    MESA_htable_handle ht_nominee;//�洢dnat��snat��Ҫ̽���IP�Ĺ�ϣ��
    MESA_htable_handle ht_snat_candidate;//�����洢snat���Ը��õ�IP��
    MESA_htable_handle ht_dnat_policy;//�����ж�dant���������Ĺ�ϣ��
    MESA_htable_handle ht_dnat_candidate;//�����ж�dnat̽��ɹ���IP�Ĺ�ϣ��
    MESA_htable_handle ht_vxlan_info;
    MESA_htable_handle ht_mrl_ip_info;
    
    //MESA_lqueue_head mrl_queue;
    MMDB_s mrl_mmdb;
    int stop_flag;
    int *mrl_snd_fd;
    int mrl_rcv_fd;
    struct sockaddr_in mgw_addr;
};
#endif