mirror of
https://github.com/lxsang/antd-tunnel-publishers
synced 2024-12-26 01:48:21 +01:00
disable header check
This commit is contained in:
parent
a8979c48dc
commit
831eacf889
BIN
dist/antd-publishers-0.1.0a.tar.gz
vendored
BIN
dist/antd-publishers-0.1.0a.tar.gz
vendored
Binary file not shown.
8
tunnel.c
8
tunnel.c
@ -101,11 +101,13 @@ int open_unix_socket(char* path)
|
|||||||
|
|
||||||
int msg_read(int fd, tunnel_msg_t* msg)
|
int msg_read(int fd, tunnel_msg_t* msg)
|
||||||
{
|
{
|
||||||
|
#ifdef VERIFY_HEADER
|
||||||
if(msg_check_number(fd, MSG_MAGIC_BEGIN) == -1)
|
if(msg_check_number(fd, MSG_MAGIC_BEGIN) == -1)
|
||||||
{
|
{
|
||||||
M_ERROR(MODULE_NAME, "Unable to check begin magic number");
|
M_ERROR(MODULE_NAME, "Unable to check begin magic number");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if(read(fd,&msg->header.type,sizeof(msg->header.type)) == -1)
|
if(read(fd,&msg->header.type,sizeof(msg->header.type)) == -1)
|
||||||
{
|
{
|
||||||
M_ERROR(MODULE_NAME, "Unable to read msg type: %s", strerror(errno));
|
M_ERROR(MODULE_NAME, "Unable to read msg type: %s", strerror(errno));
|
||||||
@ -131,6 +133,7 @@ int msg_read(int fd, tunnel_msg_t* msg)
|
|||||||
M_ERROR(MODULE_NAME, "Unable to read msg payload data");
|
M_ERROR(MODULE_NAME, "Unable to read msg payload data");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef VERIFY_HEADER
|
||||||
if(msg_check_number(fd, MSG_MAGIC_END) == -1)
|
if(msg_check_number(fd, MSG_MAGIC_END) == -1)
|
||||||
{
|
{
|
||||||
if(msg->data)
|
if(msg->data)
|
||||||
@ -140,11 +143,13 @@ int msg_read(int fd, tunnel_msg_t* msg)
|
|||||||
M_ERROR(MODULE_NAME, "Unable to check end magic number");
|
M_ERROR(MODULE_NAME, "Unable to check end magic number");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int msg_write(int fd, tunnel_msg_t* msg)
|
int msg_write(int fd, tunnel_msg_t* msg)
|
||||||
{
|
{
|
||||||
|
#ifdef VERIFY_HEADER
|
||||||
// write begin magic number
|
// write begin magic number
|
||||||
int number = MSG_MAGIC_BEGIN;
|
int number = MSG_MAGIC_BEGIN;
|
||||||
if(write(fd,&number, sizeof(number)) == -1)
|
if(write(fd,&number, sizeof(number)) == -1)
|
||||||
@ -152,6 +157,7 @@ int msg_write(int fd, tunnel_msg_t* msg)
|
|||||||
M_ERROR(MODULE_NAME, "Unable to write begin magic number: %s", strerror(errno));
|
M_ERROR(MODULE_NAME, "Unable to write begin magic number: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// write type
|
// write type
|
||||||
if(write(fd,&msg->header.type, sizeof(msg->header.type)) == -1)
|
if(write(fd,&msg->header.type, sizeof(msg->header.type)) == -1)
|
||||||
{
|
{
|
||||||
@ -186,11 +192,13 @@ int msg_write(int fd, tunnel_msg_t* msg)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef VERIFY_HEADER
|
||||||
number = MSG_MAGIC_END;
|
number = MSG_MAGIC_END;
|
||||||
if(write(fd,&number, sizeof(number)) == -1)
|
if(write(fd,&number, sizeof(number)) == -1)
|
||||||
{
|
{
|
||||||
M_ERROR(MODULE_NAME, "Unable to write end magic number: %s", strerror(errno));
|
M_ERROR(MODULE_NAME, "Unable to write end magic number: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
2
tunnel.h
2
tunnel.h
@ -6,8 +6,10 @@
|
|||||||
#define MAX_CHANNEL_PATH 108
|
#define MAX_CHANNEL_PATH 108
|
||||||
#define MAX_CHANNEL_NAME 64
|
#define MAX_CHANNEL_NAME 64
|
||||||
|
|
||||||
|
#ifdef VERIFY_HEADER
|
||||||
#define MSG_MAGIC_BEGIN 0x414e5444 //ANTD
|
#define MSG_MAGIC_BEGIN 0x414e5444 //ANTD
|
||||||
#define MSG_MAGIC_END 0x44544e41 //DTNA
|
#define MSG_MAGIC_END 0x44544e41 //DTNA
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CHANNEL_OK (uint8_t)0x0
|
#define CHANNEL_OK (uint8_t)0x0
|
||||||
#define CHANNEL_ERROR (uint8_t)0x1
|
#define CHANNEL_ERROR (uint8_t)0x1
|
||||||
|
Loading…
Reference in New Issue
Block a user