mpls: add mpls_interface_dump 22/39022/4
authorPim van Pelt <pim@ipng.nl>
Sat, 10 Jun 2023 14:46:34 +0000 (16:46 +0200)
committerNeale Ranns <neale@graphiant.com>
Tue, 29 Aug 2023 12:42:13 +0000 (12:42 +0000)
commit8d61c59c3f1e05e49b89a700a1640aa9bcebc6b8
tree813e853847debe8e51b80ff40494d823065fc247
parent7e43005d4daea3614a216b582fa0870b3a91feb5
mpls: add mpls_interface_dump

Add an API call mpls_interface_dump() which returns a list of mpls_interface_details:
- If no sw_if_index is given, all MPLS enabled sw_if_index are returned.
- If a particular sw_if_index is given, and it doesn't exist, an empty list is returned.
- If a sw_if_index exists and has MPLS enabled, a list of that one sw_if_index is returned.

Tested:
- Create 3 loopback interfaces
- Call for ~0 and for sw_if_index 0..5 all return empty lists
- set int mpls loop0 enable
- set int mpls loop1 enable
- Call for ~0 returns 2, and the call for sw_if_index=1 and =2 (the loopbacks) returns
  each a list of one sw_if_index 1 resp 2, the other values of sw_if_index return empty list
- set int mpls loop0 disable
- Call for ~0 returns 1, and the call for sw_if_index=2 (loop1) returns both a list of one
  sw_if_index=2, the other values of sw_if_index return empty list
- set int mpls loop1 disable
- Call for ~0 and for sw_if_index 0..5 all return empty lists

Example Python3 API program:
```
api_response = vpp.api.mpls_interface_dump()
print(f"Response is {api_response}")

for i in [ 0, 1, 2, 3, 4, 5 ]:
  api_response = vpp.api.mpls_interface_dump(sw_if_index=i)
  print(f"Response[{i}] = {api_response}")
```

Type: improvement
Change-Id: If87f7d7f8972d99260e859757dbcb251c6fa54a8
Signed-off-by: Pim van Pelt <pim@ipng.nl>
src/vnet/mpls/mpls.api
src/vnet/mpls/mpls_api.c