Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Fix documentation and examples to show simplified usage #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ local0 (dn):
## Example Message
Sending a message to VPP without using a builder
```rust
let create_interface: SwInterfaceAddDelAddressReply = send_recv_msg(
&SwInterfaceAddDelAddress::get_message_name_and_crc(),
let create_interface: SwInterfaceAddDelAddressReply = send_recv_one(
&SwInterfaceAddDelAddress {
client_index: t.get_client_index(),
context: 0,
Expand All @@ -60,21 +59,18 @@ let create_interface: SwInterfaceAddDelAddressReply = send_recv_msg(
},
},
&mut *t,
&SwInterfaceAddDelAddressReply::get_message_name_and_crc(),
);
```
Sending a message to VPP using a builder
```rust
let create_host_interface: CliInbandReply = send_recv_msg(
&CliInband::get_message_name_and_crc(),
let create_host_interface: CliInbandReply = send_recv_one(
&CliInband::builder()
.client_index(t.get_client_index())
.context(0)
.cmd("create host-interface name vpp1out".try_into().unwrap())
.build()
.unwrap(),
&mut *t,
&CliInbandReply::get_message_name_and_crc(),
);
```

Expand Down
36 changes: 21 additions & 15 deletions code-templates/examples/progressive-vpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,40 @@ fn main() {
println!("Connect result: {:?}", t.connect("api-test", None, 256));

// Step 3: Create Host interface
let create_host_interface: CliInbandReply = send_recv_msg(
&CliInband::get_message_name_and_crc(),
let create_host_interface: CliInbandReply = send_recv_one(
&CliInband::builder()
.client_index(t.get_client_index())
.context(0)
.cmd("create host-interface name vpp1out".try_into().unwrap())
.build()
.unwrap(),
&mut *t,
&CliInbandReply::get_message_name_and_crc(),
);
println!("{:?}", create_host_interface);

// Step 4: Set Host Interface State up
let set_interface_link_up: SwInterfaceSetFlagsReply = send_recv_msg(
&SwInterfaceSetFlags::get_message_name_and_crc(),
&SwInterfaceSetFlags::builder().client_index(t.get_client_index()).context(0).sw_if_index(1).flags(vec![IfStatusFlags::IF_STATUS_API_FLAG_ADMIN_UP, IfStatusFlags::IF_STATUS_API_FLAG_LINK_UP].try_into().unwrap()).build().unwrap(),
let set_interface_link_up: SwInterfaceSetFlagsReply = send_recv_one(
&SwInterfaceSetFlags::builder()
.client_index(t.get_client_index())
.context(0)
.sw_if_index(1)
.flags(
vec![
IfStatusFlags::IF_STATUS_API_FLAG_ADMIN_UP,
IfStatusFlags::IF_STATUS_API_FLAG_LINK_UP,
]
.try_into()
.unwrap(),
)
.build()
.unwrap(),
&mut *t,
&SwInterfaceSetFlagsReply::get_message_name_and_crc());
);

println!("{:?}", create_host_interface);

// Step 5: Assign IP Address to Host Interface
let create_interface: SwInterfaceAddDelAddressReply = send_recv_msg(
&SwInterfaceAddDelAddress::get_message_name_and_crc(),
let create_interface: SwInterfaceAddDelAddressReply = send_recv_one(
&SwInterfaceAddDelAddress {
client_index: t.get_client_index(),
context: 0,
Expand All @@ -82,13 +91,12 @@ fn main() {
prefix: AddressWithPrefix {
address: Address {
af: AddressFamily::ADDRESS_IP4,
un: AddressUnion::new_Ip4Address([10,10,1,2]),
un: AddressUnion::new_Ip4Address([10, 10, 1, 2]),
},
len: 24,
},
},
&mut *t,
&SwInterfaceAddDelAddressReply::get_message_name_and_crc(),
);
println!("{:?}", create_interface);

Expand Down Expand Up @@ -123,8 +131,7 @@ fn main() {

// Verify creation of Interface
// FIXME: Need to implement Deserialize for FixedSizeArray to make this work
let swinterfacedetails: Vec<SwInterfaceDetails> = send_bulk_msg(
&SwInterfaceDump::get_message_name_and_crc(),
let swinterfacedetails: Vec<SwInterfaceDetails> = send_recv_many(
&SwInterfaceDump::builder()
.client_index(t.get_client_index())
.context(0)
Expand All @@ -134,7 +141,6 @@ fn main() {
.build()
.unwrap(),
&mut *t,
&SwInterfaceDetails::get_message_name_and_crc(),
);
println!("{:#?}", swinterfacedetails);
println!("Interface IDX:");
Expand Down