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. |
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.
}
Parent topic: Hook Functions