# How to fill p4info for Set forwarding request

**URL:** <https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485>\
**Category:** API Working Group\
**Created:** [October 3, 2022, 1:28pm UTC](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485 "2022-10-03T13:28:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dikhit](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@dikhit](https://forum.p4.org/u/dikhit)\
**Post date:** [October 3, 2022, 1:28pm UTC](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485/1 "2022-10-03T13:28:50Z")

</div>

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 {  
UNSPECIFIED = 0;  
VERIFY = 1;  
VERIFY\_AND\_SAVE = 2;  
VERIFY\_AND\_COMMIT = 3;  
COMMIT = 4;  
RECONCILE\_AND\_COMMIT = 5;  
}  
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;  
}

---

<div class="post-metadata">

**Author:** ![DavideS](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/davides/32/120_2.png) [@DavideS](https://forum.p4.org/u/DavideS)\
**Post date:** [October 4, 2022, 6:13am UTC](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485/2 "2022-10-04T06:13:46Z")

</div>

Hi @dikhit,

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

---

<div class="post-metadata">

**Author:** ![andyfingerhut](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/andyfingerhut/32/17_2.png) [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Post date:** [October 4, 2022, 7:39am UTC](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485/3 "2022-10-04T07:39:16Z")

</div>

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](https://github.com/p4lang/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.

---

<div class="post-metadata">

**Author:** ![dikhit](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@dikhit](https://forum.p4.org/u/dikhit)\
**Post date:** [October 7, 2022, 3:29am UTC](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485/4 "2022-10-07T03:29:05Z")

</div>

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**

---

<div class="post-metadata">

**Author:** ![dikhit](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@dikhit](https://forum.p4.org/u/dikhit)\
**Post date:** [October 7, 2022, 6:34am UTC](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485/5 "2022-10-07T06:34:57Z")

</div>

> [@How to fill p4info for Set forwarding request](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485/4):
>
> Hello , I am using cpp implementation , can you please help me for GetForwardingPipelineConfigRequest , p4info is what we get as response . So how to fetch the response (config.v1.P4Info p4info). Similarly for SetForwardingPipelineConfigRequest , p4info is passed as request . so how to send this as a request. 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.

---

<div class="post-metadata">

**Author:** ![andyfingerhut](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/andyfingerhut/32/17_2.png) [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Post date:** [October 12, 2022, 3:29pm UTC](https://forum.p4.org/t/how-to-fill-p4info-for-set-forwarding-request/485/6 "2022-10-12T15:29:09Z")

</div>

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.
