|
|
@@ -4,6 +4,7 @@
|
|
|
#include "callroute_request.h"
|
|
|
#include "callroute_nodelist.h"
|
|
|
#include "SpBase.h"
|
|
|
+#include "../include/EventCode.h"
|
|
|
|
|
|
#ifdef RVC_OS_WIN
|
|
|
#include <process.h>
|
|
|
@@ -39,13 +40,14 @@ typedef int SOCKET;
|
|
|
static int get_sys_time(char* pDst, size_t iLen)
|
|
|
{
|
|
|
int iret = 0;
|
|
|
-#ifdef _WIN32||_WIN64
|
|
|
+ if (NULL == pDst) {
|
|
|
+ return iret;
|
|
|
+ }
|
|
|
+
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
SYSTEMTIME sys;
|
|
|
GetLocalTime( &sys );
|
|
|
_snprintf(pDst, iLen, "%04d%02d%02d%02d%02d%02d",sys.wYear, sys.wMonth, sys.wDay, sys.wHour, sys.wMinute, sys.wSecond);
|
|
|
- if (NULL != pDst){
|
|
|
- iret = strlen(pDst);
|
|
|
- }
|
|
|
#else
|
|
|
struct tm* t;
|
|
|
time_t tt;
|
|
|
@@ -53,6 +55,7 @@ static int get_sys_time(char* pDst, size_t iLen)
|
|
|
t = localtime(&tt);
|
|
|
_snprintf(pDst, iLen, "%04d%02d%02d%02d%02d%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
|
|
|
#endif
|
|
|
+ iret = strlen(pDst);
|
|
|
return iret;
|
|
|
}
|
|
|
|
|
|
@@ -100,7 +103,7 @@ static int request_voipgateway_address(call_info_t *call_info, proxy_rsp_packet_
|
|
|
SOCKET client_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
|
struct timeval timeout = { 2,0 };
|
|
|
if (set_socket_attribute(client_socket, timeout)){
|
|
|
- Dbg("request_voipgateway_address set_socket_attribute failed.");
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_CONNECT_FAILED, "request_voipgateway_address set_socket_attribute failed.");
|
|
|
return ret;
|
|
|
}
|
|
|
if (INVALID_SOCKET != client_socket){
|
|
|
@@ -108,8 +111,10 @@ static int request_voipgateway_address(call_info_t *call_info, proxy_rsp_packet_
|
|
|
sa.sin_family = AF_INET;
|
|
|
sa.sin_addr.s_addr = inet_addr(call_info->callroute_server_ip.GetData());
|
|
|
sa.sin_port = htons(call_info->callroute_server_port);
|
|
|
- memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
|
|
|
- Dbg("dest addr is %s:%d.", call_info->callroute_server_ip.GetData(), call_info->callroute_server_port);
|
|
|
+ memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
|
|
|
+ char strmsg[256] = { 0 };
|
|
|
+ _snprintf(strmsg, 256, "dest route addr is %s:%d.", call_info->callroute_server_ip.GetData(), call_info->callroute_server_port);
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_ADDRESS, strmsg);
|
|
|
//控制为非阻塞方式
|
|
|
#ifdef RVC_OS_WIN
|
|
|
ioctlsocket(client_socket, FIONBIO, &mode);
|
|
|
@@ -149,28 +154,26 @@ static int request_voipgateway_address(call_info_t *call_info, proxy_rsp_packet_
|
|
|
#else
|
|
|
close(client_socket);
|
|
|
#endif // RVC_OS_WIN
|
|
|
- Dbg("request_voipgateway_address connect callroute server timeout(%d).", errno);
|
|
|
+ char strerror[256];
|
|
|
+ _snprintf(strerror, 256, "request_voipgateway_address connect callroute server timeout(%d).", errno);
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_CONNECT_FAILED, strerror);
|
|
|
return ret; //超时
|
|
|
}
|
|
|
-
|
|
|
reset_buffer(&req_info, 0x20, sizeof(proxy_req_packet_t));
|
|
|
itimelen = get_sys_time(strtime, RVC_DATALEN);
|
|
|
if (0 < itimelen){
|
|
|
fill_packet(&req_info, call_info->szdest_num, call_info->szcaller_num, call_info->szbranchno, strtime);
|
|
|
}
|
|
|
-
|
|
|
ret = send(client_socket, (const char*)(&req_info), len, 0);
|
|
|
-
|
|
|
if (ret <= 0){
|
|
|
#ifdef RVC_OS_WIN
|
|
|
closesocket(client_socket);
|
|
|
#else
|
|
|
close(client_socket);
|
|
|
#endif // RVC_OS_WIN
|
|
|
- Dbg("request_voipgateway_address send to callroute server failed.");
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_FAILED, "request_voipgateway_address send to callroute server failed.");
|
|
|
return ret;
|
|
|
}
|
|
|
-
|
|
|
ret = recv(client_socket, (char*)rsp_packet, rsp_len, 0);
|
|
|
|
|
|
#ifdef RVC_OS_WIN
|
|
|
@@ -179,11 +182,10 @@ static int request_voipgateway_address(call_info_t *call_info, proxy_rsp_packet_
|
|
|
close(client_socket);
|
|
|
#endif // RVC_OS_WIN
|
|
|
if (ret <= 0){
|
|
|
- Dbg("request_voipgateway_address recv from callroute server failed.");
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_FAILED, "request_voipgateway_address recv from callroute server failed.");
|
|
|
return ret;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@@ -200,8 +202,10 @@ static bool is_response_packet_valid(proxy_rsp_packet_t* packet_info)
|
|
|
memcpy(packgelen, packet_info->req_hdr.packgelen, 4);
|
|
|
memcpy(tradefrom, packet_info->req_hdr.tradefrom, 3);
|
|
|
memcpy(requestcode, packet_info->req_hdr.requestcode, 16);
|
|
|
- Dbg("get mediaserver address from callroute server failed, rsp packgelen:%s, tradefrom:%s, requestcode:%s!",
|
|
|
+ char strmsg[256] = { 0 };
|
|
|
+ _snprintf(strmsg, 256, "get mediaserver address from callroute server failed, rsp packgelen:%s, tradefrom:%s, requestcode:%s!",
|
|
|
packgelen,tradefrom, requestcode);
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_FAILED, strmsg);
|
|
|
}else{
|
|
|
bret = true;
|
|
|
}
|
|
|
@@ -243,6 +247,7 @@ static unsigned int separate_string_string(char *buf, const char *delim, char **
|
|
|
|
|
|
static node_list_head_t *create_node_list_by_callernum(call_info_t *call_info, proxy_rsp_packet_t* packet_info)
|
|
|
{
|
|
|
+
|
|
|
node_list_head_t *phead = NULL;
|
|
|
char new_touri[RVC_DATALEN]={0};
|
|
|
char strinterip[RVC_DATALEN]={0};
|
|
|
@@ -251,7 +256,6 @@ static node_list_head_t *create_node_list_by_callernum(call_info_t *call_info, p
|
|
|
if (NULL == call_info || NULL == packet_info){
|
|
|
return NULL;
|
|
|
}
|
|
|
-
|
|
|
if (is_response_packet_valid(packet_info)){
|
|
|
if (0 == fifter_sparate_flag(packet_info)){
|
|
|
char *dp[10] = {NULL};
|
|
|
@@ -278,15 +282,18 @@ static node_list_head_t *create_node_list_by_callernum(call_info_t *call_info, p
|
|
|
get_interger_netaddr(strinterip, RVC_DATALEN, packet_info->rsp_body.video_content_ip);
|
|
|
_snprintf(new_caller_number, RVC_DATALEN, "%s%s%s",
|
|
|
call_info->szcaller_num.GetData(), "#", strinterip);
|
|
|
-
|
|
|
- Dbg("new callroute node: new_caller_number:%s new_touri:%s, assist_ip:%s, assist_port:%s!",
|
|
|
+ char strmsg[256] = { 0 };
|
|
|
+ _snprintf(strmsg, 256,"new callroute node: new_caller_number:%s new_touri:%s, assist_ip:%s, assist_port:%s!",
|
|
|
new_caller_number, new_touri, packet_info->rsp_body.video_content_ip, packet_info->rsp_body.video_content_port);
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_FAILED, strmsg);
|
|
|
add_node_to_list(phead, new_caller_number, new_touri, packet_info->rsp_body.video_content_ip, packet_info->rsp_body.video_content_port);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
- Dbg("create_node_list_by_callernum failed. szbranchno:%s, szcaller_num:%s, szdest_num:%s.", call_info->szbranchno.GetData(), call_info->szcaller_num.GetData(), call_info->szdest_num.GetData());
|
|
|
+ char strerror[256] = { 0 };
|
|
|
+ _snprintf(strerror, 256, "create_node_list_by_callernum failed. szbranchno:%s, szcaller_num:%s, szdest_num:%s.", call_info->szbranchno.GetData(), call_info->szcaller_num.GetData(), call_info->szdest_num.GetData());
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_FAILED, strerror);
|
|
|
}
|
|
|
|
|
|
return phead;
|
|
|
@@ -303,17 +310,17 @@ node_list_head_t *get_callroute_list(call_info_t *call_info)
|
|
|
call_info->szdest_num.GetLength() == 0 ||
|
|
|
call_info->szcaller_num.GetLength() == 0 ||
|
|
|
call_info->szbranchno.GetLength() == 0) {
|
|
|
- Dbg("get_callroute_list failed call_info param is null.");
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_FAILED, "get_callroute_list failed call_info param is null.");
|
|
|
return NULL;
|
|
|
}
|
|
|
-
|
|
|
reset_buffer(&rsp_info, 0x20, sizeof(proxy_rsp_packet_t));
|
|
|
ret = request_voipgateway_address(call_info, &rsp_info, recvlen);
|
|
|
if (ret <= 0){
|
|
|
- Dbg("get_callroute_list failed szbranchno:%s, szcaller_num:%s, szdest_num:%s.", call_info->szbranchno.GetData(), call_info->szcaller_num.GetData(), call_info->szdest_num.GetData());
|
|
|
+ char strmsg[256] = { 0 };
|
|
|
+ _snprintf(strmsg, 256, "get_callroute_list failed szbranchno:%s, szcaller_num:%s, szdest_num:%s.", call_info->szbranchno.GetData(), call_info->szcaller_num.GetData(), call_info->szdest_num.GetData());
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_WARN_COUNTERCONNECT_CALLROUTE_FAILED, strmsg);
|
|
|
return NULL;
|
|
|
}
|
|
|
-
|
|
|
return create_node_list_by_callernum(call_info, &rsp_info);
|
|
|
}
|
|
|
|