How to fill p4info for Set forwarding request

Hi ,
Like we fill device_id as request.set_device_id(1); , similarly How to fill request like p4info and p4_device_config. (i am using opensource p4runtime.proto).

message SetForwardingPipelineConfigRequest {
enum Action {
uint64 device_id = 1;
uint64 role_id = 2 [deprecated=true];
string role = 6;
Uint128 election_id = 3;
Action action = 4;
ForwardingPipelineConfig config = 5;

message ForwardingPipelineConfig {
config.v1.P4Info p4info = 1;
bytes p4_device_config = 2;
message Cookie {
uint64 cookie = 1;
Cookie cookie = 3;

Hi @dikhit,

can you be a little more specific ? your question is not clear to me

The precise answer depends upon which programming language you are using to create and send P4Runtime API messages. Many programming languages are supported by the Google Protobuf library (e.g. C++, Java, Go, Python, …), which is what most people use to create Protobuf messages, whether P4Runtime API messages or any other message formats defined using Protobuf.

There is some sample code for creating P4Runtime API messages in Python in multiple repositories, including the P4 tutorials repository here: GitHub - p4lang/tutorials: P4 language tutorials. It may take some work to find exactly what you are looking for, but the Python code in the utils directory of that repo is especially relevant.

Hello ,
I am using cpp implementation , can you please help me

  1. for GetForwardingPipelineConfigRequest , p4info is what we get as response . So how to fetch the response (config.v1.P4Info p4info).
  2. Similarly for SetForwardingPipelineConfigRequest , p4info is passed as request . so how to send this as a request.
  3. I was thinking of to print this p4info , but i was not able to print it . What can be the correct way to print p4info

please help me with the solution.

I am hoping someone else reading this knows where to find open source and public examples of construction and/or “parsing” of P4Runtime API messages from the controller software side, using C++. I have not written such code before, nor looked for it, but I suspect such example code is out there in the public somewhere.