This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/common/include/tfe_cmsg.h
2020-08-21 11:58:03 +08:00

79 lines
2.6 KiB
C

#pragma once
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 information */
TFE_CMSG_TCP_RESTORE_SEQ = 0x0,
TFE_CMSG_TCP_RESTORE_ACK = 0x1,
TFE_CMSG_TCP_RESTORE_MSS_CLIENT = 0x2,
TFE_CMSG_TCP_RESTORE_MSS_SERVER = 0x3,
TFE_CMSG_TCP_RESTORE_WSACLE_CLIENT = 0x4,
TFE_CMSG_TCP_RESTORE_WSACLE_SERVER = 0x5,
TFE_CMSG_TCP_RESTORE_SACK_CLIENT = 0x6,
TFE_CMSG_TCP_RESTORE_SACK_SERVER = 0x7,
TFE_CMSG_TCP_RESTORE_TS_CLIENT = 0x8,
TFE_CMSG_TCP_RESTORE_TS_SERVER = 0x9,
TFE_CMSG_TCP_RESTORE_PROTOCOL = 0xa,
TFE_CMSG_POLICY_ID = 0x10,
TFE_CMSG_STREAM_TRACE_ID = 0x11,
TFE_CMSG_SSL_INTERCEPT_STATE, //size uint64_t, 0-passthrough, 1-intercept, 2-shutdown, referer from enum ssl_stream_action
TFE_CMSG_SSL_SERVER_SIDE_LATENCY, //size uint64_t, milisecond
TFE_CMSG_SSL_CLIENT_SIDE_LATENCY, //size uint64_t, milisecond
TFE_CMSG_SSL_SERVER_SIDE_VERSION, //string, SSLv3 TLSv1 TLSv1.1 TLSv1.2 TLSv1.3 unknown
TFE_CMSG_SSL_CLIENT_SIDE_VERSION,
TFE_CMSG_SSL_PINNING_STATE, //size uint64_t, 0-not pinning 1-pinning 2-maybe pinning
TFE_CMSG_SSL_CERT_VERIFY,
TFE_CMSG_SSL_ERROR, //string
/* Original Traffic's src & dst MAC address */
TFE_CMSG_SRC_MAC,
TFE_CMSG_DST_MAC,
/* TCP option information */
TFE_CMSG_DOWNSTREAM_TCP_NODELAY,
TFE_CMSG_DOWNSTREAM_TCP_TTL,
TFE_CMSG_DOWNSTREAM_TCP_KEEPALIVE,
TFE_CMSG_DOWNSTREAM_TCP_KEEPCNT,
TFE_CMSG_DOWNSTREAM_TCP_KEEPIDLE,
TFE_CMSG_DOWNSTREAM_TCP_KEEPINTVL,
TFE_CMSG_DOWNSTREAM_TCP_USER_TIMEOUT,
TFE_CMSG_UPSTREAM_TCP_NODELAY,
TFE_CMSG_UPSTREAM_TCP_TTL,
TFE_CMSG_UPSTREAM_TCP_KEEPALIVE,
TFE_CMSG_UPSTREAM_TCP_KEEPCNT,
TFE_CMSG_UPSTREAM_TCP_KEEPIDLE,
TFE_CMSG_UPSTREAM_TCP_KEEPINTVL,
TFE_CMSG_UPSTREAM_TCP_USER_TIMEOUT,
TFE_CMSG_TCP_PASSTHROUGH,
/* Add new cmsg here */
/* MAX cmsg num */
TFE_CMSG_TLV_NR_MAX
};
struct tfe_cmsg* tfe_cmsg_init();
void tfe_cmsg_destroy(struct tfe_cmsg *cmsg);
int tfe_cmsg_get_value(struct tfe_cmsg * cmsg, enum tfe_cmsg_tlv_type type, unsigned char * out_value,
size_t sz_out_value_buf, uint16_t * out_size);
int tfe_cmsg_set(struct tfe_cmsg * cmsg, enum tfe_cmsg_tlv_type 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);