From 4136cc36713a6ab39811dc5cdb78cc8f516d3410 Mon Sep 17 00:00:00 2001 From: luwenpeng Date: Fri, 21 Apr 2023 19:06:12 +0800 Subject: [PATCH] =?UTF-8?q?TSG-13837=20decrypted=20traffic=20steering?= =?UTF-8?q?=E9=80=82=E9=85=8Dmrzcpd=E6=96=B0=E5=A2=9EMR=5FBUFF=5FUSER=5F0?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/src/packet_io.cpp | 29 ++++++++++++++++++++--------- test/marsio.cpp | 11 +++++++++++ test/marsio.h | 3 ++- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/platform/src/packet_io.cpp b/platform/src/packet_io.cpp index e572c7e..033c692 100644 --- a/platform/src/packet_io.cpp +++ b/platform/src/packet_io.cpp @@ -15,12 +15,13 @@ #include "ctrl_packet.h" #include "global_metrics.h" +#define RX_BURST_MAX 128 +#define MR_MASK_DECRYPTED 0x01 + /****************************************************************************** * struct ******************************************************************************/ -#define RX_BURST_MAX 128 - struct config { int bypass_all_traffic; @@ -91,13 +92,20 @@ int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta) else { meta->is_ctrl_pkt = 0; -#if 0 - if (marsio_buff_get_metadata(rx_buff, MR_IS_DECRYPTED, &(meta->is_decrypted), sizeof(meta->is_decrypted)) <= 0) + uint16_t user_data = 0; + if (marsio_buff_get_metadata(rx_buff, MR_BUFF_USER_0, &user_data, sizeof(user_data)) <= 0) { LOG_ERROR("%s: unable to get is_decrypted from metadata", LOG_TAG_PKTIO); return -1; } -#endif + if (user_data & MR_MASK_DECRYPTED) + { + meta->is_decrypted = 1; + } + else + { + meta->is_decrypted = 0; + } } meta->sids.num = marsio_buff_get_sid_list(rx_buff, meta->sids.elems, sizeof(meta->sids.elems) / sizeof(meta->sids.elems[0])); @@ -143,14 +151,17 @@ int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta) } else { - // TODO -#if 0 - if (marsio_buff_set_metadata(tx_buff, MR_IS_DECRYPTED, &(meta->is_decrypted), sizeof(meta->is_decrypted)) != 0) + uint16_t user_data = 0; + if (meta->is_decrypted) + { + user_data = MR_MASK_DECRYPTED; + } + + if (marsio_buff_set_metadata(tx_buff, MR_BUFF_USER_0, &user_data, sizeof(user_data)) != 0) { LOG_ERROR("%s: unable to set is_decrypted for metadata", LOG_TAG_PKTIO); return -1; } -#endif } if (meta->sids.num > 0) diff --git a/test/marsio.cpp b/test/marsio.cpp index 1a6c974..bda26b9 100644 --- a/test/marsio.cpp +++ b/test/marsio.cpp @@ -55,6 +55,7 @@ struct mrb_metadata uint16_t port_egress; uint16_t link_db_index; + uint16_t user_data_0; }; struct mock_marsio_buff_t @@ -171,6 +172,9 @@ int marsio_buff_set_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, case MR_BUFF_PAYLOAD_OFFSET: mrb_metadata->payload_offset = *(uint16_t *)data; return 0; + case MR_BUFF_USER_0: + mrb_metadata->user_data_0 = *(uint16_t *)data; + return 0; default: return -1; } @@ -224,6 +228,13 @@ int marsio_buff_get_metadata(marsio_buff_t *m, enum mr_buff_metadata_type type, } *(uint16_t *)(data) = (uint16_t)mrb_metadata->payload_offset; return sizeof(uint16_t); + case MR_BUFF_USER_0: + if (sz_data < sizeof(uint16_t)) + { + return -1; + } + *(uint16_t *)(data) = (uint16_t)mrb_metadata->user_data_0; + return sizeof(uint16_t); default: return -1; } diff --git a/test/marsio.h b/test/marsio.h index 3ea0dc2..516c824 100644 --- a/test/marsio.h +++ b/test/marsio.h @@ -38,7 +38,8 @@ enum mr_buff_metadata_type MR_BUFF_ROUTE_CTX = 2, MR_BUFF_SESSION_ID = 3, MR_BUFF_DIR = 4, - MR_BUFF_PAYLOAD_OFFSET = 5 + MR_BUFF_PAYLOAD_OFFSET = 5, + MR_BUFF_USER_0 = 254, }; struct mr_instance *marsio_create();