api: refactor to use REPLY_MSG_ID_BASE #define
[vpp.git] / test / vpp_ipsec.py
index 2bf7eda..76080e0 100644 (file)
@@ -217,8 +217,6 @@ class VppIpsecSA(VppObject):
         if (tun_src):
             self.tun_src = ip_address(text_type(tun_src))
             self.flags = self.flags | e.IPSEC_API_SAD_FLAG_IS_TUNNEL
-            if (self.tun_src.version == 6):
-                self.flags = self.flags | e.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6
         if (tun_dst):
             self.tun_dst = ip_address(text_type(tun_dst))
         self.udp_src = udp_src
@@ -267,31 +265,13 @@ class VppIpsecSA(VppObject):
             entry['udp_src_port'] = self.udp_src
         if self.udp_dst:
             entry['udp_dst_port'] = self.udp_dst
-        r = self.test.vapi.ipsec_sad_entry_add_del_v3(is_add=1, entry=entry)
+        r = self.test.vapi.ipsec_sad_entry_add(entry=entry)
         self.stat_index = r.stat_index
         self.test.registry.register(self, self.test.logger)
         return self
 
     def remove_vpp_config(self):
-        r = self.test.vapi.ipsec_sad_entry_add_del_v3(
-            is_add=0,
-            entry={
-                'sad_id': self.id,
-                'spi': self.spi,
-                'integrity_algorithm': self.integ_alg,
-                'integrity_key': {
-                    'length': len(self.integ_key),
-                    'data': self.integ_key,
-                },
-                'crypto_algorithm': self.crypto_alg,
-                'crypto_key': {
-                    'data': self.crypto_key,
-                    'length': len(self.crypto_key),
-                },
-                'protocol': self.proto,
-                'tunnel': self.tunnel_encode(),
-                'salt': self.salt
-            })
+        self.test.vapi.ipsec_sad_entry_del(id=self.id)
 
     def object_id(self):
         return "ipsec-sa-%d" % self.id
@@ -333,6 +313,17 @@ class VppIpsecSA(VppObject):
             # +1 to skip main thread
             return c[worker+1][self.stat_index]
 
+    def get_lost(self, worker=None):
+        c = self.test.statistics.get_counter("/net/ipsec/sa/lost")
+        if worker is None:
+            total = 0
+            for t in c:
+                total += t[self.stat_index]
+            return total
+        else:
+            # +1 to skip main thread
+            return c[worker+1][self.stat_index]
+
 
 class VppIpsecTunProtect(VppObject):
     """