summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2023-11-07 19:45:56 +0800
committeryangwei <[email protected]>2023-11-07 19:45:56 +0800
commitfe8e4d942aeb1930b81db04dc0c7fefcb05dfb73 (patch)
tree31b1448e50e86989455835b3495d8f21974b83cb
parentea28252c59180a42df76ee99fed966dbe590f01d (diff)
✨ feat(get rawpkt by route from streaminfo): 增加根据路由方向获取流上存储的原始包接口
-rw-r--r--include/public/stream_inc/stream_control.h1
-rw-r--r--include/public/stream_inc/stream_rawpkt.h4
-rw-r--r--src/dealpkt/plug_support.c49
3 files changed, 51 insertions, 3 deletions
diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h
index c475a56..89579f1 100644
--- a/include/public/stream_inc/stream_control.h
+++ b/include/public/stream_inc/stream_control.h
@@ -56,6 +56,7 @@ enum MESA_stream_opt{
MSO_STREAM_S2C_SYN_NUM,
MSO_STREAM_INBOND_LINK_ID,
MSO_STREAM_OUTBOND_LINK_ID,
+ MSO_STREAM_C2S_ROUTE_DIRECTION,
__MSO_MAX,
};
diff --git a/include/public/stream_inc/stream_rawpkt.h b/include/public/stream_inc/stream_rawpkt.h
index 07c5152..c54b937 100644
--- a/include/public/stream_inc/stream_rawpkt.h
+++ b/include/public/stream_inc/stream_rawpkt.h
@@ -109,7 +109,9 @@ const void *get_this_layer_header(const struct streaminfo *pstream);
*/
const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
-const void *get_rawpkt_from_streaminfo(const struct streaminfo *pstream);
+const void *get_current_rawpkt_from_streaminfo(const struct streaminfo *pstream);
+
+const void *get_rawpkt_from_streaminfo(const struct streaminfo *pstream, int route_direction);
struct detain_pkt;
struct detain_pkt* MESA_rawpkt_detain(const struct streaminfo *pstream, const void *rawpkt);
diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c
index 2ae8f62..24dc415 100644
--- a/src/dealpkt/plug_support.c
+++ b/src/dealpkt/plug_support.c
@@ -395,7 +395,7 @@ static int get_vxlan_info_from_streaminfo(const struct streaminfo_private *pstre
return ret;
}
-const void *get_rawpkt_from_streaminfo(const struct streaminfo *pstream)
+const void *get_current_rawpkt_from_streaminfo(const struct streaminfo *pstream)
{
const struct streaminfo_private *pstream_pr = (const struct streaminfo_private *)pstream;
if(pstream_pr->plugin_process_context != 0)
@@ -405,6 +405,21 @@ const void *get_rawpkt_from_streaminfo(const struct streaminfo *pstream)
return NULL;
}
+
+const void *get_rawpkt_from_streaminfo(const struct streaminfo *pstream, int route_direction)
+{
+ const struct streaminfo_private *pstream_pr = (const struct streaminfo_private *)pstream;
+ if(pstream_pr->polling_inject_context == NULL)return NULL;
+ switch (route_direction)
+ {
+ case DIR_ROUTE_UP:
+ return pstream_pr->polling_inject_context->raw_pkt_up;
+ case DIR_ROUTE_DOWN:
+ return pstream_pr->polling_inject_context->raw_pkt_down;
+ }
+ return NULL;
+}
+
const struct streaminfo *get_streaminfo_from_rawpkt(const void *rawpkt)
{
if(NULL == rawpkt)return NULL;
@@ -1688,6 +1703,29 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
case MSO_STREAM_S2C_RAWPKT_HDR:
{
const raw_pkt_t *rawpkt = NULL;
+ if(pstream_pr->stream_c2s_route_dir == DIR_ROUTE_UP)
+ {
+ if(opt == MSO_STREAM_C2S_RAWPKT_HDR)
+ {
+ rawpkt=pstream_pr->polling_inject_context->raw_pkt_up;
+ }
+ else
+ {
+ rawpkt=pstream_pr->polling_inject_context->raw_pkt_down;
+ }
+ }
+ else
+ {
+ if(opt == MSO_STREAM_C2S_RAWPKT_HDR)
+ {
+ rawpkt=pstream_pr->polling_inject_context->raw_pkt_down;
+ }
+ else
+ {
+ rawpkt=pstream_pr->polling_inject_context->raw_pkt_up;
+ }
+ }
+#if 0
if ((opt == MSO_STREAM_C2S_RAWPKT_HDR && pstream->curdir == DIR_C2S)
|| (opt == MSO_STREAM_S2C_RAWPKT_HDR && pstream->curdir == DIR_S2C))
{
@@ -1711,6 +1749,7 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
rawpkt = pstream_pr->polling_inject_context->raw_pkt_up;
}
}
+#endif
if (rawpkt != NULL)
{
*((void **)opt_val) = (void *)((const char *)rawpkt->raw_pkt_data + rawpkt->overlay_layer_bytes);
@@ -1795,7 +1834,13 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
}
}
break;
-
+ case MSO_STREAM_C2S_ROUTE_DIRECTION:
+ {
+ UCHAR *c2s_route_dir = (UCHAR *)opt_val;
+ *c2s_route_dir=pstream_pr->stream_c2s_route_dir;
+ ret=0;
+ }
+ break;
default:
sapp_runtime_log(RLOG_LV_INFO, "%s,MESA_get_stream_opt() error:unsupport MESA_stream_opt type:%d!\n",printaddr(&pstream->addr, pstream->threadnum), (int)opt);
ret = -1;