增加tfe_cmsg工具类,用于序列化/反序列化控制信息

This commit is contained in:
崔一鸣
2019-05-29 14:36:26 +08:00
committed by luqiuwen
parent a4f23f73e9
commit 1b872c246d
4 changed files with 293 additions and 1 deletions

36
common/include/tfe_cmsg.h Normal file
View File

@@ -0,0 +1,36 @@
#pragma once
#define TFE_CMSG_TLV_NR_MAX 64
struct tfe_cmsg;
struct tfe_cmsg_serialize_header;
enum tfe_cmsg_errno
{
TFE_CMSG_INVALID_FORMAT = -1,
TFE_CMSG_BUFF_NOT_ENOUGH = -2,
TFE_CMSG_INVALID_TYPE = -3
};
enum tfe_cmsg_tlv_type
{
TCP_RESTORE_INFO_TLV_SEQ = 0,
TCP_RESTORE_INFO_TLV_ACK,
TCP_RESTORE_INFO_TLV_MSS_CLIENT,
TCP_RESTORE_INFO_TLV_MSS_SERVER,
TCP_RESTORE_INFO_TLV_WSACLE_CLIENT,
TCP_RESTORE_INFO_TLV_WSACLE_SERVER,
TCP_RESTORE_INFO_TLV_SACK_CLIENT,
TCP_RESTORE_INFO_TLV_SACK_SERVER,
TCP_RESTORE_INFO_TLV_TS_CLIENT,
TCP_RESTORE_INFO_TLV_TS_SERVER,
TCP_RESTORE_INFO_TLV_USER_DEFINED
};
struct tfe_cmsg* tfe_cmsg_init();
void tfe_cmsg_destroy(struct tfe_cmsg *cmsg);
int tfe_cmsg_get(struct tfe_cmsg *cmsg, uint16_t type, uint16_t *size, unsigned char **pvalue);
int tfe_cmsg_set(struct tfe_cmsg *cmsg, uint16_t type, const unsigned char *value, uint16_t size);
uint16_t tfe_cmsg_serialize_size_get(struct tfe_cmsg *cmsg);
int tfe_cmsg_serialize(struct tfe_cmsg *cmsg, unsigned char *buff, uint16_t bufflen, uint16_t *serialize_len);
int tfe_cmsg_deserialize(const unsigned char *data, uint16_t len, struct tfe_cmsg** pcmsg);