import socket
from vpp_object import VppObject
-from vpp_ip_route import MPLS_LABEL_INVALID, VppRoutePath
+from vpp_ip_route import MPLS_LABEL_INVALID, VppRoutePath, VppMplsLabel
class BIER_HDR_PAYLOAD:
self.bp = bp
self.paths = paths
+ def encode_paths(self):
+ br_paths = []
+ for p in self.paths:
+ lstack = []
+ for l in p.nh_labels:
+ if type(l) == VppMplsLabel:
+ lstack.append(l.encode())
+ else:
+ lstack.append({'label': l, 'ttl': 255})
+ n_labels = len(lstack)
+ while (len(lstack) < 16):
+ lstack.append({})
+ br_paths.append({'next_hop': p.nh_addr,
+ 'weight': 1,
+ 'afi': p.proto,
+ 'sw_if_index': 0xffffffff,
+ 'preference': 0,
+ 'table_id': p.nh_table_id,
+ 'next_hop_id': p.next_hop_id,
+ 'is_udp_encap': p.is_udp_encap,
+ 'n_labels': n_labels,
+ 'label_stack': lstack})
+ return br_paths
+
def add_vpp_config(self):
self._test.vapi.bier_route_add_del(
self.tbl_id,
self.bp,
- self.paths,
+ self.encode_paths(),
is_add=1)
self._test.registry.register(self, self._test.logger)
self._test.vapi.bier_route_add_del(
self.tbl_id,
self.bp,
- self.paths,
+ self.encode_paths(),
is_add=0)
def __str__(self):
BIER Disposition Entry
"""
- def __init__(self, test, tbl_id, bp, payload_proto, nh, nh_tbl,
- rpf_id=~0):
+ def __init__(self, test, tbl_id, bp, payload_proto, nh_proto,
+ nh, nh_tbl, rpf_id=~0):
self._test = test
self.tbl_id = tbl_id
self.nh_tbl = nh_tbl
+ self.nh_proto = nh_proto
self.bp = bp
self.payload_proto = payload_proto
self.rpf_id = rpf_id
self.tbl_id,
self.bp,
self.payload_proto,
+ self.nh_proto,
self.nh,
self.nh_tbl,
self.rpf_id,
self.tbl_id,
self.bp,
self.payload_proto,
+ self.nh_proto,
self.nh,
self.nh_tbl,
self.rpf_id,