Rate This Document
Findability
Accuracy
Completeness
Readability

flexda_custom_extract_hdr

Function

Extracts header information from a packet.

Syntax

int flexda_custom_extract_hdr ( void *ctx, const struct flexda_custom_info_t *info)

Parameters

Parameter

Type

Input/Output

Description

ctx

void *

Input

Pointer to the custom context. It also stores the extracted header information.

info

struct flexda_custom_info_t *

Input

Information provided by dpak-ovs for flexda-ovs to read. For details, see Table 1.

Return value

int

Output

The function returns 0 upon successful execution; otherwise, it returns an error code.

Table 1 struct flexda_custom_info_t

Attribute Type

Attribute Name

Description

uint16_t

input_port_id

Source input port of the current packet in OVS offload.

dp_packet *

pkt

Current packet in OVS offload.

rte_flow_action *

src_actions

Actions of the current software flow table in OVS offload.

Example

int flexda_custom_extract_hdr(void *ctx, flexda_custom_info_t info)
{
    struct custom_packet_ctx *custom_ctx = (struct custom_packet_ctx *)ctx;
    struct flexda_sub_hdr *out_header = &custom_ctx->out_header;  // Default packet header information structure provided by the framework, which is used together with the packet parsing API
    struct dp_packet *pkt = info.pkt;
    struct flexda_extract_ctx pkt_parser;  // Default packet parsing structure provided by the framework, which is used together with the packet parsing API
    pkt_parser.pkt_itr = (uint8_t *)flexda_dp_packet_data(pkt);
    pkt_parser.pkt_end = (uint8_t *)flexda_dp_packet_data(pkt) + flexda_dp_packet_size(pkt);
    if (custom_ctx->vlan_poped == 1) {
        // Call the default packet header parsing API provided by the framework to parse and save the packet header information in the custom packet context.
        if (!flexda_extract_hdr(&pkt_parser, out_header)) { // Parsing failure
            return -EINVAL;
        }
        return 0; // Parsing success
    }
    return false;// The flag bit is not 1.
}