/** * Set subtype in an object of type of_bsn_gentable_entry_desc_stats_reply. * @param obj Pointer to an object of type of_bsn_gentable_entry_desc_stats_reply. * @param subtype The value to write into the object */ void of_bsn_gentable_entry_desc_stats_reply_subtype_set( of_bsn_gentable_entry_desc_stats_reply_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_BSN_GENTABLE_ENTRY_DESC_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 20; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; }
int of_list_append_bind(of_object_t *parent, of_object_t *child) { if (parent == NULL || child == NULL || parent->wbuf == NULL) { return OF_ERROR_PARAM; } if (!of_object_can_grow(parent, parent->length + child->length)) { return OF_ERROR_RESOURCE; } object_child_attach(parent, child, parent->length, child->length); /* Update the wire length and type if needed */ of_object_wire_length_set(child, child->length); of_object_wire_type_set(child); /* Update the parent's length */ of_object_parent_length_update(parent, child->length); OF_LENGTH_CHECK_ASSERT(parent); return OF_ERROR_NONE; }
/** * Set miss_send_len in an object of type of_set_config. * @param obj Pointer to an object of type of_set_config. * @param miss_send_len The value to write into the object */ void of_set_config_miss_send_len_set( of_set_config_t *obj, uint16_t miss_send_len) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_SET_CONFIG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, miss_send_len); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set experimenter in an object of type of_experimenter_error_msg. * @param obj Pointer to an object of type of_experimenter_error_msg. * @param experimenter The value to write into the object */ void of_experimenter_error_msg_experimenter_set( of_experimenter_error_msg_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_EXPERIMENTER_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 12; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set flags in an object of type of_queue_stats_reply. * @param obj Pointer to an object of type of_queue_stats_reply. * @param flags The value to write into the object */ void of_queue_stats_reply_flags_set( of_queue_stats_reply_t *obj, uint16_t flags) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_QUEUE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 10; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, flags); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Get out_group from an object of type of_flow_modify. * @param obj Pointer to an object of type of_flow_modify. * @param out_group Pointer to the child object of type * uint32_t to be filled out. * */ void of_flow_modify_out_group_get( of_flow_modify_t *obj, uint32_t *out_group) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(IS_FLOW_MOD_SUBTYPE(obj->object_id)); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 40; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, out_group); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set value in an object of type of_oxm_icmpv6_code. * @param obj Pointer to an object of type of_oxm_icmpv6_code. * @param value The value to write into the object */ void of_oxm_icmpv6_code_value_set( of_oxm_icmpv6_code_t *obj, uint8_t value) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_OXM_ICMPV6_CODE); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u8_set(wbuf, abs_offset, value); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set burst_size in an object of type of_meter_band_drop. * @param obj Pointer to an object of type of_meter_band_drop. * @param burst_size The value to write into the object */ void of_meter_band_drop_burst_size_set( of_meter_band_drop_t *obj, uint32_t burst_size) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_METER_BAND_DROP); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 8; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, burst_size); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set experimenter in an object of type of_bsn_get_interfaces_request. * @param obj Pointer to an object of type of_bsn_get_interfaces_request. * @param experimenter The value to write into the object */ void of_bsn_get_interfaces_request_experimenter_set( of_bsn_get_interfaces_request_t *obj, uint32_t experimenter) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_BSN_GET_INTERFACES_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 8; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, experimenter); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Get subtype from an object of type of_bsn_shell_output. * @param obj Pointer to an object of type of_bsn_shell_output. * @param subtype Pointer to the child object of type * uint32_t to be filled out. * */ void of_bsn_shell_output_subtype_get( of_bsn_shell_output_t *obj, uint32_t *subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_BSN_SHELL_OUTPUT); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_get(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set ethertype in an object of type of_action_push_pbb. * @param obj Pointer to an object of type of_action_push_pbb. * @param ethertype The value to write into the object */ void of_action_push_pbb_ethertype_set( of_action_push_pbb_t *obj, uint16_t ethertype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_ACTION_PUSH_PBB); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 4; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, ethertype); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set value in an object of type of_bsn_tlv_tx_packets. * @param obj Pointer to an object of type of_bsn_tlv_tx_packets. * @param value The value to write into the object */ void of_bsn_tlv_tx_packets_value_set( of_bsn_tlv_tx_packets_t *obj, uint64_t value) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_BSN_TLV_TX_PACKETS); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 4; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u64_set(wbuf, abs_offset, value); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Get value from an object of type of_oxm_in_port. * @param obj Pointer to an object of type of_oxm_in_port. * @param value Pointer to the child object of type * of_port_no_t to be filled out. * */ void of_oxm_in_port_value_get( of_oxm_in_port_t *obj, of_port_no_t *value) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_OXM_IN_PORT); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_port_no_get(ver, wbuf, abs_offset, value); OF_PORT_NO_VALUE_CHECK(*value, ver); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set if_name in an object of type of_bsn_vport_q_in_q. * @param obj Pointer to an object of type of_bsn_vport_q_in_q. * @param if_name The value to write into the object */ void of_bsn_vport_q_in_q_if_name_set( of_bsn_vport_q_in_q_t *obj, of_port_name_t if_name) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_BSN_VPORT_Q_IN_Q); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_port_name_set(wbuf, abs_offset, if_name); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set uri in an object of type of_bsn_controller_connection. * @param obj Pointer to an object of type of_bsn_controller_connection. * @param uri The value to write into the object */ void of_bsn_controller_connection_uri_set( of_bsn_controller_connection_t *obj, of_desc_str_t uri) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_BSN_CONTROLLER_CONNECTION); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 8; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_desc_str_set(wbuf, abs_offset, uri); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set actor_key in an object of type of_bsn_set_lacp_request. * @param obj Pointer to an object of type of_bsn_set_lacp_request. * @param actor_key The value to write into the object */ void of_bsn_set_lacp_request_actor_key_set( of_bsn_set_lacp_request_t *obj, uint16_t actor_key) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_BSN_SET_LACP_REQUEST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 36; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, actor_key); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set subtype in an object of type of_action_id_bsn_set_tunnel_dst. * @param obj Pointer to an object of type of_action_id_bsn_set_tunnel_dst. * @param subtype The value to write into the object */ void of_action_id_bsn_set_tunnel_dst_subtype_set( of_action_id_bsn_set_tunnel_dst_t *obj, uint32_t subtype) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_ACTION_ID_BSN_SET_TUNNEL_DST); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 8; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, subtype); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set value in an object of type of_oxm_bsn_l3_interface_class_id. * @param obj Pointer to an object of type of_oxm_bsn_l3_interface_class_id. * @param value The value to write into the object */ void of_oxm_bsn_l3_interface_class_id_value_set( of_oxm_bsn_l3_interface_class_id_t *obj, uint32_t value) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_OXM_BSN_L3_INTERFACE_CLASS_ID); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, value); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set value_mask in an object of type of_oxm_vlan_vid_masked. * @param obj Pointer to an object of type of_oxm_vlan_vid_masked. * @param value_mask The value to write into the object */ void of_oxm_vlan_vid_masked_value_mask_set( of_oxm_vlan_vid_masked_t *obj, uint16_t value_mask) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_OXM_VLAN_VID_MASKED); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 6; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, value_mask); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set in_phy_port in an object of type of_packet_in. * @param obj Pointer to an object of type of_packet_in. * @param in_phy_port The value to write into the object */ void of_packet_in_in_phy_port_set( of_packet_in_t *obj, of_port_no_t in_phy_port) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_PACKET_IN); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: offset = 16; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_port_no_set(ver, wbuf, abs_offset, in_phy_port); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set code in an object of type of_meter_mod_failed_error_msg. * @param obj Pointer to an object of type of_meter_mod_failed_error_msg. * @param code The value to write into the object */ void of_meter_mod_failed_error_msg_code_set( of_meter_mod_failed_error_msg_t *obj, uint16_t code) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_METER_MOD_FAILED_ERROR_MSG); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 10; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u16_set(wbuf, abs_offset, code); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set xid in an object of type of_hello. * @param obj Pointer to an object of type of_hello. * @param xid The value to write into the object */ void of_hello_xid_set( of_hello_t *obj, uint32_t xid) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; ASSERT(obj->object_id == OF_HELLO); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 4; break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); of_wire_buffer_u32_set(wbuf, abs_offset, xid); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Set match in an object of type of_flow_modify. * @param obj Pointer to an object of type of_flow_modify. * @param match Pointer to the child of type of_match_t. * * If the child's wire buffer is the same as the parent's, then * nothing is done as the changes have already been registered in the * parent. Otherwise, the data in the child's wire buffer is inserted * into the parent's and the appropriate lengths are updated. */ int WARN_UNUSED_RESULT of_flow_modify_match_set( of_flow_modify_t *obj, of_match_t *match) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ int new_len, delta; /* For set, need new length and delta */ of_octets_t match_octets; /* Serialized string for match */ ASSERT(IS_FLOW_MOD_SUBTYPE(obj->object_id)); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 8; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_1: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); /* Match object */ OF_TRY(of_match_serialize(ver, match, &match_octets)); new_len = match_octets.bytes; of_wire_buffer_replace_data(wbuf, abs_offset, cur_len, match_octets.data, new_len); /* Free match serialized octets */ FREE(match_octets.data); /* Not scalar, update lengths if needed */ delta = new_len - cur_len; if (delta != 0) { /* Update parent(s) */ of_object_parent_length_update((of_object_t *)obj, delta); } OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; }
/** * Set data in an object of type of_packet_in. * @param obj Pointer to an object of type of_packet_in. * @param data The value to write into the object */ int WARN_UNUSED_RESULT of_packet_in_data_set( of_packet_in_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ int new_len, delta; /* For set, need new length and delta */ ASSERT(obj->object_id == OF_PACKET_IN); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 18; cur_len = _END_LEN(obj, offset); break; case OF_VERSION_1_1: offset = 24; cur_len = _END_LEN(obj, offset); break; case OF_VERSION_1_2: case OF_VERSION_1_3: offset = _PACKET_IN_DATA_OFFSET(obj); cur_len = _END_LEN(obj, offset); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); new_len = data->bytes; of_wire_buffer_grow(wbuf, abs_offset + (new_len - cur_len)); of_wire_buffer_octets_data_set(wbuf, abs_offset, data, cur_len); /* Not scalar, update lengths if needed */ delta = new_len - cur_len; if (delta != 0) { /* Update parent(s) */ of_object_parent_length_update((of_object_t *)obj, delta); } OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; }
/** * Bind an object of type of_list_action_t to the parent of type of_packet_out for * member actions * @param obj Pointer to an object of type of_packet_out. * @param actions Pointer to the child object of type * of_list_action_t to be filled out. * \ingroup of_packet_out * * The parameter actions is filled out to point to the same underlying * wire buffer as its parent. * */ void of_packet_out_actions_bind( of_packet_out_t *obj, of_list_action_t *actions) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ ASSERT(obj->object_id == OF_PACKET_OUT); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 16; cur_len = _PACKET_OUT_ACTION_LEN(obj); break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 24; cur_len = _PACKET_OUT_ACTION_LEN(obj); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); /* Initialize child */ of_list_action_init(actions, obj->version, 0, 1); /* Attach to parent */ actions->parent = (of_object_t *)obj; actions->wire_object.wbuf = obj->wire_object.wbuf; actions->wire_object.obj_offset = abs_offset; actions->wire_object.owned = 0; actions->length = cur_len; OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Get match from an object of type of_flow_modify. * @param obj Pointer to an object of type of_flow_modify. * @param match Pointer to the child object of type * of_match_t to be filled out. * */ int WARN_UNUSED_RESULT of_flow_modify_match_get( of_flow_modify_t *obj, of_match_t *match) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ of_octets_t match_octets; /* Serialized string for match */ ASSERT(IS_FLOW_MOD_SUBTYPE(obj->object_id)); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 8; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_1: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 48; cur_len = _WIRE_MATCH_PADDED_LEN(obj, offset); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf)); match_octets.bytes = cur_len; match_octets.data = OF_OBJECT_BUFFER_INDEX(obj, offset); OF_TRY(of_match_deserialize(ver, match, &match_octets)); OF_LENGTH_CHECK_ASSERT(obj); return OF_ERROR_NONE; }
/** * Bind an object of type of_list_queue_stats_entry_t to the parent of type of_queue_stats_reply for * member entries * @param obj Pointer to an object of type of_queue_stats_reply. * @param entries Pointer to the child object of type * of_list_queue_stats_entry_t to be filled out. * \ingroup of_queue_stats_reply * * The parameter entries is filled out to point to the same underlying * wire buffer as its parent. * */ void of_queue_stats_reply_entries_bind( of_queue_stats_reply_t *obj, of_list_queue_stats_entry_t *entries) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ ASSERT(obj->object_id == OF_QUEUE_STATS_REPLY); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 12; cur_len = _END_LEN(obj, offset); break; case OF_VERSION_1_1: case OF_VERSION_1_2: case OF_VERSION_1_3: offset = 16; cur_len = _END_LEN(obj, offset); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); /* Initialize child */ of_list_queue_stats_entry_init(entries, obj->version, 0, 1); /* Attach to parent */ entries->parent = (of_object_t *)obj; entries->wire_object.wbuf = obj->wire_object.wbuf; entries->wire_object.obj_offset = abs_offset; entries->wire_object.owned = 0; entries->length = cur_len; OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Bind an object of type of_list_instruction_t to the parent of type of_flow_modify for * member instructions * @param obj Pointer to an object of type of_flow_modify. * @param instructions Pointer to the child object of type * of_list_instruction_t to be filled out. * \ingroup of_flow_modify * * The parameter instructions is filled out to point to the same underlying * wire buffer as its parent. * */ void of_flow_modify_instructions_bind( of_flow_modify_t *obj, of_list_instruction_t *instructions) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ ASSERT(IS_FLOW_MOD_SUBTYPE(obj->object_id)); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_1: offset = 136; cur_len = _END_LEN(obj, offset); break; case OF_VERSION_1_2: case OF_VERSION_1_3: offset = _FLOW_MODIFY_INSTRUCTIONS_OFFSET(obj); cur_len = _END_LEN(obj, offset); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); /* Initialize child */ of_list_instruction_init(instructions, obj->version, 0, 1); /* Attach to parent */ instructions->parent = (of_object_t *)obj; instructions->wire_object.wbuf = obj->wire_object.wbuf; instructions->wire_object.obj_offset = abs_offset; instructions->wire_object.owned = 0; instructions->length = cur_len; OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Get data from an object of type of_packet_in. * @param obj Pointer to an object of type of_packet_in. * @param data Pointer to the child object of type * of_octets_t to be filled out. * */ void of_packet_in_data_get( of_packet_in_t *obj, of_octets_t *data) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ ASSERT(obj->object_id == OF_PACKET_IN); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_0: offset = 18; cur_len = _END_LEN(obj, offset); break; case OF_VERSION_1_1: offset = 24; cur_len = _END_LEN(obj, offset); break; case OF_VERSION_1_2: case OF_VERSION_1_3: offset = _PACKET_IN_DATA_OFFSET(obj); cur_len = _END_LEN(obj, offset); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); ASSERT(cur_len + abs_offset <= WBUF_CURRENT_BYTES(wbuf)); data->bytes = cur_len; data->data = OF_WIRE_BUFFER_INDEX(wbuf, abs_offset); OF_LENGTH_CHECK_ASSERT(obj); return ; }
/** * Bind an object of type of_list_uint8_t to the parent of type of_table_feature_prop_next_tables for * member next_table_ids * @param obj Pointer to an object of type of_table_feature_prop_next_tables. * @param next_table_ids Pointer to the child object of type * of_list_uint8_t to be filled out. * \ingroup of_table_feature_prop_next_tables * * The parameter next_table_ids is filled out to point to the same underlying * wire buffer as its parent. * */ void of_table_feature_prop_next_tables_next_table_ids_bind( of_table_feature_prop_next_tables_t *obj, of_list_uint8_t *next_table_ids) { of_wire_buffer_t *wbuf; int offset = 0; /* Offset of value relative to the start obj */ int abs_offset; /* Offset of value relative to start of wbuf */ of_version_t ver; int cur_len = 0; /* Current length of object data */ ASSERT(obj->object_id == OF_TABLE_FEATURE_PROP_NEXT_TABLES); ver = obj->version; wbuf = OF_OBJECT_TO_WBUF(obj); ASSERT(wbuf != NULL); /* By version, determine offset and current length (where needed) */ switch (ver) { case OF_VERSION_1_3: offset = 4; cur_len = _END_LEN(obj, offset); break; default: ASSERT(0); } abs_offset = OF_OBJECT_ABSOLUTE_OFFSET(obj, offset); ASSERT(abs_offset >= 0); ASSERT(cur_len >= 0 && cur_len < 64 * 1024); /* Initialize child */ of_list_uint8_init(next_table_ids, obj->version, 0, 1); /* Attach to parent */ next_table_ids->parent = (of_object_t *)obj; next_table_ids->wire_object.wbuf = obj->wire_object.wbuf; next_table_ids->wire_object.obj_offset = abs_offset; next_table_ids->wire_object.owned = 0; next_table_ids->length = cur_len; OF_LENGTH_CHECK_ASSERT(obj); return ; }