TSG-14568 tsg-service-chaining-engine支持MAAT4
This commit is contained in:
@@ -22,8 +22,8 @@ struct ctrl_pkt_parser
|
||||
uint64_t session_id;
|
||||
enum session_state state;
|
||||
char method[32];
|
||||
int policy_ids[32];
|
||||
int policy_id_num;
|
||||
uint64_t rule_ids[32];
|
||||
int rule_id_num;
|
||||
};
|
||||
|
||||
const char *session_state_to_string(enum session_state state);
|
||||
|
||||
@@ -31,26 +31,29 @@ extern "C"
|
||||
* fixed_num_array
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct fixed_num_array
|
||||
{
|
||||
int elems[128];
|
||||
uint64_t elems[128];
|
||||
int num;
|
||||
int size;
|
||||
};
|
||||
|
||||
void fixed_num_array_init(struct fixed_num_array *array);
|
||||
void fixed_num_array_add_elem(struct fixed_num_array *array, int elem);
|
||||
void fixed_num_array_del_elem(struct fixed_num_array *array, int elem);
|
||||
void fixed_num_array_add_elem(struct fixed_num_array *array, uint64_t elem);
|
||||
void fixed_num_array_del_elem(struct fixed_num_array *array, uint64_t elem);
|
||||
int fixed_num_array_is_full(struct fixed_num_array *array);
|
||||
int fixed_num_array_count_elem(struct fixed_num_array *array);
|
||||
int fixed_num_array_exist_elem(struct fixed_num_array *array, int elem);
|
||||
int fixed_num_array_exist_elem(struct fixed_num_array *array, uint64_t elem);
|
||||
int fixed_num_array_index_elem(struct fixed_num_array *array, int index);
|
||||
|
||||
/******************************************************************************
|
||||
* sids
|
||||
******************************************************************************/
|
||||
|
||||
#include <marsio.h>
|
||||
typedef uint16_t sid_t;
|
||||
#define MR_SID_LIST_MAXLEN 8
|
||||
|
||||
struct sids
|
||||
{
|
||||
|
||||
@@ -126,7 +126,7 @@ int ctrl_packet_parser_parse(struct ctrl_pkt_parser *handler, const char *data,
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
handler->policy_id_num = MIN(cJSON_GetArraySize(item), (int)(sizeof(handler->policy_ids) / sizeof(handler->policy_ids[0])));
|
||||
handler->rule_id_num = MIN(cJSON_GetArraySize(item), (int)(sizeof(handler->rule_ids) / sizeof(handler->rule_ids[0])));
|
||||
cJSON_ArrayForEach(elem, item)
|
||||
{
|
||||
if (!cJSON_IsNumber(elem))
|
||||
@@ -134,10 +134,10 @@ int ctrl_packet_parser_parse(struct ctrl_pkt_parser *handler, const char *data,
|
||||
LOG_ERROR("%s: unexpected control packet: (invalid service_chaining value) %s", LOG_TAG_POLICY, data);
|
||||
continue;
|
||||
}
|
||||
handler->policy_ids[iter] = elem->valueint;
|
||||
handler->rule_ids[iter] = elem->valueint;
|
||||
iter++;
|
||||
|
||||
if (iter == handler->policy_id_num)
|
||||
if (iter == handler->rule_id_num)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -160,11 +160,11 @@ void ctrl_packet_parser_dump(struct ctrl_pkt_parser *handler)
|
||||
LOG_INFO("%s: session_id : %lu", LOG_TAG_POLICY, handler->session_id);
|
||||
LOG_INFO("%s: state : %s", LOG_TAG_POLICY, session_state_to_string(handler->state));
|
||||
LOG_INFO("%s: method : %s", LOG_TAG_POLICY, handler->method);
|
||||
LOG_INFO("%s: policy_id_num : %d", LOG_TAG_POLICY, handler->policy_id_num);
|
||||
LOG_INFO("%s: rule_id_num : %d", LOG_TAG_POLICY, handler->rule_id_num);
|
||||
|
||||
for (int i = 0; i < handler->policy_id_num; i++)
|
||||
for (int i = 0; i < handler->rule_id_num; i++)
|
||||
{
|
||||
LOG_INFO("%s: policy_ids[%03d] : %i", LOG_TAG_POLICY, i, handler->policy_ids[i]);
|
||||
LOG_INFO("%s: rule_ids[%03d] : %lu", LOG_TAG_POLICY, i, handler->rule_ids[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void fixed_num_array_init(struct fixed_num_array *array)
|
||||
array->size = sizeof(array->elems) / sizeof(array->elems[0]);
|
||||
}
|
||||
|
||||
void fixed_num_array_add_elem(struct fixed_num_array *array, int elem)
|
||||
void fixed_num_array_add_elem(struct fixed_num_array *array, uint64_t elem)
|
||||
{
|
||||
if (array->num < array->size)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ void fixed_num_array_add_elem(struct fixed_num_array *array, int elem)
|
||||
}
|
||||
}
|
||||
|
||||
void fixed_num_array_del_elem(struct fixed_num_array *array, int elem)
|
||||
void fixed_num_array_del_elem(struct fixed_num_array *array, uint64_t elem)
|
||||
{
|
||||
for (int i = 0; i < array->num; i++)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ int fixed_num_array_count_elem(struct fixed_num_array *array)
|
||||
}
|
||||
}
|
||||
|
||||
int fixed_num_array_exist_elem(struct fixed_num_array *array, int elem)
|
||||
int fixed_num_array_exist_elem(struct fixed_num_array *array, uint64_t elem)
|
||||
{
|
||||
for (int i = 0; i < array->num; i++)
|
||||
{
|
||||
|
||||
@@ -16,10 +16,10 @@ TEST(CTRL_PACKET, PARSE)
|
||||
EXPECT_TRUE(parser.session_id == 123456789);
|
||||
EXPECT_TRUE(parser.state == SESSION_STATE_ACTIVE);
|
||||
EXPECT_STREQ(parser.method, "policy_update");
|
||||
EXPECT_TRUE(parser.policy_id_num == 3);
|
||||
EXPECT_TRUE(parser.policy_ids[0] == 1);
|
||||
EXPECT_TRUE(parser.policy_ids[1] == 2);
|
||||
EXPECT_TRUE(parser.policy_ids[2] == 3);
|
||||
EXPECT_TRUE(parser.rule_id_num == 3);
|
||||
EXPECT_TRUE(parser.rule_ids[0] == 1);
|
||||
EXPECT_TRUE(parser.rule_ids[1] == 2);
|
||||
EXPECT_TRUE(parser.rule_ids[2] == 3);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
||||
Reference in New Issue
Block a user