Пример #1
0
of_object_t *
of_object_new_from_message(of_message_t msg, int len)
{
    of_object_id_t object_id;
    of_object_t *obj;
    of_version_t version;

    version = of_message_version_get(msg);
    if (!OF_VERSION_OKAY(version)) {
        return NULL;
    }

    if (of_validate_message(msg, len) != 0) {
        LOCI_LOG_ERROR("message validation failed\n");
        return NULL;
    }

    if ((obj = of_object_new(-1)) == NULL) {
        return NULL;
    }

    if (of_object_buffer_bind(obj, OF_MESSAGE_TO_BUFFER(msg), len, 
                              OF_MESSAGE_FREE_FUNCTION) < 0) {
        FREE(obj);
        return NULL;
    }
    obj->version = version;

    of_header_wire_object_id_get(obj, &object_id);
    of_object_init_map[object_id](obj, version, len, 0);

    return obj;
}
Пример #2
0
of_flow_modify_t *
of_flow_modify_new(of_version_t version)
{
    of_flow_modify_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_FLOW_MODIFY] + of_object_extra_len[version][OF_FLOW_MODIFY];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_flow_modify_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_flow_modify_init(obj, version, bytes, 0);

    if (of_flow_modify_push_wire_values(obj) < 0) {
        FREE(obj);
        return NULL;
    }

    /* Initialize match TLV for 1.2 */
    /* FIXME: Check 1.3 below */
    if ((version == OF_VERSION_1_2) || (version == OF_VERSION_1_3)) {
        of_object_u16_set((of_object_t *)obj, 48 + 2, 4);
    }

    return obj;
}
Пример #3
0
of_hello_t *
of_hello_new_from_message(of_message_t msg)
{
    of_hello_t *obj = NULL;
    of_version_t version;
    int length;

    if (msg == NULL) return NULL;

    version = of_message_version_get(msg);
    if (!OF_VERSION_OKAY(version)) return NULL;

    length = of_message_length_get(msg);

    if ((obj = (of_hello_t *)of_object_new(-1)) == NULL) {
        return NULL;
    }

    of_hello_init(obj, version, 0, 0);

    if ((of_object_buffer_bind((of_object_t *)obj, OF_MESSAGE_TO_BUFFER(msg),
                               length, OF_MESSAGE_FREE_FUNCTION)) < 0) {
       FREE(obj);
       return NULL;
    }
    obj->length = length;
    obj->version = version;

    return obj;
}
of_object_t *
of_list_bundle_prop_new(of_version_t version)
{
    of_object_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BUNDLE_PROP];

    if ((obj = of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bundle_prop_init(obj, version, bytes, 0);

    return obj;
}
of_object_t *
of_list_bsn_interface_new(of_version_t version)
{
    of_object_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BSN_INTERFACE];

    if ((obj = of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bsn_interface_init(obj, version, bytes, 0);

    return obj;
}
of_object_t *
of_list_bsn_debug_counter_desc_stats_entry_new(of_version_t version)
{
    of_object_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BSN_DEBUG_COUNTER_DESC_STATS_ENTRY];

    if ((obj = of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bsn_debug_counter_desc_stats_entry_init(obj, version, bytes, 0);

    return obj;
}
of_hello_elem_header_t *
of_hello_elem_header_new(of_version_t version)
{
    of_hello_elem_header_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_HELLO_ELEM_HEADER] + of_object_extra_len[version][OF_HELLO_ELEM_HEADER];

    if ((obj = (of_hello_elem_header_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_hello_elem_header_init(obj, version, bytes, 0);

    return obj;
}
of_table_feature_prop_header_t *
of_table_feature_prop_header_new(of_version_t version)
{
    of_table_feature_prop_header_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_TABLE_FEATURE_PROP_HEADER] + of_object_extra_len[version][OF_TABLE_FEATURE_PROP_HEADER];

    if ((obj = (of_table_feature_prop_header_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_table_feature_prop_header_init(obj, version, bytes, 0);

    return obj;
}
of_object_t *
of_list_meter_stats_new(of_version_t version)
{
    of_object_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_METER_STATS];

    if ((obj = of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_meter_stats_init(obj, version, bytes, 0);

    return obj;
}
of_instruction_header_t *
of_instruction_header_new(of_version_t version)
{
    of_instruction_header_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_INSTRUCTION_HEADER] + of_object_extra_len[version][OF_INSTRUCTION_HEADER];

    if ((obj = (of_instruction_header_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_instruction_header_init(obj, version, bytes, 0);

    return obj;
}
Пример #11
0
of_list_uint32_t *
of_list_uint32_new(of_version_t version)
{
    of_list_uint32_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_UINT32] + of_object_extra_len[version][OF_LIST_UINT32];

    if ((obj = (of_list_uint32_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_uint32_init(obj, version, bytes, 0);

    return obj;
}
of_object_t *
of_list_queue_stats_prop_new(of_version_t version)
{
    of_object_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_QUEUE_STATS_PROP];

    if ((obj = of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_queue_stats_prop_init(obj, version, bytes, 0);

    return obj;
}
of_list_action_id_t *
of_list_action_id_new(of_version_t version)
{
    of_list_action_id_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_ACTION_ID] + of_object_extra_len[version][OF_LIST_ACTION_ID];

    if ((obj = (of_list_action_id_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_action_id_init(obj, version, bytes, 0);

    return obj;
}
of_object_t *
of_list_bsn_gentable_entry_stats_entry_new(of_version_t version)
{
    of_object_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BSN_GENTABLE_ENTRY_STATS_ENTRY];

    if ((obj = of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bsn_gentable_entry_stats_entry_init(obj, version, bytes, 0);

    return obj;
}
of_object_t *
of_list_instruction_new(of_version_t version)
{
    of_object_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_INSTRUCTION];

    if ((obj = of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_instruction_init(obj, version, bytes, 0);

    return obj;
}
of_list_bucket_counter_t *
of_list_bucket_counter_new(of_version_t version)
{
    of_list_bucket_counter_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BUCKET_COUNTER] + of_object_extra_len[version][OF_LIST_BUCKET_COUNTER];

    if ((obj = (of_list_bucket_counter_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bucket_counter_init(obj, version, bytes, 0);

    return obj;
}
of_list_bsn_lacp_stats_entry_t *
of_list_bsn_lacp_stats_entry_new(of_version_t version)
{
    of_list_bsn_lacp_stats_entry_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BSN_LACP_STATS_ENTRY] + of_object_extra_len[version][OF_LIST_BSN_LACP_STATS_ENTRY];

    if ((obj = (of_list_bsn_lacp_stats_entry_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bsn_lacp_stats_entry_init(obj, version, bytes, 0);

    return obj;
}
of_list_bsn_flow_checksum_bucket_stats_entry_t *
of_list_bsn_flow_checksum_bucket_stats_entry_new(of_version_t version)
{
    of_list_bsn_flow_checksum_bucket_stats_entry_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BSN_FLOW_CHECKSUM_BUCKET_STATS_ENTRY] + of_object_extra_len[version][OF_LIST_BSN_FLOW_CHECKSUM_BUCKET_STATS_ENTRY];

    if ((obj = (of_list_bsn_flow_checksum_bucket_stats_entry_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bsn_flow_checksum_bucket_stats_entry_init(obj, version, bytes, 0);

    return obj;
}
Пример #19
0
of_instruction_t *
of_instruction_new(of_version_t version)
{
    of_instruction_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_INSTRUCTION] + of_object_extra_len[version][OF_INSTRUCTION];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_instruction_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_instruction_init(obj, version, bytes, 0);

    return obj;
}
of_table_feature_prop_header_t *
of_table_feature_prop_header_new(of_version_t version)
{
    of_table_feature_prop_header_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_TABLE_FEATURE_PROP_HEADER] + of_object_extra_len[version][OF_TABLE_FEATURE_PROP_HEADER];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_table_feature_prop_header_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_table_feature_prop_header_init(obj, version, bytes, 0);

    return obj;
}
of_list_bsn_flow_checksum_bucket_stats_entry_t *
of_list_bsn_flow_checksum_bucket_stats_entry_new(of_version_t version)
{
    of_list_bsn_flow_checksum_bucket_stats_entry_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_BSN_FLOW_CHECKSUM_BUCKET_STATS_ENTRY] + of_object_extra_len[version][OF_LIST_BSN_FLOW_CHECKSUM_BUCKET_STATS_ENTRY];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_list_bsn_flow_checksum_bucket_stats_entry_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_bsn_flow_checksum_bucket_stats_entry_init(obj, version, bytes, 0);

    return obj;
}
of_list_queue_stats_entry_t *
of_list_queue_stats_entry_new(of_version_t version)
{
    of_list_queue_stats_entry_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_QUEUE_STATS_ENTRY] + of_object_extra_len[version][OF_LIST_QUEUE_STATS_ENTRY];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_list_queue_stats_entry_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_queue_stats_entry_init(obj, version, bytes, 0);

    return obj;
}
Пример #23
0
of_list_meter_band_t *
of_list_meter_band_new(of_version_t version)
{
    of_list_meter_band_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_LIST_METER_BAND] + of_object_extra_len[version][OF_LIST_METER_BAND];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_list_meter_band_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_list_meter_band_init(obj, version, bytes, 0);

    return obj;
}
of_experimenter_stats_header_t *
of_experimenter_stats_header_new(of_version_t version)
{
    of_experimenter_stats_header_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_EXPERIMENTER_STATS_HEADER] + of_object_extra_len[version][OF_EXPERIMENTER_STATS_HEADER];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_experimenter_stats_header_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_experimenter_stats_header_init(obj, version, bytes, 0);

    return obj;
}
of_bsn_tlv_tx_packets_t *
of_bsn_tlv_tx_packets_new(of_version_t version)
{
    of_bsn_tlv_tx_packets_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_BSN_TLV_TX_PACKETS] + of_object_extra_len[version][OF_BSN_TLV_TX_PACKETS];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_bsn_tlv_tx_packets_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_bsn_tlv_tx_packets_init(obj, version, bytes, 0);

    if (of_bsn_tlv_tx_packets_push_wire_values(obj) < 0) {
        FREE(obj);
        return NULL;
    }

    return obj;
}
of_get_config_request_t *
of_get_config_request_new(of_version_t version)
{
    of_get_config_request_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_GET_CONFIG_REQUEST] + of_object_extra_len[version][OF_GET_CONFIG_REQUEST];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_get_config_request_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_get_config_request_init(obj, version, bytes, 0);

    if (of_get_config_request_push_wire_values(obj) < 0) {
        FREE(obj);
        return NULL;
    }

    return obj;
}
of_oxm_bsn_l3_interface_class_id_t *
of_oxm_bsn_l3_interface_class_id_new(of_version_t version)
{
    of_oxm_bsn_l3_interface_class_id_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_OXM_BSN_L3_INTERFACE_CLASS_ID] + of_object_extra_len[version][OF_OXM_BSN_L3_INTERFACE_CLASS_ID];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_oxm_bsn_l3_interface_class_id_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_oxm_bsn_l3_interface_class_id_init(obj, version, bytes, 0);

    if (of_oxm_bsn_l3_interface_class_id_push_wire_values(obj) < 0) {
        FREE(obj);
        return NULL;
    }

    return obj;
}
Пример #28
0
of_oxm_icmpv6_code_t *
of_oxm_icmpv6_code_new(of_version_t version)
{
    of_oxm_icmpv6_code_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_OXM_ICMPV6_CODE] + of_object_extra_len[version][OF_OXM_ICMPV6_CODE];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_oxm_icmpv6_code_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_oxm_icmpv6_code_init(obj, version, bytes, 0);

    if (of_oxm_icmpv6_code_push_wire_values(obj) < 0) {
        FREE(obj);
        return NULL;
    }

    return obj;
}
of_table_feature_prop_next_tables_t *
of_table_feature_prop_next_tables_new(of_version_t version)
{
    of_table_feature_prop_next_tables_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_TABLE_FEATURE_PROP_NEXT_TABLES] + of_object_extra_len[version][OF_TABLE_FEATURE_PROP_NEXT_TABLES];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_table_feature_prop_next_tables_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_table_feature_prop_next_tables_init(obj, version, bytes, 0);

    if (of_table_feature_prop_next_tables_push_wire_values(obj) < 0) {
        FREE(obj);
        return NULL;
    }

    return obj;
}
Пример #30
0
of_action_pop_pbb_t *
of_action_pop_pbb_new(of_version_t version)
{
    of_action_pop_pbb_t *obj;
    int bytes;

    bytes = of_object_fixed_len[version][OF_ACTION_POP_PBB] + of_object_extra_len[version][OF_ACTION_POP_PBB];

    /* Allocate a maximum-length wire buffer assuming we'll be appending to it. */
    if ((obj = (of_action_pop_pbb_t *)of_object_new(OF_WIRE_BUFFER_MAX_LENGTH)) == NULL) {
        return NULL;
    }

    of_action_pop_pbb_init(obj, version, bytes, 0);

    if (of_action_pop_pbb_push_wire_values(obj) < 0) {
        FREE(obj);
        return NULL;
    }

    return obj;
}