summaryrefslogtreecommitdiff
path: root/access/include
diff options
context:
space:
mode:
author崔一鸣 <[email protected]>2018-12-13 19:55:59 +0800
committer崔一鸣 <[email protected]>2018-12-13 19:55:59 +0800
commit608aea42336fcc768e3eecaa12c846266d4bcd69 (patch)
tree495fafa70961d4c1389f73d5d78e6212a227900b /access/include
parent250f47e34d2d30e099d167cc8eb979eff13d8dd4 (diff)
增加dnat模块
Diffstat (limited to 'access/include')
-rw-r--r--access/include/dnat.h9
-rw-r--r--access/include/ip_mgr.h39
-rw-r--r--access/include/nat.h9
-rw-r--r--access/include/snat.h10
-rw-r--r--access/include/udp_server.h3
5 files changed, 30 insertions, 40 deletions
diff --git a/access/include/dnat.h b/access/include/dnat.h
new file mode 100644
index 0000000..143da80
--- /dev/null
+++ b/access/include/dnat.h
@@ -0,0 +1,9 @@
+struct dnat_handle;
+
+struct dnat_handle * dnat_init(const char *profile, struct ip_mgr_handle *_ip_mgr_handle, struct field_stat_handle *fs_handle, void *logger);
+
+void dnat_destroy(struct dnat_handle *handle);
+
+int dnat_tx_convert(struct dnat_handle *handle, char *buff, int len, uint32_t *mrl_ip);
+
+int dnat_rx_convert(struct dnat_handle *handle, char *buff, int len); \ No newline at end of file
diff --git a/access/include/ip_mgr.h b/access/include/ip_mgr.h
index 9b8c2a7..41f09f9 100644
--- a/access/include/ip_mgr.h
+++ b/access/include/ip_mgr.h
@@ -1,34 +1,13 @@
-#define IP_MGR_MAC_LEN 18
-#define IP_MGR_IP_LEN 16
-#define IP_MGR_PORT_LEN 6
-
-struct ip_mgr_cand_ip_detail
-{
- uint32_t ip;
- int reference;
- struct ip_mgr_vxlan_info *vxlan_info;
- uint32_t mrl_ip;
-};
+struct ip_mgr_handle;
-struct ip_mgr_vxlan_info
-{
- int vxlan_link_id;
- int vxlan_encap_type;
- int vxlan_link_dir;
- int vxlan_vpn_id;
- char vxlan_outer_local_port[IP_MGR_PORT_LEN];
- char vxlan_outer_gdev_port[IP_MGR_PORT_LEN];
- char vxlan_outer_local_ip[IP_MGR_IP_LEN];
- char vxlan_outer_gdev_ip[IP_MGR_IP_LEN];//串行设备IP
- char vxlan_outer_local_mac[IP_MGR_MAC_LEN];//接收到的数据包的本地设备MAC地址
- char vxlan_outer_gdev_mac[IP_MGR_MAC_LEN];//接收到的数据包的串行设备MAC地址
- char vxlan_inner_smac[IP_MGR_MAC_LEN];
- char vxlan_inner_dmac[IP_MGR_MAC_LEN];
-};
+struct ip_mgr_handle *ip_mgr_init(const char *profile, struct field_stat_handle *fs_handle, void *logger);
-struct ip_mgr_handle;
-struct ip_mgr_handle *ip_mgr_init(const char *profile, MESA_htable_handle cand_ip_detail_htable, struct field_stat_handle *fs_handle,
- Maat_feather_t Maat_feather_cand, Maat_feather_t Maat_feather_policy, void *logger);
void ip_mgr_destroy(struct ip_mgr_handle *handle);
-int ip_mgr_candidata_ip_get(struct ip_mgr_handle *handle, const char *user_name, uint32_t *selected_ip); \ No newline at end of file
+
+int ip_mgr_dnat_policy_query(struct ip_mgr_handle *handle, uint32_t orig_ip,
+ uint16_t orig_port, uint32_t *trans_ip, uint16_t *trans_port);
+
+int ip_mgr_mrl_ip_query(struct ip_mgr_handle *handle, uint32_t back_ip, uint32_t *mrl_ip);
+
+int ip_mgr_snat_cand_ip_get(struct ip_mgr_handle *handle, const char *user_name, uint32_t *selected_ip); \ No newline at end of file
diff --git a/access/include/nat.h b/access/include/nat.h
deleted file mode 100644
index 5df0104..0000000
--- a/access/include/nat.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#define NAT_COVERT_SUCCESS -1
-#define NAT_COVERT_FAILURE 0
-
-struct nat_handle;
-struct nat_handle * nat_init(const char *profile, MESA_htable_handle ip2user_htable, MESA_htable_handle cand_ip_detail_htable,
- struct field_stat_handle *fs_handle, void *logger);
-void nat_destroy(struct nat_handle *handle);
-int nat_src_convert(struct nat_handle *handle, struct ip_mgr_handle *_ip_mgr_handle, char *buff, int len, struct ip_mgr_vxlan_info **vxlan_info, uint32_t *mrl_ip);
-int nat_dest_convert(struct nat_handle *handle, char *buff, int len); \ No newline at end of file
diff --git a/access/include/snat.h b/access/include/snat.h
new file mode 100644
index 0000000..a77915d
--- /dev/null
+++ b/access/include/snat.h
@@ -0,0 +1,10 @@
+struct snat_handle;
+
+struct snat_handle * snat_init(const char *profile, MESA_htable_handle ip2user_htable, struct ip_mgr_handle *_ip_mgr_handle,
+ struct field_stat_handle *fs_handle, void *logger);
+
+void snat_destroy(struct snat_handle *handle);
+
+int snat_tx_convert(struct snat_handle *handle, char *buff, int len, uint32_t *mrl_ip);
+
+int snat_rx_convert(struct snat_handle *handle, char *buff, int len); \ No newline at end of file
diff --git a/access/include/udp_server.h b/access/include/udp_server.h
index a326327..40917a2 100644
--- a/access/include/udp_server.h
+++ b/access/include/udp_server.h
@@ -2,7 +2,8 @@ struct udp_server_args
{
void *logger;
const char *profile;
- struct nat_handle *_nat_handle;
+ struct snat_handle *_snat_handle;
+ struct dnat_handle *_dnat_handle;
struct mgw_tun_handle *tun_handle;
struct field_stat_handle *fs_handle;
};