Bgpcep l3vpn multicast test coverage
[integration/test.git] / tools / fastbgp / play.py
index 4cc0fce66f23536dae04ec6e1e30c29d24849581..f2a1622ee14bd59428c6830f1408f4ccff3cf1ee 100755 (executable)
@@ -160,6 +160,10 @@ supported decoding for these elements."
     Enabling this flag makes the script not decoding the update mesage, because of not\
     supported decoding for these elements."
     parser.add_argument("--mvpn", default=False, action="store_true", help=str_help)
+    str_help = "Open message includes L3VPN-MULTICAST arguments.\
+    Enabling this flag makes the script not decoding the update mesage, because of not\
+    supported decoding for these elements."
+    parser.add_argument("--l3vpn_mcast", default=False, action="store_true", help=str_help)
     parser.add_argument("--wfr", default=10, type=int, help="Wait for read timeout")
     str_help = "Skipping well known attributes for update message"
     parser.add_argument("--skipattr", default=False, action="store_true", help=str_help)
@@ -360,6 +364,7 @@ class MessageGenerator(object):
         self.bgpls = args.bgpls
         self.evpn = args.evpn
         self.mvpn = args.mvpn
+        self.l3vpn_mcast = args.l3vpn_mcast
         self.skipattr = args.skipattr
         # Default values when BGP-LS Attributes are used
         if self.bgpls:
@@ -850,6 +855,28 @@ class MessageGenerator(object):
             )
             optional_parameters_hex += optional_parameter_hex
 
+        if self.l3vpn_mcast:
+            optional_parameter_hex = (
+                "\x02"  # Param type ("Capability Ad")
+                "\x06"  # Length (6 bytes)
+                "\x01"  # Multiprotocol extetension capability,
+                "\x04"  # Capability value length
+                "\x00\x01"  # AFI (IPV4)
+                "\x00"  # (reserved)
+                "\x81"  # SAFI (L3VPN-MCAST)
+            )
+            optional_parameters_hex += optional_parameter_hex
+            optional_parameter_hex = (
+                "\x02"  # Param type ("Capability Ad")
+                "\x06"  # Length (6 bytes)
+                "\x01"  # Multiprotocol extetension capability,
+                "\x04"  # Capability value length
+                "\x00\x02"  # AFI (IPV6)
+                "\x00"  # (reserved)
+                "\x81"  # SAFI (L3VPN-MCAST)
+            )
+            optional_parameters_hex += optional_parameter_hex
+
         optional_parameter_hex = (
             "\x02"  # Param type ("Capability Ad")
             "\x06"  # Length (6 bytes)
@@ -1305,7 +1332,8 @@ class ReadTracker(object):
     for idle waiting.
     """
 
-    def __init__(self, bgp_socket, timer, storage, evpn=False, mvpn=False, wait_for_read=10):
+    def __init__(self, bgp_socket, timer, storage, evpn=False, mvpn=False,
+                 l3vpn_mcast=False, wait_for_read=10):
         """The reader initialisation.
 
         Arguments:
@@ -1314,6 +1342,7 @@ class ReadTracker(object):
             storage: thread safe dict
             evpn: flag that evpn functionality is tested
             mvpn: flag that mvpn functionality is tested
+            l3vpn_mcast: flag that l3vpn_mcast functionality is tested
         """
         # References to outside objects.
         self.socket = bgp_socket
@@ -1337,6 +1366,7 @@ class ReadTracker(object):
         self.storage = storage
         self.evpn = evpn
         self.mvpn = mvpn
+        self.l3vpn_mcast = l3vpn_mcast
         self.wfr = wait_for_read
 
     def read_message_chunk(self):
@@ -1347,7 +1377,6 @@ class ReadTracker(object):
         """
         # TODO: We could return the whole message, currently not needed.
         # We assume the socket is readable.
-        logger.info("READING MESSAGE")
         chunk_message = self.socket.recv(self.bytes_to_read)
         self.msg_in += chunk_message
         self.bytes_to_read -= len(chunk_message)
@@ -1551,6 +1580,11 @@ class ReadTracker(object):
             logger.debug("Skipping update decoding due to mvpn data expected")
             return
 
+        logger.debug("L3vpn-mcast {}".format(self.l3vpn_mcast))
+        if self.l3vpn_mcast:
+            logger.debug("Skipping update decoding due to l3vpn_mcast data expected")
+            return
+
         if msg_type == 2:
             logger.debug("Message type: 0x%s (update)",
                          binascii.b2a_hex(msg_type_hex))
@@ -1716,7 +1750,8 @@ class StateTracker(object):
         self.timer = timer
         # Sub-trackers.
         self.reader = ReadTracker(bgp_socket, timer, storage, evpn=cliargs.evpn,
-                                  mvpn=cliargs.mvpn, wait_for_read=cliargs.wfr)
+                                  mvpn=cliargs.mvpn, l3vpn_mcast=cliargs.l3vpn_mcast,
+                                  wait_for_read=cliargs.wfr)
         self.writer = WriteTracker(bgp_socket, generator, timer)
         # Prioritization state.
         self.prioritize_writing = False