本文整理汇总了C++中TEST_ASSERT_NOT_NULL_MESSAGE函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST_ASSERT_NOT_NULL_MESSAGE函数的具体用法?C++ TEST_ASSERT_NOT_NULL_MESSAGE怎么用?C++ TEST_ASSERT_NOT_NULL_MESSAGE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST_ASSERT_NOT_NULL_MESSAGE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_match_basic_IPV4_SCTP_DST
void
test_match_basic_IPV4_SCTP_DST(void) {
struct lagopus_packet *pkt;
struct port port;
struct flow *flow;
OS_MBUF *m;
bool rv;
/* prepare packet */
pkt = alloc_lagopus_packet();
TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
m = pkt->mbuf;
OS_M_APPEND(m, 64);
/* prepare flow */
flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
TAILQ_INIT(&flow->match_list);
add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
0x08, 0x00);
OS_MTOD(m, uint8_t *)[12] = 0x81;
OS_MTOD(m, uint8_t *)[13] = 0x00;
OS_MTOD(m, uint8_t *)[16] = 0x08;
OS_MTOD(m, uint8_t *)[17] = 0x00;
OS_MTOD(m, uint8_t *)[18] = 0x45;
add_match(&flow->match_list, 1, OFPXMT_OFB_IP_PROTO << 1,
IPPROTO_SCTP);
OS_MTOD(m, uint8_t *)[27] = IPPROTO_SCTP;
/* SCTP_DST */
add_match(&flow->match_list, 2, OFPXMT_OFB_SCTP_DST << 1,
0, 80);
OS_MTOD(m, uint8_t *)[40] = 80;
OS_MTOD(m, uint8_t *)[41] = 0;
refresh_match(flow);
lagopus_packet_init(pkt, m, &port);
rv = match_basic(pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, false,
"SCTP_DST mismatch error.");
OS_MTOD(m, uint8_t *)[40] = 0;
OS_MTOD(m, uint8_t *)[41] = 80;
lagopus_packet_init(pkt, m, &port);
rv = match_basic(pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, true,
"SCTP_DST match error.");
free(m);
}
示例2: test_port_add
void
test_port_add(void) {
struct vector *ports;
struct port port;
lagopus_result_t rv;
ports = ports_alloc();
TEST_ASSERT_NOT_NULL_MESSAGE(ports, "ports_alloc error");
strncpy(port.ofp_port.name, "port1", sizeof(port.ofp_port.name));
port.ofp_port.port_no = 1;
port.ifindex = 120;
port.type = LAGOPUS_PORT_TYPE_NULL;
rv = port_add(ports, &port);
TEST_ASSERT_EQUAL_MESSAGE(rv, LAGOPUS_RESULT_OK, "port_add error");
}
示例3: test_set_field_IPV6_SCTP_SRC
void
test_set_field_IPV6_SCTP_SRC(void) {
struct port port;
struct action_list action_list;
struct action *action;
struct ofp_action_set_field *action_set;
struct lagopus_packet *pkt;
OS_MBUF *m;
TAILQ_INIT(&action_list);
action = calloc(1, sizeof(*action) + 64);
action_set = (struct ofp_action_set_field *)&action->ofpat;
action_set->type = OFPAT_SET_FIELD;
lagopus_set_action_function(action);
TAILQ_INSERT_TAIL(&action_list, action, entry);
pkt = alloc_lagopus_packet();
TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
m = PKT2MBUF(pkt);
OS_M_PKTLEN(m) = 128;
OS_MTOD(m, uint8_t *)[12] = 0x86;
OS_MTOD(m, uint8_t *)[13] = 0xdd;
OS_MTOD(m, uint8_t *)[20] = IPPROTO_SCTP;
lagopus_packet_init(pkt, m, &port);
set_match(action_set->field, 2, OFPXMT_OFB_SCTP_SRC << 1,
0x80, 0x21);
execute_action(pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[54], 0x80,
"SET_FIELD IPV6_SCTP_SRC[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[55], 0x21,
"SET_FIELD IPV6_SCTP_SRC[1] error.");
OS_MTOD(m, uint8_t *)[20] = IPPROTO_DSTOPTS;
OS_MTOD(m, uint8_t *)[54] = IPPROTO_SCTP;
OS_MTOD(m, uint8_t *)[55] = 0;
lagopus_packet_init(pkt, m, &port);
execute_action(pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[54], IPPROTO_SCTP,
"SET_FIELD IPV6_SCTP_SRC proto error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[62], 0x80,
"SET_FIELD IPV6_SCTP_SRC[0](next hdr) error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[63], 0x21,
"SET_FIELD IPV6_SCTP_SRC[1](next hdr) error.");
}
示例4: test_set_field_IPV6_SCTP_DST
void
test_set_field_IPV6_SCTP_DST(void) {
struct port port;
struct action_list action_list;
struct action *action;
struct ofp_action_set_field *action_set;
struct lagopus_packet pkt;
OS_MBUF *m;
TAILQ_INIT(&action_list);
action = calloc(1, sizeof(*action) + 64);
action_set = (struct ofp_action_set_field *)&action->ofpat;
action_set->type = OFPAT_SET_FIELD;
lagopus_set_action_function(action);
TAILQ_INSERT_TAIL(&action_list, action, entry);
m = calloc(1, sizeof(*m));
TEST_ASSERT_NOT_NULL_MESSAGE(m, "calloc error.");
m->data = &m->dat[128];
OS_M_PKTLEN(m) = 128;
m->data[12] = 0x86;
m->data[13] = 0xdd;
m->data[20] = IPPROTO_SCTP;
lagopus_packet_init(&pkt, m, &port);
set_match(action_set->field, 2, OFPXMT_OFB_SCTP_DST << 1,
0x80, 0x21);
execute_action(&pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(m->data[56], 0x80,
"SET_FIELD IPV6_SCTP_DST[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(m->data[57], 0x21,
"SET_FIELD IPV6_SCTP_DST[1] error.");
m->data[20] = IPPROTO_DSTOPTS;
m->data[54] = IPPROTO_SCTP;
m->data[55] = 0;
lagopus_packet_init(&pkt, m, &port);
execute_action(&pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(m->data[54], IPPROTO_SCTP,
"SET_FIELD IPV6_SCTP_DST proto error.");
TEST_ASSERT_EQUAL_MESSAGE(m->data[64], 0x80,
"SET_FIELD IPV6_SCTP_DST[0](next hdr) error.");
TEST_ASSERT_EQUAL_MESSAGE(m->data[65], 0x21,
"SET_FIELD IPV6_SCTP_DST[1](next hdr) error.");
}
示例5: test_match_basic_IPV4_SCTP_SRC
void
test_match_basic_IPV4_SCTP_SRC(void) {
struct lagopus_packet pkt;
struct port port;
struct flow *flow;
OS_MBUF *m;
bool rv;
/* prepare packet */
pkt.in_port = &port;
m = calloc(1, sizeof(*m));
TEST_ASSERT_NOT_NULL_MESSAGE(m, "calloc error.");
m->data = &m->dat[128];
OS_M_PKTLEN(m) = 64;
/* prepare flow */
flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
TAILQ_INIT(&flow->match_list);
add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
0x08, 0x00);
m->data[12] = 0x81;
m->data[13] = 0x00;
m->data[16] = 0x08;
m->data[17] = 0x00;
m->data[18] = 0x45;
add_match(&flow->match_list, 1, OFPXMT_OFB_IP_PROTO << 1,
IPPROTO_SCTP);
m->data[27] = IPPROTO_SCTP;
/* SCTP_SRC */
add_match(&flow->match_list, 2, OFPXMT_OFB_SCTP_SRC << 1,
0xf0, 0x00);
m->data[38] = 0;
m->data[39] = 0xf0;
refresh_match(flow);
lagopus_packet_init(&pkt, m);
rv = match_basic(&pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, false,
"SCTP_SRC mismatch error.");
m->data[38] = 0xf0;
m->data[39] = 0x00;
rv = match_basic(&pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, true,
"SCTP_SRC match error.");
free(m);
}
示例6: test_controller_conf_delete_not_initialize
void
test_controller_conf_delete_not_initialize(void) {
lagopus_result_t rc;
controller_conf_t *conf = NULL;
const char *name = "controller_name";
rc = controller_conf_create(&conf, name);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
TEST_ASSERT_NOT_NULL_MESSAGE(conf, "conf_create() will create new controller");
rc = controller_conf_delete(conf);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_NOT_STARTED, rc);
controller_conf_destroy(conf);
controller_finalize();
}
示例7: test_controller_attr_public_channel_name
void
test_controller_attr_public_channel_name(void) {
lagopus_result_t rc;
controller_conf_t *conf = NULL;
const char *name = "controller_name";
char *actual_channel_name = NULL;
const char *expected_channel_name = "";
controller_initialize();
rc = controller_conf_create(&conf, name);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
TEST_ASSERT_NOT_NULL_MESSAGE(conf, "conf_create() will create new controller");
rc = controller_conf_add(conf);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
// Normal case of getter
{
rc = datastore_controller_get_channel_name(name, true, &actual_channel_name);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_OBJECT, rc);
rc = datastore_controller_get_channel_name(name, false, &actual_channel_name);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
TEST_ASSERT_EQUAL_STRING(expected_channel_name, actual_channel_name);
}
// Abnormal case of getter
{
rc = datastore_controller_get_channel_name(NULL, true, &actual_channel_name);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
rc = datastore_controller_get_channel_name(NULL, false, &actual_channel_name);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
rc = datastore_controller_get_channel_name(name, true, NULL);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
rc = datastore_controller_get_channel_name(name, false, NULL);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
}
free((void *)actual_channel_name);
controller_finalize();
}
示例8: test_set_field_ARP_SPA
void
test_set_field_ARP_SPA(void) {
struct port port;
struct action_list action_list;
struct action *action;
struct ofp_action_set_field *action_set;
struct lagopus_packet *pkt;
OS_MBUF *m;
TAILQ_INIT(&action_list);
action = calloc(1, sizeof(*action) + 64);
action_set = (struct ofp_action_set_field *)&action->ofpat;
action_set->type = OFPAT_SET_FIELD;
lagopus_set_action_function(action);
TAILQ_INSERT_TAIL(&action_list, action, entry);
pkt = alloc_lagopus_packet();
TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
m = pkt->mbuf;
OS_M_APPEND(m, 64);
OS_MTOD(m, uint8_t *)[12] = 0x08;
OS_MTOD(m, uint8_t *)[13] = 0x06;
OS_MTOD(m, uint8_t *)[20] = 0x00;
OS_MTOD(m, uint8_t *)[21] = ARPOP_REQUEST;
OS_MTOD(m, uint8_t *)[28] = 172;
OS_MTOD(m, uint8_t *)[29] = 21;
OS_MTOD(m, uint8_t *)[30] = 0;
OS_MTOD(m, uint8_t *)[31] = 1;
lagopus_packet_init(pkt, m, &port);
set_match(action_set->field, 4, OFPXMT_OFB_ARP_SPA << 1,
192, 168, 1, 2);
execute_action(pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[28], 192,
"SET_FIELD ARP_SPA[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[29], 168,
"SET_FIELD ARP_SPA[1] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[30], 1,
"SET_FIELD ARP_SPA[2] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[31], 2,
"SET_FIELD ARP_SPA[3] error.");
}
示例9: test_match_basic_PBB_ISID_W
void
test_match_basic_PBB_ISID_W(void) {
struct lagopus_packet pkt;
struct port port;
struct flow *flow;
OS_MBUF *m;
bool rv;
/* prepare packet */
m = calloc(1, sizeof(*m));
TEST_ASSERT_NOT_NULL_MESSAGE(m, "calloc error.");
m->data = &m->dat[128];
OS_M_PKTLEN(m) = 64;
/* prepare flow */
flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
TAILQ_INIT(&flow->match_list);
#ifndef PBB_IS_VLAN
add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
0x88, 0xe7);
#endif
m->data[12] = 0x88;
m->data[13] = 0xe7;
add_match(&flow->match_list, 6, (OFPXMT_OFB_PBB_ISID << 1) + 1,
0x5a, 0xc3, 0x00, 0xff, 0xff, 0x00);
refresh_match(flow);
lagopus_packet_init(&pkt, m, &port);
rv = match_basic(&pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, false,
"PBB_ISID_W mismatch(1) error.");
m->data[15] = 0x3c;
m->data[16] = 0xc3;
m->data[17] = 0x5a;
rv = match_basic(&pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, false,
"PBB_ISID_W mismatch(2) error.");
m->data[15] = 0x5a;
m->data[16] = 0xc3;
m->data[17] = 0x3c;
rv = match_basic(&pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, true,
"PBB_ISID_W match error.");
}
示例10: test_set_field_IN_PORT
void
test_set_field_IN_PORT(void) {
datastore_bridge_info_t info;
struct action_list action_list;
struct bridge *bridge;
struct port *port;
struct action *action;
struct ofp_action_set_field *action_set;
struct port nport;
struct lagopus_packet pkt;
OS_MBUF *m;
/* setup bridge and port */
memset(&info, 0, sizeof(info));
info.fail_mode = DATASTORE_BRIDGE_FAIL_MODE_SECURE;
TEST_ASSERT_EQUAL(dp_bridge_create("br0", &info), LAGOPUS_RESULT_OK);
TEST_ASSERT_EQUAL(dp_port_create("port0"), LAGOPUS_RESULT_OK);
TEST_ASSERT_EQUAL(dp_port_create("port1"), LAGOPUS_RESULT_OK);
TEST_ASSERT_EQUAL(dp_bridge_port_set("br0", "port0", 1), LAGOPUS_RESULT_OK);
TEST_ASSERT_EQUAL(dp_bridge_port_set("br0", "port1", 2), LAGOPUS_RESULT_OK);
TAILQ_INIT(&action_list);
action = calloc(1, sizeof(*action) + 64);
action_set = (struct ofp_action_set_field *)&action->ofpat;
action_set->type = OFPAT_SET_FIELD;
lagopus_set_action_function(action);
TAILQ_INSERT_TAIL(&action_list, action, entry);
m = calloc(1, sizeof(*m));
TEST_ASSERT_NOT_NULL_MESSAGE(m, "calloc error.");
m->data = &m->dat[128];
bridge = dp_bridge_lookup("br0");
TEST_ASSERT_NOT_NULL(bridge);
pkt.in_port = port_lookup(bridge->ports, 1);
TEST_ASSERT_NOT_NULL(pkt.in_port);
lagopus_packet_init(&pkt, m);
set_match(action_set->field, 4, OFPXMT_OFB_IN_PORT << 1,
0x00, 0x00, 0x00, 0x02);
execute_action(&pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(pkt.in_port->ofp_port.port_no, 2,
"SET_FIELD IN_PORT error.");
}
示例11: test_set_field_ETH_TYPE
void
test_set_field_ETH_TYPE(void) {
struct port port;
struct action_list action_list;
struct action *action;
struct ofp_action_set_field *action_set;
struct lagopus_packet pkt;
OS_MBUF *m;
TAILQ_INIT(&action_list);
action = calloc(1, sizeof(*action) + 64);
action_set = (struct ofp_action_set_field *)&action->ofpat;
action_set->type = OFPAT_SET_FIELD;
lagopus_set_action_function(action);
TAILQ_INSERT_TAIL(&action_list, action, entry);
m = calloc(1, sizeof(*m));
TEST_ASSERT_NOT_NULL_MESSAGE(m, "calloc error.");
m->data = &m->dat[128];
OS_M_PKTLEN(m) = 64;
m->data[12] = 0x08;
m->data[13] = 0x00;
lagopus_packet_init(&pkt, m, &port);
set_match(action_set->field, 2, OFPXMT_OFB_ETH_TYPE << 1,
0x20, 0xf1);
execute_action(&pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(m->data[12], 0x20,
"SET_FIELD ETH_TYPE[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(m->data[13], 0xf1,
"SET_FIELD ETH_TYPE[1] error.");
m->data[12] = 0x81;
m->data[13] = 0x00;
lagopus_packet_init(&pkt, m, &port);
execute_action(&pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(m->data[16], 0x20,
"SET_FIELD(vlan) ETH_TYPE[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(m->data[17], 0xf1,
"SET_FIELD(vlan) ETH_TYPE[1] error.");
}
示例12: test_controller_attr_public_role
void
test_controller_attr_public_role(void) {
lagopus_result_t rc;
controller_conf_t *conf = NULL;
const char *name = "controller_name";
datastore_controller_role_t actual_role = DATASTORE_CONTROLLER_ROLE_UNKNOWN;
const datastore_controller_role_t expected_role = actual_role;
controller_initialize();
rc = controller_conf_create(&conf, name);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
TEST_ASSERT_NOT_NULL_MESSAGE(conf, "conf_create() will create new controller");
rc = controller_conf_add(conf);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
// Normal case of getter
{
rc = datastore_controller_get_role(name, true, &actual_role);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_OBJECT, rc);
rc = datastore_controller_get_role(name, false, &actual_role);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_OK, rc);
TEST_ASSERT_EQUAL_UINT32(expected_role, actual_role);
}
// Abnormal case of getter
{
rc = datastore_controller_get_role(NULL, true, &actual_role);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
rc = datastore_controller_get_role(NULL, false, &actual_role);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
rc = datastore_controller_get_role(name, true, NULL);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
rc = datastore_controller_get_role(name, false, NULL);
TEST_ASSERT_EQUAL(LAGOPUS_RESULT_INVALID_ARGS, rc);
}
controller_finalize();
}
示例13: test_pop_vlan
void
test_pop_vlan(void) {
struct port port;
struct action_list action_list;
struct action *action;
struct ofp_action_pop_mpls *action_pop;
struct lagopus_packet *pkt;
OS_MBUF *m;
TAILQ_INIT(&action_list);
action = calloc(1, sizeof(*action));
action_pop = (struct ofp_action_pop_mpls *)&action->ofpat;
action_pop->type = OFPAT_POP_VLAN;
lagopus_set_action_function(action);
TAILQ_INSERT_TAIL(&action_list, action, entry);
pkt = alloc_lagopus_packet();
TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
m = pkt->mbuf;
OS_M_APPEND(m, 64 + 4);
OS_MTOD(m, uint8_t *)[12] = 0x81;
OS_MTOD(m, uint8_t *)[13] = 0x00;
OS_MTOD(m, uint8_t *)[14] = 0x30;
OS_MTOD(m, uint8_t *)[15] = 50;
OS_MTOD(m, uint8_t *)[16] = 0x08;
OS_MTOD(m, uint8_t *)[17] = 0x00;
OS_MTOD(m, uint8_t *)[18] = 0x45;
OS_MTOD(m, uint8_t *)[26] = 240;
lagopus_packet_init(pkt, m, &port);
execute_action(pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(OS_M_PKTLEN(m), 64,
"POP_VLAN length error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x08,
"POP_VLAN ethertype[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0x00,
"POP_VLAN ethertype[1] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[14], 0x45,
"POP_VLAN ip_vhl error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[22], 240,
"POP_VLAN ip_ttl error.");
}
示例14: test_match_basic_PBB_ISID_W
void
test_match_basic_PBB_ISID_W(void) {
struct lagopus_packet *pkt;
struct port port;
struct flow *flow;
OS_MBUF *m;
bool rv;
/* prepare packet */
pkt = alloc_lagopus_packet();
TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
m = PKT2MBUF(pkt);
OS_M_APPEND(m, 64);
/* prepare flow */
flow = calloc(1, sizeof(struct flow) + 10 * sizeof(struct match));
TAILQ_INIT(&flow->match_list);
#ifndef PBB_IS_VLAN
add_match(&flow->match_list, 2, OFPXMT_OFB_ETH_TYPE << 1,
0x88, 0xe7);
#endif
OS_MTOD(m, uint8_t *)[12] = 0x88;
OS_MTOD(m, uint8_t *)[13] = 0xe7;
add_match(&flow->match_list, 6, (OFPXMT_OFB_PBB_ISID << 1) + 1,
0x5a, 0xc3, 0x00, 0xff, 0xff, 0x00);
refresh_match(flow);
lagopus_packet_init(pkt, m, &port);
rv = match_basic(pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, false,
"PBB_ISID_W mismatch(1) error.");
OS_MTOD(m, uint8_t *)[15] = 0x3c;
OS_MTOD(m, uint8_t *)[16] = 0xc3;
OS_MTOD(m, uint8_t *)[17] = 0x5a;
rv = match_basic(pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, false,
"PBB_ISID_W mismatch(2) error.");
OS_MTOD(m, uint8_t *)[15] = 0x5a;
OS_MTOD(m, uint8_t *)[16] = 0xc3;
OS_MTOD(m, uint8_t *)[17] = 0x3c;
rv = match_basic(pkt, flow);
TEST_ASSERT_EQUAL_MESSAGE(rv, true,
"PBB_ISID_W match error.");
}
示例15: test_set_field_ETH_TYPE
void
test_set_field_ETH_TYPE(void) {
struct port port;
struct action_list action_list;
struct action *action;
struct ofp_action_set_field *action_set;
struct lagopus_packet *pkt;
OS_MBUF *m;
TAILQ_INIT(&action_list);
action = calloc(1, sizeof(*action) + 64);
action_set = (struct ofp_action_set_field *)&action->ofpat;
action_set->type = OFPAT_SET_FIELD;
lagopus_set_action_function(action);
TAILQ_INSERT_TAIL(&action_list, action, entry);
pkt = alloc_lagopus_packet();
TEST_ASSERT_NOT_NULL_MESSAGE(pkt, "lagopus_alloc_packet error.");
m = PKT2MBUF(pkt);
OS_M_APPEND(m, 64);
OS_MTOD(m, uint8_t *)[12] = 0x08;
OS_MTOD(m, uint8_t *)[13] = 0x00;
lagopus_packet_init(pkt, m, &port);
set_match(action_set->field, 2, OFPXMT_OFB_ETH_TYPE << 1,
0x20, 0xf1);
execute_action(pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[12], 0x20,
"SET_FIELD ETH_TYPE[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[13], 0xf1,
"SET_FIELD ETH_TYPE[1] error.");
OS_MTOD(m, uint8_t *)[12] = 0x81;
OS_MTOD(m, uint8_t *)[13] = 0x00;
lagopus_packet_init(pkt, m, &port);
execute_action(pkt, &action_list);
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[16], 0x20,
"SET_FIELD(vlan) ETH_TYPE[0] error.");
TEST_ASSERT_EQUAL_MESSAGE(OS_MTOD(m, uint8_t *)[17], 0xf1,
"SET_FIELD(vlan) ETH_TYPE[1] error.");
}