blob: aad87bd591297ff19ad63e223c67766a8aa38fae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.#!/usr/bin/env python3
"""
UDP encap objects
"""
from vpp_object import VppObject
from socket import inet_pton, inet_ntop, AF_INET, AF_INET6
def find_udp_encap(test, ue):
encaps = test.vapi.udp_encap_dump()
for e in encaps:
if ue.id == e.udp_encap.id \
and ue.src_ip == str(e.udp_encap.src_ip) \
and ue.dst_ip == str(e.udp_encap.dst_ip) \
and e.udp_encap.dst_port == ue.dst_port \
and e.udp_encap.src_port == ue.src_port:
return True
return False
class VppUdpEncap(VppObject):
def __init__(self,
test,
src_ip,
dst_ip,
src_port,
dst_port,
table_id=0):
self._test = test
self.table_id = table_id
self.src_ip_s = src_ip
self.dst_ip_s = dst_ip
self.src_ip = src_ip
self.dst_ip = dst_ip
self.src_port = src_port
self.dst_port = dst_port
def add_vpp_config(self):
r = self._test.vapi.udp_encap_add(
self.src_ip,
self.dst_ip,
self.src_port,
self.dst_port,
self.table_id)
self.id = r.id
self._test.registry.register(self, self._test.logger)
def remove_vpp_config(self):
self._test.vapi.udp_encap_del(self.id)
def query_vpp_config(self):
return find_udp_encap(self._test, self)
def object_id(self):
return ("udp-encap-%d" % self.id)
def get_stats(self):
c = self._test.statistics.get_counter("/net/udp-encap")
return c[0][self.id]
|