[P4-dev] move parser pointer forward

LJ Wobker ljw at barefootnetworks.com
Mon Aug 3 14:07:45 EDT 2015

That's correct - there is no explicit "skip" functionality in the parser.
Think of the parse tree as a continuous graph that walks through the
incoming bytestream in order: there are no gaps.  As Mihai suggests, you
can always just use a dummy header field for bytes that you don't care
about, although I would contend that in most cases it will make more sense
to just parse the header with a meaningful name.

Let us consider a contrived case such as: RTP in UDP in ipv4 in ethernet.
Let's further assume (again, contrived) that you know you absolutely do not
need to parse any of the specific fields within the UDP header, but you
need/want to be able to get to the RTP headers underneath.

You could easily build a parse tree/header definition that treats the
entire UDP header as one field, instead of the component fields.  This
might or might not be simpler/easier/faster/cheaper for a given target or
compiler to handle, and it might (or might not!) be more convenient for the
P4 programmer.

Original UDP header format from

header_type udp_t {

    fields {

*        srcPort : 16;*

*        dstPort : 16;*

*        length_ : 16;*

*        checksum : 16;*



Modified/ simpler version as described:

header_type udp_t {

    fields {

*        meaningless_blob : 64;*



So that’s probably a longer answer than you really needed, but I figured
I’d write it out for posterity.


-----Original Message-----
From: P4-dev [mailto:p4-dev-bounces at p4.org] On Behalf Of Salvatore
Sent: Monday, August 03, 2015 10:01 AM
To: p4-dev at p4.org
Subject: [P4-dev] move parser pointer forward

Hi all,

could someone confirm that the actual specification doesn't provide any

construct to advance the parsing pointer except the "extract" one?

Is it possible to skip the parsing of some fields without defining and

extracting a header including them?




P4-dev mailing list

P4-dev at p4.org

Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org

Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150803/87609fe3/attachment-0001.html>

More information about the P4-dev mailing list