p4lang / p4runtime-shell

An interactive Python shell for P4Runtime
Apache License 2.0
76 stars 40 forks source link

Is there "parsing" of PacketIn packets into Python data structs? #107

Open jafingerhut opened 1 year ago

jafingerhut commented 1 year ago

I see in https://github.com/p4lang/p4runtime-shell/blob/main/usage/packet_io.md that one can use Pythonic syntax to fill in the controller packet metadata fields:

P4Runtime sh >>> p = packet_out()
P4Runtime sh >>> p.payload = b'AAAA'  # Note that the payload must be a byte string
P4Runtime sh >>> p.metadata['egress_port'] = '1'  # Note that the value must be a string
P4Runtime sh >>> p.send  # send the packet-out message

But I did not see any way to take a PacketIn message and access its payload and metadata fields in a similar style. I only found that one could use the PacketIn class to receive packets as Python Protobuf data structures.

Did I miss some feature to take the PacketIn's and make them readable using syntax like mypktin.payload, mypktin.metadata['egress_port'], etc.?

antoninbas commented 1 year ago

From looking at the code, it doesn't seem that this functionality is available at the moment