diff options
| author | 崔一鸣 <[email protected]> | 2018-12-18 18:03:01 +0800 |
|---|---|---|
| committer | 崔一鸣 <[email protected]> | 2018-12-18 18:13:38 +0800 |
| commit | 5679a4d71da19564c42ea7f8edf5c274dd6cb86f (patch) | |
| tree | 841ff50608861106c0bb2cff444af70870d4bf0b /access/src/main.cpp | |
| parent | abaa4322165f523736f9d847d1cffdf438d64968 (diff) | |
修改dnat代码,方便测试1.1.1
Diffstat (limited to 'access/src/main.cpp')
| -rw-r--r-- | access/src/main.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/access/src/main.cpp b/access/src/main.cpp index 9545aaf..31ab96f 100644 --- a/access/src/main.cpp +++ b/access/src/main.cpp @@ -43,9 +43,8 @@ static struct udp_client_handle * udp_client_init(const char *profile, void *log const char *section = "mrl"; char ip[MGW_SYMBOL_MAX] = ""; uint16_t port; - MESA_load_profile_string_def(profile, section, "ip", ip, MGW_SYMBOL_MAX, "192.168.10.242"); MESA_load_profile_int_def(profile, section, "port", (int *)&port, 23456); - MGW_LOG_INFO(logger, "MESA_prof_load, [%s]:\n ip: %s\n port: %d", "mrl", ip, port); + MGW_LOG_INFO(logger, "MESA_prof_load, [%s]:\n port: %d", "mrl", port); int socket_fd = mgw_socket_init(); if(socket_fd < 0) { @@ -198,7 +197,7 @@ static struct mgw_handle * mgw_init(char *conf_path) struct mgw_handle *_mgw_handle = ALLOC(struct mgw_handle, 1); char *profile = ALLOC(char, MGW_SYMBOL_MAX); strncpy(profile, conf_path, MGW_SYMBOL_MAX); - printf("profile is %s\n", profile); + //printf("profile is %s\n", profile); const char *section = "global"; //init srand @@ -317,10 +316,22 @@ static int send_data_to_mrl(struct udp_client_handle *handle, char *buff, int le static void mgw_run(struct mgw_handle *handle) { //void *logger = handle->logger; - sleep(10); struct timespec start_time; + //for test + struct timespec start_time1; + clock_gettime(CLOCK_MONOTONIC, &start_time1); + //for test while(1) { + //for test + struct timespec end_time; + clock_gettime(CLOCK_MONOTONIC, &end_time); + long long cost_time; + cost_time = end_time.tv_sec - start_time1.tv_sec; + printf("cost time is %d\n", cost_time); + if(cost_time > 600) break; + //for test + char buff[MGW_PACKET_MAX]; int len = mgw_tun_read(handle->tun_handle, buff, MGW_PACKET_MAX); if(len < 0) @@ -338,12 +349,20 @@ static void mgw_run(struct mgw_handle *handle) } if(rtn == MGW_FORWORD) { + //for test + int rtn = mgw_tun_write(handle->tun_handle, buff, len); + if(rtn < 0 || rtn != len) + { + continue; + } + /* normal int rtn = send_data_to_mrl(handle->_udp_client_handle, buff, len, mrl_ip); if(rtn > 0 && rtn == len) { FS_operate(g_fs_handle->handle, g_fs_handle->field_tx_to_mrl, 0, FS_OP_ADD, 1); } continue; + */ } // rtn=MGW_BYPASS, do sant_src_convert clock_gettime(CLOCK_MONOTONIC, &start_time); |
