|
@@ -566,7 +566,7 @@ static int on_recv(bizchan_t *chan, SOCKET conn)
|
|
|
result = (n < 0 || (errno == EWOULDBLOCK) || (errno == EINTR) || (errno == EAGAIN)) ? 0 : -1;
|
|
|
}
|
|
|
|
|
|
- bizlog(chan, 0, "on_recv n:%d, result:%d, errno:%d", n, result, errno);
|
|
|
+ bizlog(chan, "on_recv n:%d, result:%d, errno:%d", n, result, errno);
|
|
|
return result;
|
|
|
#endif
|
|
|
}
|
|
@@ -606,7 +606,7 @@ static int on_send(bizchan_t *chan, SOCKET conn)
|
|
|
t->need_encrypt = 0;
|
|
|
}
|
|
|
n = send(conn, t->buf+t->sended, t->left, 0);
|
|
|
- bizlog(chan, 0, "on_send n:%d, t->sended:%d, t->left:%d", n, t->sended, t->left);
|
|
|
+ bizlog(chan, "on_send n:%d, t->sended:%d, t->left:%d", n, t->sended, t->left);
|
|
|
if (n > 0) {
|
|
|
char tmp[32];
|
|
|
sprintf(tmp, "send out %d bytes!\n", n);
|
|
@@ -960,10 +960,10 @@ static void do_shake_send(bizchan_t* chan, SOCKET conn, int* error) {
|
|
|
#if ENCRYPT_CHINA
|
|
|
EncWithSM4_ECB(seed_key, (unsigned char*)&chan->local_pwd[0], KEY_LEN / 2,
|
|
|
(unsigned char*)&hdr.encrypt_key[0], &enc_length);
|
|
|
- bizlog(chan, 0, "use SM4 password_crypt_type");
|
|
|
+ bizlog(chan, "use SM4 password_crypt_type");
|
|
|
#else
|
|
|
encodefun((unsigned char*)&hdr.encrypt_key[0], sizeof(hdr.encrypt_key), (unsigned char*)&chan->local_pwd[0], sizeof(chan->local_pwd));
|
|
|
- Dbg(chan, 0, "use old password_crypt_type");
|
|
|
+ bizlog(chan, "use old password_crypt_type");
|
|
|
#endif
|
|
|
hdr.encrypt_keyhash = hash_key(chan->local_pwd, sizeof(chan->local_pwd));
|
|
|
memset(hdr.callee_id, ' ', sizeof(hdr.callee_id));
|
|
@@ -1009,23 +1009,23 @@ static void do_shake_recv(bizchan_t* chan, SOCKET conn, int* error) {
|
|
|
int result = DecWithSM4_ECB(seed_key,
|
|
|
(unsigned char*)&ack_hdr.encrypt_key[0], sizeof(ack_hdr.encrypt_key),
|
|
|
(unsigned char*)&chan->remote_pwd[0], &dec_length);
|
|
|
- bizlog(chan, 0, "use SM4 Decode password result:%d", result);
|
|
|
+ bizlog(chan, "use SM4 Decode password result:%d", result);
|
|
|
if (result != 0) {
|
|
|
result = decodefun((unsigned char*)&chan->remote_pwd[0], sizeof(chan->remote_pwd), (unsigned char*)&ack_hdr.encrypt_key[0], sizeof(ack_hdr.encrypt_key));
|
|
|
- bizlog(chan, 0, "use old Decode password result:%d", result);
|
|
|
+ bizlog(chan, "use old Decode password result:%d", result);
|
|
|
}
|
|
|
if (check_hash(chan->remote_pwd, sizeof(chan->remote_pwd), ack_hdr.encrypt_keyhash)) {
|
|
|
chan->remote_video_rtp_port = ack_hdr.rtp_port;
|
|
|
chan->remote_video_desc = ack_hdr.media_desc;
|
|
|
memcpy(chan->remote_client_id, ack_hdr.client_id, sizeof(chan->remote_client_id));
|
|
|
chan->remote_version = ack_hdr.version;
|
|
|
- bizlog(chan, 0, "remote_acm_version:%d", chan->remote_version);
|
|
|
+ bizlog(chan, "remote_acm_version:%d", chan->remote_version);
|
|
|
chan->connected = TRUE;
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
*error = -1;
|
|
|
- bizlog(chan, 0, "do_shake_recv check_hash failed");
|
|
|
+ bizlog(chan, "do_shake_recv check_hash failed");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -1037,8 +1037,8 @@ static void do_shake_recv(bizchan_t* chan, SOCKET conn, int* error) {
|
|
|
#else
|
|
|
if (t <= 0 && ((errno != EWOULDBLOCK) || (errno != EINTR) || (errno != EAGAIN))) {
|
|
|
*error = -1;
|
|
|
- bizlog(chan, 0, "do_shake_recv errno:%d", errno);
|
|
|
- bizlog(chan, 0, "do_shake_recv t<=0 failed");
|
|
|
+ bizlog(chan, "do_shake_recv errno:%d", errno);
|
|
|
+ bizlog(chan, "do_shake_recv t<=0 failed");
|
|
|
}
|
|
|
#endif
|
|
|
}
|
|
@@ -1094,7 +1094,7 @@ SOCKET connect_server(bizchan_t* chan, char* server, int port, int timeout)
|
|
|
#else
|
|
|
close(m_hSocket);
|
|
|
#endif
|
|
|
- bizlog(chan, 0, "connect_server set_socket_noblock failed");
|
|
|
+ bizlog(chan, "connect_server set_socket_noblock failed");
|
|
|
}
|
|
|
|
|
|
addrSrv.sin_family = AF_INET;
|
|
@@ -1102,7 +1102,7 @@ SOCKET connect_server(bizchan_t* chan, char* server, int port, int timeout)
|
|
|
addrSrv.sin_port = htons(port);
|
|
|
int ret = connect(m_hSocket, (struct sockaddr*)&addrSrv, sizeof(addrSrv));
|
|
|
if (ret == 0) {
|
|
|
- bizlog(chan, 0, "connect_server connect success 1.");
|
|
|
+ bizlog(chan, "connect_server connect success 1.");
|
|
|
return m_hSocket;
|
|
|
}
|
|
|
#ifdef RVC_OS_WIN
|
|
@@ -1115,7 +1115,7 @@ SOCKET connect_server(bizchan_t* chan, char* server, int port, int timeout)
|
|
|
//linux下需要检测EINPROGRESS和EINTR
|
|
|
if (ret < 0 && (errno != EINPROGRESS && errno != EINTR)) {
|
|
|
close(m_hSocket);
|
|
|
- bizlog(chan, 0, "connect_server connect failed, errno: %d", errno);
|
|
|
+ bizlog(chan, "connect_server connect failed, errno: %d", errno);
|
|
|
return INVALID_SOCKET;
|
|
|
}
|
|
|
#endif
|
|
@@ -1133,11 +1133,11 @@ SOCKET connect_server(bizchan_t* chan, char* server, int port, int timeout)
|
|
|
#else
|
|
|
close(m_hSocket);
|
|
|
#endif
|
|
|
- bizlog(chan, 0, "connect_server connect timeout.");
|
|
|
+ bizlog(chan, "connect_server connect timeout.");
|
|
|
return INVALID_SOCKET;
|
|
|
}
|
|
|
|
|
|
- bizlog(chan, 0, "connect_server connect success 2.");
|
|
|
+ bizlog(chan, "connect_server connect success 2.");
|
|
|
return m_hSocket;
|
|
|
}
|
|
|
|
|
@@ -1174,7 +1174,7 @@ static void process(bizchan_t* chan) {
|
|
|
#else
|
|
|
do_shake_send(chan, conn, &error);
|
|
|
if (error != 0) {
|
|
|
- bizlog(chan, 0, "do_shake_send failed");
|
|
|
+ bizlog(chan, "do_shake_send failed");
|
|
|
goto on_error;
|
|
|
}
|
|
|
while (!chan->stop_flag && !chan->connected) {
|
|
@@ -1187,13 +1187,13 @@ static void process(bizchan_t* chan) {
|
|
|
int activity = select(maxfd + 1, &read_fds, NULL, &except_fds, &tv);
|
|
|
if (activity == -1) {
|
|
|
perror("select()");
|
|
|
- bizlog(chan, 0, "process shake select -1");
|
|
|
+ bizlog(chan, "process shake select -1");
|
|
|
goto on_error;
|
|
|
}
|
|
|
else if (activity == 0) {
|
|
|
// timeout
|
|
|
printf("select() returns 0.\n");
|
|
|
- bizlog(chan, 0, "process shake select 0");
|
|
|
+ bizlog(chan, "process shake select 0");
|
|
|
goto on_error;
|
|
|
}else {
|
|
|
/* All fd_set's should be checked. */
|
|
@@ -1205,7 +1205,7 @@ static void process(bizchan_t* chan) {
|
|
|
char pipe_read_buffer[4];
|
|
|
int n = read(chan->evt[0], pipe_read_buffer, 4);
|
|
|
if (n < 0) {
|
|
|
- bizlog(chan, 0, "process shake pipe read < 0");
|
|
|
+ bizlog(chan, "process shake pipe read < 0");
|
|
|
}
|
|
|
}
|
|
|
if (FD_ISSET(conn, &except_fds)) {
|
|
@@ -1221,7 +1221,7 @@ static void process(bizchan_t* chan) {
|
|
|
|
|
|
if (chan->connected)
|
|
|
{
|
|
|
- char buffer[128];
|
|
|
+ char buffer[128] = {0};
|
|
|
int rc;
|
|
|
|
|
|
invoke_on_connect(chan, 0);
|
|
@@ -1286,11 +1286,11 @@ static void process(bizchan_t* chan) {
|
|
|
break;
|
|
|
}
|
|
|
else {
|
|
|
- bizlog(chan, 0, "pipe read < 0");
|
|
|
+ bizlog(chan, "pipe read < 0");
|
|
|
}
|
|
|
}
|
|
|
if (FD_ISSET(conn, &except_fds)) {
|
|
|
- bizlog(chan, 0, "select() except_fds set.");
|
|
|
+ bizlog(chan, "select() except_fds set.");
|
|
|
error = -1;
|
|
|
}
|
|
|
if (error != 0) {
|
|
@@ -1303,7 +1303,7 @@ static void process(bizchan_t* chan) {
|
|
|
|
|
|
on_error:
|
|
|
//OutputDebugStringA("on_error");
|
|
|
- bizlog(chan, 0, "on_error");
|
|
|
+ bizlog(chan, "on_error");
|
|
|
|
|
|
if (!chan->connected) {
|
|
|
invoke_on_connect(chan, -1); // connect failed!
|
|
@@ -1311,7 +1311,7 @@ on_error:
|
|
|
else {
|
|
|
//....
|
|
|
//OutputDebugStringA("connected, and error!");
|
|
|
- bizlog(chan, 0, "connected, and error!");
|
|
|
+ bizlog(chan, "connected, and error!");
|
|
|
}
|
|
|
|
|
|
if (conn != INVALID_SOCKET) {
|
|
@@ -1339,7 +1339,7 @@ static void* work_proc(void* arg)
|
|
|
//....
|
|
|
}
|
|
|
#else
|
|
|
- bizlog(chan, 0, "work_proc start");
|
|
|
+ bizlog(chan, "work_proc start");
|
|
|
process(chan);
|
|
|
#endif
|
|
|
return 0;
|
|
@@ -1629,8 +1629,9 @@ BIZCHAN_API(int) bizchan_post_pkt(bizchan_t *chan, int type, int compress, int e
|
|
|
{
|
|
|
send_buf_node *t;
|
|
|
|
|
|
- if (!chan->connected)
|
|
|
+ if (!chan->connected) {
|
|
|
return -1;
|
|
|
+ }
|
|
|
|
|
|
t = (send_buf_node *)malloc(sizeof(send_buf_node));
|
|
|
|
|
@@ -1674,7 +1675,8 @@ BIZCHAN_API(int) bizchan_post_pkt(bizchan_t *chan, int type, int compress, int e
|
|
|
hdr->hash = hash_key(pkt, pkt_size);
|
|
|
memcpy(&hdr->data[0], pkt, pkt_size);
|
|
|
t->need_encrypt = encrypt;
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
qlz_state_compress state_compress;
|
|
|
acm_hdr *hdr;
|
|
|
int new_pkt_size;
|
|
@@ -1713,8 +1715,6 @@ BIZCHAN_API(int) bizchan_post_pkt(bizchan_t *chan, int type, int compress, int e
|
|
|
write(chan->evt[1], "post", sizeof("post"));
|
|
|
#endif
|
|
|
|
|
|
-
|
|
|
-
|
|
|
return 0;
|
|
|
}
|
|
|
|