summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-05-23 02:43:50 +0800
committeryangwei <[email protected]>2024-05-23 02:43:50 +0800
commita47b3b5a6eaf56b38edb31998555c2c62fb17ac2 (patch)
treeaa47786ab0c1380ad301d0282c6f63a2faa26c83
parent9d75d5eb6898b068904fed3c3c544dece7f5e057 (diff)
✨ feat(stream opt): 支持按方向获取会话上的SIDv4.3.56
-rw-r--r--include/public/stream_inc/stream_control.h53
-rw-r--r--src/dealpkt/plug_support.c24
2 files changed, 47 insertions, 30 deletions
diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h
index 0b53511..cee6b1f 100644
--- a/include/public/stream_inc/stream_control.h
+++ b/include/public/stream_inc/stream_control.h
@@ -67,6 +67,8 @@ enum MESA_stream_opt{
MSO_IP_TTL_S2C, /* opt_val type must be unsigned char, IPv4 is TTL, IPv6 is Hop Limit */
MSO_TCP_RTT_CSC, /* opt_val type must be unsigned short, the full RTT is client->tsg->server->tsg->client, this is |tsg->server->tsg| */
MSO_TCP_RTT_SCS, /* opt_val type must be unsigned short, the full RTT is server->tsg->client->tsg->server, this is |tsg->client->tsg| */
+ MSO_STREAM_C2S_SEGMENT_ID_LIST,
+ MSO_STREAM_S2C_SEGMENT_ID_LIST,
__MSO_MAX,
};
@@ -162,8 +164,8 @@ enum stream_timer_return_value{
};
-#define MAX_TCP_OPT_LEN (38) /* TCP头部长度最长为60字节, 去除标准头部剩余选项部分最�?40字节, 选项数据部分最�?38字节 */
-#define MAX_TCP_OPT_NUM (20) /* 单个TCP包最大选项数量 */
+#define MAX_TCP_OPT_LEN (38) /* TCP max hdr length 60Bytes, set max opt length 38 Bytes */
+#define MAX_TCP_OPT_NUM (20)
enum tcp_option_value{
TCP_OPT_EOL = 0,
@@ -210,21 +212,16 @@ struct tcp_option_ext{
} __attribute__((packed, aligned(1)));
-/* 2018-10-24 lijia add, for pangu 项目mac_in_mac回流.
- 理论�?, sapp平台不应该关心和业务密切相关的东�?, 比如mac里哪个字段是link_id, 哪个是dev_id,
- 但这个玩意太底层�?, 平台借用GDEV发送RST包也要填充这些�?, 必须平台处理!!
-*/
-/* 为了方便业务插件获取mac_in_mac地址里的具体信息, 不再使用原始的bit位域, 转换成变量形�? */
struct vxlan_info{
- unsigned char encap_type; /* 原始二层封装格式 */
- unsigned char entrance_id; /* 设备所在出入口ID */
- unsigned char dev_id; /* 设备ID */
- unsigned char link_id; /* 链路ID */
- unsigned char link_dir; /* 链路方向, 指当前四元组的IP被捕获时的传输方�?, 对于TCP, SYN包的传输方向; 对于UDP, 端口大IP的传输方�? */
- unsigned char inner_smac[18]; /* 内层真实SMAC, string类型, �?: "11:22:33:44:55:66" */
- unsigned char inner_dmac[18]; /* 内层真实DMAC, string类型, �?: "11:22:33:44:55:66" */
- unsigned char inner_smac_hex[6]; /* 内层真实SMAC, 原始二进制类�? */
- unsigned char inner_dmac_hex[6]; /* 内层真实DMAC, 原始二进制类�? */
+ unsigned char encap_type;
+ unsigned char entrance_id;
+ unsigned char dev_id;
+ unsigned char link_id;
+ unsigned char link_dir;
+ unsigned char inner_smac[18]; /*string, "11:22:33:44:55:66" */
+ unsigned char inner_dmac[18]; /* string, "11:22:33:44:55:66" */
+ unsigned char inner_smac_hex[6]; /* hex */
+ unsigned char inner_dmac_hex[6]; /* hex */
};
@@ -342,14 +339,11 @@ int sapp_get_device_opt(const char *device, enum sapp_device_opt opt_type, void
/***************************************************************************************
NOTE:
- 在被动模式下, 插件无需关心route_dir的绝对�?, 只需要理解同向和反向即可,
- 但主动发包必须要精确理解route_dir�?0还是1, 因外界网络拓扑模式不�?, 可能随时会变�?,
- 所以设置此接口, 插件只需传入人易理解的方向human_dir, 返回当前链路的link route dir,
- 注意首次部署�?, etc/sapp.toml->inbound_route_dir一定要设置正确.
+ convernt by etc/sapp.toml->inbound_route_dir.
- args: 表示发包目标相对于当前设备所在的地理位置,
- 'E' or 'e': 表示数据包传输方向是从Internal to External.
- 'I' or 'i': 表示数据包传输方向是从External to Internal.
+ args:
+ 'E' or 'e': Internal to External.
+ 'I' or 'i': External to Internal.
return value:
0 or 1: success.
@@ -359,20 +353,19 @@ int MESA_dir_human_to_link(int human_dir);
/*
args:
- 链路传输方向: 0�?1, 通常来自stream->routedir;
+ 0 or 1, stream->routedir;
- 返回�?:
- 'E' or 'e': 表示数据包传输方向是从Internal to External.
- 'I' or 'i': 表示数据包传输方向是从External to Internal.
- 'x': 参数错误;
+ return value:
+ 'E' or 'e': Internal to External.
+ 'I' or 'i': External to Internal.
+ 'x': error;
*/
int MESA_dir_link_to_human(int link_route_dir);
/****************************************************************************************
- CHN : 因为历史遗留问题,此类函数保留仅为向后兼容,请使用新接口:MESA_set_stream_opt().
- ENG : for compat old version, keep these functions, but we suggest you use new API MESA_set_stream_opt().
+ for compat old version, keep these functions, but we suggest you use new API MESA_set_stream_opt().
*****************************************************************************************/
int tcp_set_single_stream_max_unorder(const struct streaminfo *stream, unsigned char dir, unsigned short unorder_num);
int tcp_set_single_stream_needack(const struct streaminfo *pstream);
diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c
index a90720e..6358187 100644
--- a/src/dealpkt/plug_support.c
+++ b/src/dealpkt/plug_support.c
@@ -1998,6 +1998,30 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
}
break;
+ case MSO_STREAM_C2S_SEGMENT_ID_LIST:
+ case MSO_STREAM_S2C_SEGMENT_ID_LIST:
+ {
+ ret = -1;
+ *opt_val_len = 0;
+ void **value = (void **)opt_val;
+ struct rawpkt_metadata *meta = NULL;
+ if (opt == MSO_STREAM_C2S_SEGMENT_ID_LIST)
+ {
+ meta = pstream_pr->polling_inject_context->meta_stream_dir[DIR_C2S - 1];
+ }
+ else
+ {
+ meta = pstream_pr->polling_inject_context->meta_stream_dir[DIR_S2C - 1];
+ }
+ if (meta)
+ {
+ *value = (void *)(&meta->raw_sid_list);
+ *opt_val_len = sizeof(struct segment_id_list);
+ ret = *opt_val_len;
+ }
+ }
+ break;
+
case MSO_IP_TTL_C2S:
if(0 == pstream_pr->ip_ttl_c2s){
ret = -1;