static int test_validate_tlv16_list(void) { of_flow_modify_t *obj = of_flow_modify_new(OF_VERSION_1_0); of_list_action_t list; of_action_set_tp_dst_t element1; of_action_output_t element2; of_message_t msg; of_flow_modify_actions_bind(obj, &list); of_action_set_tp_dst_init(&element1, OF_VERSION_1_0, -1, 1); of_list_action_append_bind(&list, (of_action_t *)&element1); of_action_output_init(&element2, OF_VERSION_1_0, -1, 1); of_list_action_append_bind(&list, (of_action_t *)&element2); msg = OF_OBJECT_TO_MESSAGE(obj); TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == 0); of_message_length_set(msg, of_message_length_get(msg) - 1); TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == -1); of_message_length_set(msg, of_message_length_get(msg) + 2); TEST_ASSERT(of_validate_message(msg, of_message_length_get(msg)) == -1); of_flow_modify_delete(obj); return TEST_PASS; }
SimpleForwardingModule::SimpleForwardingModule( uint64_t instanceId) : AbstractModule(zmf::data::ModuleUniqueId(MODULE_TYPE_ID, instanceId), MODULE_VERSION, "SimpleForwardingModule", {{deviceMgrDependencyType_, deviceMgrDependencyVersion_}}) { tempPacketOut_OF_1_0 = of_packet_out_new(OF_VERSION_1_0); tempPacketOut_OF_1_3 = of_packet_out_new(OF_VERSION_1_3); of_packet_out_buffer_id_set(tempPacketOut_OF_1_0, OF_BUFFER_ID_NO_BUFFER); of_packet_out_buffer_id_set(tempPacketOut_OF_1_3, OF_BUFFER_ID_NO_BUFFER); tempActionList_OF_1_0 = of_list_action_new(OF_VERSION_1_0); tempActionList_OF_1_3 = of_list_action_new(OF_VERSION_1_3); tempOutPut_OF_1_0 = of_action_output_new(OF_VERSION_1_0); tempOutPut_OF_1_3 = of_action_output_new(OF_VERSION_1_3); of_list_action_append_bind(tempActionList_OF_1_0, tempOutPut_OF_1_0); of_list_action_append_bind(tempActionList_OF_1_3, tempOutPut_OF_1_3); //of_port_no_t port_no = destinationDevice->switchPort; //of_action_output_port_set(output, port_no); of_packet_out_actions_set(tempPacketOut_OF_1_0, tempActionList_OF_1_0); of_packet_out_actions_set(tempPacketOut_OF_1_3, tempActionList_OF_1_3); };
/* Generated from of10/echo_request.data */ static int test_of10_echo_request(void) { uint8_t binary[] = { 0x01, 0x02, 0x00, 0x0b, 0x12, 0x34, 0x56, 0x78, 0x61, 0x62, 0x01, }; of_object_t *obj; obj = of_echo_request_new(OF_VERSION_1_0); of_echo_request_xid_set(obj, 0x12345678); { of_octets_t data = { .data=(uint8_t *)"ab\x01", .bytes=3 }; of_echo_request_data_set(obj, &data); } if (sizeof(binary) != WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj)) || memcmp(binary, WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), sizeof(binary))) { show_failure(binary, sizeof(binary), WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj))); of_object_delete(obj); return TEST_FAIL; } of_object_delete(obj); return TEST_PASS; } /* Generated from of10/flow_add.data */ static int test_of10_flow_add(void) { uint8_t binary[] = { 0x01, 0x0e, 0x00, 0x70, 0x12, 0x34, 0x56, 0x78, 0x00, 0x30, 0x00, 0xe2, 0x00, 0x03, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x03, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0xff, 0xfb, 0x00, 0x00, 0xff, 0xff, 0x00, 0x10, 0x00, 0x00, 0x23, 0x20, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x10, 0x00, 0x5c, 0x16, 0xc7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, }; of_object_t *obj; obj = of_flow_add_new(OF_VERSION_1_0); of_flow_add_xid_set(obj, 0x12345678); of_flow_add_idle_timeout_set(obj, 5); of_flow_add_flags_set(obj, 2); { of_match_t match = { OF_VERSION_1_0 }; match.fields.in_port = 3; match.fields.eth_src = (of_mac_addr_t) { { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab } }; match.fields.eth_dst = (of_mac_addr_t) { { 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67 } }; match.fields.eth_type = 0x800; match.fields.ipv4_src = 0xc0a8037f; match.fields.ipv4_dst = 0xffffffff; OF_MATCH_MASK_IN_PORT_EXACT_SET(&match); OF_MATCH_MASK_ETH_SRC_EXACT_SET(&match); OF_MATCH_MASK_ETH_DST_EXACT_SET(&match); OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match); //OF_MATCH_MASK_VLAN_VID_EXACT_SET(&match); //OF_MATCH_MASK_VLAN_PCP_EXACT_SET(&match); OF_MATCH_MASK_ETH_TYPE_EXACT_SET(&match); //OF_MATCH_MASK_IP_DSCP_EXACT_SET(&match); //OF_MATCH_MASK_IP_PROTO_EXACT_SET(&match); OF_MATCH_MASK_IPV4_SRC_EXACT_SET(&match); OF_MATCH_MASK_IPV4_DST_EXACT_SET(&match); //OF_MATCH_MASK_TCP_SRC_EXACT_SET(&match); //OF_MATCH_MASK_TCP_DST_EXACT_SET(&match); of_flow_add_match_set(obj, &match); } { of_list_action_t actions; of_flow_add_actions_bind(obj, &actions); { of_action_t action; of_action_output_init(&action.output, OF_VERSION_1_0, -1, 1); of_list_action_append_bind(&actions, &action); of_action_output_port_set(&action.output, OF_PORT_DEST_FLOOD); } { of_action_t action; of_action_nicira_dec_ttl_init(&action.nicira_dec_ttl, OF_VERSION_1_0, -1, 1); of_list_action_append_bind(&actions, &action); } { of_action_t action; of_action_bsn_set_tunnel_dst_init(&action.bsn_set_tunnel_dst, OF_VERSION_1_0, -1, 1); of_list_action_append_bind(&actions, &action); } } if (sizeof(binary) != WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj)) || memcmp(binary, WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), sizeof(binary))) { show_failure(binary, sizeof(binary), WBUF_BUF(OF_OBJECT_TO_WBUF(obj)), WBUF_CURRENT_BYTES(OF_OBJECT_TO_WBUF(obj))); of_object_delete(obj); return TEST_FAIL; } of_object_delete(obj); return TEST_PASS; }