blob: 5383b07fc4cb6c154cffec257ab3b72d028a3716 [file] [log] [blame]
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001import os
2import fnmatch
3import time
Klement Sekeraf62ae122016-10-11 11:47:09 +02004from hook import Hook
Klement Sekerae4504c62016-12-08 10:16:41 +01005from collections import deque
Klement Sekeraf62ae122016-10-11 11:47:09 +02006
Klement Sekera0e3c0de2016-09-29 14:43:44 +02007# Sphinx creates auto-generated documentation by importing the python source
Klement Sekerada505f62017-01-04 12:58:53 +01008# files and collecting the docstrings from them. The NO_VPP_PAPI flag allows
9# the vpp_papi_provider.py file to be importable without having to build
10# the whole vpp api if the user only wishes to generate the test documentation.
Klement Sekera277b89c2016-10-28 13:20:27 +020011do_import = True
12try:
13 no_vpp_papi = os.getenv("NO_VPP_PAPI")
14 if no_vpp_papi == "1":
15 do_import = False
16except:
17 pass
18
19if do_import:
Ole Troan7e3a8752016-12-05 10:27:09 +010020 from vpp_papi import VPP
Klement Sekera277b89c2016-10-28 13:20:27 +020021
Klement Sekeraf62ae122016-10-11 11:47:09 +020022# from vnet/vnet/mpls/mpls_types.h
23MPLS_IETF_MAX_LABEL = 0xfffff
24MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1
25
Klement Sekera0e3c0de2016-09-29 14:43:44 +020026
Neale Ranns177bbdc2016-11-15 09:46:51 +000027class L2_VTR_OP:
Eyal Bari284293a2017-06-06 14:18:55 +030028 L2_DISABLED = 0
29 L2_PUSH_1 = 1
30 L2_PUSH_2 = 2
Neale Ranns177bbdc2016-11-15 09:46:51 +000031 L2_POP_1 = 3
Eyal Bari284293a2017-06-06 14:18:55 +030032 L2_POP_2 = 4
33 L2_TRANSLATE_1_1 = 5
34 L2_TRANSLATE_1_2 = 6
35 L2_TRANSLATE_2_1 = 7
36 L2_TRANSLATE_2_2 = 8
Neale Ranns177bbdc2016-11-15 09:46:51 +000037
Klement Sekera0e3c0de2016-09-29 14:43:44 +020038
Neale Ranns039cbfe2018-02-27 03:45:38 -080039class QOS_SOURCE:
40 EXT = 0
41 VLAN = 1
42 MPLS = 2
43 IP = 3
44
45
Klement Sekera73884482017-02-23 09:26:30 +010046class UnexpectedApiReturnValueError(Exception):
47 """ exception raised when the API return value is unexpected """
48 pass
49
50
Klement Sekeraf62ae122016-10-11 11:47:09 +020051class VppPapiProvider(object):
52 """VPP-api provider using vpp-papi
53
54 @property hook: hook object providing before and after api/cli hooks
Klement Sekeraf62ae122016-10-11 11:47:09 +020055 """
56
Klement Sekerae0545ef2017-01-25 08:00:40 +010057 _zero, _negative = range(2)
58
Klement Sekera7bb873a2016-11-18 07:38:42 +010059 def __init__(self, name, shm_prefix, test_class):
Klement Sekera277b89c2016-10-28 13:20:27 +020060 self.hook = Hook("vpp-papi-provider")
Klement Sekeraf62ae122016-10-11 11:47:09 +020061 self.name = name
62 self.shm_prefix = shm_prefix
Klement Sekera7bb873a2016-11-18 07:38:42 +010063 self.test_class = test_class
Klement Sekerae0545ef2017-01-25 08:00:40 +010064 self._expect_api_retval = self._zero
65 self._expect_stack = []
Ole Troan7e3a8752016-12-05 10:27:09 +010066 jsonfiles = []
67
Klement Sekera0e3c0de2016-09-29 14:43:44 +020068 install_dir = os.getenv('VPP_TEST_INSTALL_PATH')
Ole Troan7e3a8752016-12-05 10:27:09 +010069 for root, dirnames, filenames in os.walk(install_dir):
70 for filename in fnmatch.filter(filenames, '*.api.json'):
71 jsonfiles.append(os.path.join(root, filename))
72
Ole Troana7564e82018-06-12 21:06:44 +020073 self.vpp = VPP(jsonfiles, logger=test_class.logger, read_timeout=5)
Klement Sekerae4504c62016-12-08 10:16:41 +010074 self._events = deque()
Klement Sekeraf62ae122016-10-11 11:47:09 +020075
Klement Sekerae0545ef2017-01-25 08:00:40 +010076 def __enter__(self):
77 return self
78
79 def expect_negative_api_retval(self):
80 """ Expect API failure """
81 self._expect_stack.append(self._expect_api_retval)
82 self._expect_api_retval = self._negative
83 return self
84
85 def expect_zero_api_retval(self):
86 """ Expect API success """
87 self._expect_stack.append(self._expect_api_retval)
88 self._expect_api_retval = self._zero
89 return self
90
91 def __exit__(self, exc_type, exc_value, traceback):
92 self._expect_api_retval = self._expect_stack.pop()
93
Klement Sekeraf62ae122016-10-11 11:47:09 +020094 def register_hook(self, hook):
95 """Replace hook registration with new hook
96
97 :param hook:
98
99 """
100 self.hook = hook
101
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200102 def collect_events(self):
Klement Sekerae4504c62016-12-08 10:16:41 +0100103 """ Collect all events from the internal queue and clear the queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200104 e = self._events
Klement Sekerae4504c62016-12-08 10:16:41 +0100105 self._events = deque()
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200106 return e
107
108 def wait_for_event(self, timeout, name=None):
Klement Sekerae4504c62016-12-08 10:16:41 +0100109 """ Wait for and return next event. """
Klement Sekeraacb9b8e2017-02-14 02:55:31 +0100110 if name:
Klement Sekeraacb9b8e2017-02-14 02:55:31 +0100111 self.test_class.logger.debug("Expecting event '%s' within %ss",
112 name, timeout)
Eyal Bari20197482017-09-13 12:29:08 +0300113 else:
114 self.test_class.logger.debug("Expecting event within %ss",
115 timeout)
Klement Sekerae4504c62016-12-08 10:16:41 +0100116 if self._events:
117 self.test_class.logger.debug("Not waiting, event already queued")
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200118 limit = time.time() + timeout
119 while time.time() < limit:
120 if self._events:
Klement Sekerae4504c62016-12-08 10:16:41 +0100121 e = self._events.popleft()
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200122 if name and type(e).__name__ != name:
123 raise Exception(
124 "Unexpected event received: %s, expected: %s" %
125 (type(e).__name__, name))
Klement Sekerae4504c62016-12-08 10:16:41 +0100126 self.test_class.logger.debug("Returning event %s:%s" %
127 (name, e))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200128 return e
129 time.sleep(0) # yield
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200130 raise Exception("Event did not occur within timeout")
131
132 def __call__(self, name, event):
Klement Sekerae4504c62016-12-08 10:16:41 +0100133 """ Enqueue event in the internal event queue. """
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200134 # FIXME use the name instead of relying on type(e).__name__ ?
135 # FIXME #2 if this throws, it is eaten silently, Ole?
Klement Sekerae4504c62016-12-08 10:16:41 +0100136 self.test_class.logger.debug("New event: %s: %s" % (name, event))
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200137 self._events.append(event)
138
Klement Sekeraf62ae122016-10-11 11:47:09 +0200139 def connect(self):
140 """Connect the API to VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100141 self.vpp.connect(self.name, self.shm_prefix)
142 self.papi = self.vpp.api
143 self.vpp.register_event_callback(self)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200144
145 def disconnect(self):
146 """Disconnect the API from VPP"""
Klement Sekera7112c542017-03-01 09:53:19 +0100147 self.vpp.disconnect()
Klement Sekeraf62ae122016-10-11 11:47:09 +0200148
149 def api(self, api_fn, api_args, expected_retval=0):
Klement Sekerae4504c62016-12-08 10:16:41 +0100150 """ Call API function and check it's return value.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200151 Call the appropriate hooks before and after the API call
152
153 :param api_fn: API function to call
154 :param api_args: tuple of API function arguments
155 :param expected_retval: Expected return value (Default value = 0)
156 :returns: reply from the API
157
158 """
159 self.hook.before_api(api_fn.__name__, api_args)
Ole Troan7e3a8752016-12-05 10:27:09 +0100160 reply = api_fn(**api_args)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100161 if self._expect_api_retval == self._negative:
162 if hasattr(reply, 'retval') and reply.retval >= 0:
163 msg = "API call passed unexpectedly: expected negative "\
164 "return value instead of %d in %s" % \
165 (reply.retval, repr(reply))
166 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100167 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100168 elif self._expect_api_retval == self._zero:
169 if hasattr(reply, 'retval') and reply.retval != expected_retval:
Neale Ranns88fc83e2017-04-05 08:11:14 -0700170 msg = "API call failed, expected %d return value instead "\
171 "of %d in %s" % (expected_retval, reply.retval,
172 repr(reply))
Klement Sekerae0545ef2017-01-25 08:00:40 +0100173 self.test_class.logger.info(msg)
Klement Sekera73884482017-02-23 09:26:30 +0100174 raise UnexpectedApiReturnValueError(msg)
Klement Sekerae0545ef2017-01-25 08:00:40 +0100175 else:
176 raise Exception("Internal error, unexpected value for "
177 "self._expect_api_retval %s" %
178 self._expect_api_retval)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200179 self.hook.after_api(api_fn.__name__, api_args)
180 return reply
181
182 def cli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100183 """ Execute a CLI, calling the before/after hooks appropriately.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200184
185 :param cli: CLI to execute
186 :returns: CLI output
187
188 """
189 self.hook.before_cli(cli)
190 cli += '\n'
Ole Troan7e3a8752016-12-05 10:27:09 +0100191 r = self.papi.cli_inband(length=len(cli), cmd=cli)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200192 self.hook.after_cli(cli)
Jan49c0fca2016-10-26 15:44:27 +0200193 if hasattr(r, 'reply'):
Ole Troan7e3a8752016-12-05 10:27:09 +0100194 return r.reply.decode().rstrip('\x00')
Klement Sekeraf62ae122016-10-11 11:47:09 +0200195
Jan49c0fca2016-10-26 15:44:27 +0200196 def ppcli(self, cli):
Klement Sekerae4504c62016-12-08 10:16:41 +0100197 """ Helper method to print CLI command in case of info logging level.
Jan49c0fca2016-10-26 15:44:27 +0200198
199 :param cli: CLI to execute
200 :returns: CLI output
201 """
Ed Warnickeb8ff5d62016-11-28 13:59:22 -0600202 return cli + "\n" + str(self.cli(cli))
Jan49c0fca2016-10-26 15:44:27 +0200203
Jan4af521d2016-11-15 17:05:00 +0100204 def _convert_mac(self, mac):
Mohsin Kazmi57938f62017-10-27 21:28:07 +0200205 return mac.replace(':', '').decode('hex')
Jan4af521d2016-11-15 17:05:00 +0100206
Klement Sekeraf62ae122016-10-11 11:47:09 +0200207 def show_version(self):
208 """ """
Klement Sekera7112c542017-03-01 09:53:19 +0100209 return self.api(self.papi.show_version, {})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200210
211 def pg_create_interface(self, pg_index):
212 """
213
214 :param pg_index:
215
216 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100217 return self.api(self.papi.pg_create_interface,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200218 {"interface_id": pg_index})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200219
220 def sw_interface_dump(self, filter=None):
221 """
222
223 :param filter: (Default value = None)
224
225 """
226 if filter is not None:
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200227 args = {"name_filter_valid": 1, "name_filter": filter}
Klement Sekeraf62ae122016-10-11 11:47:09 +0200228 else:
Ole Troan7e3a8752016-12-05 10:27:09 +0100229 args = {}
230 return self.api(self.papi.sw_interface_dump, args)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200231
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000232 def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id):
Klement Sekerae4504c62016-12-08 10:16:41 +0100233 """ Set the IPvX Table-id for the Interface
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000234
235 :param sw_if_index:
236 :param is_ipv6:
237 :param table_id:
238
239 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100240 return self.api(self.papi.sw_interface_set_table,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200241 {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6,
242 'vrf_id': table_id})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000243
Klement Sekeraf62ae122016-10-11 11:47:09 +0200244 def sw_interface_add_del_address(self, sw_if_index, addr, addr_len,
245 is_ipv6=0, is_add=1, del_all=0):
246 """
247
248 :param addr: param is_ipv6: (Default value = 0)
249 :param sw_if_index:
250 :param addr_len:
251 :param is_ipv6: (Default value = 0)
252 :param is_add: (Default value = 1)
253 :param del_all: (Default value = 0)
254
255 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100256 return self.api(self.papi.sw_interface_add_del_address,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200257 {'sw_if_index': sw_if_index,
258 'is_add': is_add,
259 'is_ipv6': is_ipv6,
260 'del_all': del_all,
261 'address_length': addr_len,
262 'address': addr})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200263
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800264 def sw_interface_set_unnumbered(self, sw_if_index, ip_sw_if_index,
265 is_add=1):
266 """ Set the Interface to be unnumbered
267
268 :param is_add: (Default value = 1)
269 :param sw_if_index - interface That will be unnumbered
270 :param ip_sw_if_index - interface with an IP addres
271
272 """
273 return self.api(self.papi.sw_interface_set_unnumbered,
274 {'sw_if_index': ip_sw_if_index,
275 'unnumbered_sw_if_index': sw_if_index,
276 'is_add': is_add})
277
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000278 def sw_interface_enable_disable_mpls(self, sw_if_index,
279 is_enable=1):
280 """
281 Enable/Disable MPLS on the interface
282 :param sw_if_index:
283 :param is_enable: (Default value = 1)
284
285 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100286 return self.api(self.papi.sw_interface_set_mpls_enable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200287 {'sw_if_index': sw_if_index,
288 'enable': is_enable})
Neale Ranns8fe8cc22016-11-01 10:05:08 +0000289
Jan Gelety057bb8c2016-12-20 17:32:45 +0100290 def sw_interface_ra_suppress(self, sw_if_index, suppress=1):
Ole Troan7e3a8752016-12-05 10:27:09 +0100291 return self.api(self.papi.sw_interface_ip6nd_ra_config,
Jan Gelety057bb8c2016-12-20 17:32:45 +0100292 {'sw_if_index': sw_if_index,
293 'suppress': suppress})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200294
Neale Ranns227038a2017-04-21 01:07:59 -0700295 def set_ip_flow_hash(self,
296 table_id,
297 src=1,
298 dst=1,
299 sport=1,
300 dport=1,
301 proto=1,
302 reverse=0,
303 is_ip6=0):
304 return self.api(self.papi.set_ip_flow_hash,
305 {'vrf_id': table_id,
306 'src': src,
307 'dst': dst,
308 'dport': dport,
309 'sport': sport,
310 'proto': proto,
311 'reverse': reverse,
312 'is_ipv6': is_ip6})
313
Neale Ranns3f844d02017-02-18 00:03:54 -0800314 def ip6_nd_proxy(self, address, sw_if_index, is_del=0):
315 return self.api(self.papi.ip6nd_proxy_add_del,
316 {'address': address,
317 'sw_if_index': sw_if_index,
318 'is_del': is_del})
319
Neale Ranns75152282017-01-09 01:00:45 -0800320 def ip6_sw_interface_ra_config(self, sw_if_index,
Neale Ranns32e1c012016-11-22 17:07:28 +0000321 no,
Neale Ranns75152282017-01-09 01:00:45 -0800322 suppress,
Neale Ranns32e1c012016-11-22 17:07:28 +0000323 send_unicast):
Neale Ranns75152282017-01-09 01:00:45 -0800324 return self.api(self.papi.sw_interface_ip6nd_ra_config,
325 {'sw_if_index': sw_if_index,
Neale Ranns32e1c012016-11-22 17:07:28 +0000326 'is_no': no,
Klement Sekerada505f62017-01-04 12:58:53 +0100327 'suppress': suppress,
328 'send_unicast': send_unicast})
Neale Ranns75152282017-01-09 01:00:45 -0800329
Neale Ranns87df12d2017-02-18 08:16:41 -0800330 def ip6_sw_interface_ra_prefix(self,
331 sw_if_index,
332 address,
333 address_length,
334 use_default=0,
335 no_advertise=0,
336 off_link=0,
337 no_autoconfig=0,
338 no_onlink=0,
339 is_no=0,
340 val_lifetime=0xffffffff,
341 pref_lifetime=0xffffffff):
342 return self.api(self.papi.sw_interface_ip6nd_ra_prefix,
343 {'sw_if_index': sw_if_index,
344 'address': address,
345 'address_length': address_length,
346 'use_default': use_default,
347 'no_advertise': no_advertise,
348 'off_link': off_link,
349 'no_autoconfig': no_autoconfig,
350 'no_onlink': no_onlink,
351 'is_no': is_no,
352 'val_lifetime': val_lifetime,
353 'pref_lifetime': pref_lifetime})
354
Neale Ranns75152282017-01-09 01:00:45 -0800355 def ip6_sw_interface_enable_disable(self, sw_if_index, enable):
356 """
357 Enable/Disable An interface for IPv6
358 """
359 return self.api(self.papi.sw_interface_ip6_enable_disable,
360 {'sw_if_index': sw_if_index,
361 'enable': enable})
362
Klement Sekeraf62ae122016-10-11 11:47:09 +0200363 def vxlan_add_del_tunnel(
364 self,
365 src_addr,
366 dst_addr,
Eyal Baric5b13602016-11-24 19:42:43 +0200367 mcast_sw_if_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200368 is_add=1,
369 is_ipv6=0,
370 encap_vrf_id=0,
371 decap_next_index=0xFFFFFFFF,
Jon Loeliger3d460bd2018-02-01 16:36:12 -0600372 vni=0,
373 instance=0xFFFFFFFF):
Klement Sekeraf62ae122016-10-11 11:47:09 +0200374 """
375
376 :param dst_addr:
377 :param src_addr:
378 :param is_add: (Default value = 1)
379 :param is_ipv6: (Default value = 0)
380 :param encap_vrf_id: (Default value = 0)
381 :param decap_next_index: (Default value = 0xFFFFFFFF)
Eyal Baric5b13602016-11-24 19:42:43 +0200382 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200383 :param vni: (Default value = 0)
Jon Loeliger3d460bd2018-02-01 16:36:12 -0600384 :param instance: (Default value = 0xFFFFFFFF)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200385
386 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100387 return self.api(self.papi.vxlan_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200388 {'is_add': is_add,
389 'is_ipv6': is_ipv6,
390 'src_address': src_addr,
391 'dst_address': dst_addr,
392 'mcast_sw_if_index': mcast_sw_if_index,
393 'encap_vrf_id': encap_vrf_id,
394 'decap_next_index': decap_next_index,
Jon Loeliger3d460bd2018-02-01 16:36:12 -0600395 'vni': vni,
396 'instance': instance})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200397
Marco Varleseb598f1d2017-09-19 14:25:28 +0200398 def geneve_add_del_tunnel(
399 self,
400 local_addr,
401 remote_addr,
402 mcast_sw_if_index=0xFFFFFFFF,
403 is_add=1,
404 is_ipv6=0,
405 encap_vrf_id=0,
406 decap_next_index=0xFFFFFFFF,
407 vni=0):
408 """
409
410 :param remote_addr:
411 :param local_addr:
412 :param is_add: (Default value = 1)
413 :param is_ipv6: (Default value = 0)
414 :param encap_vrf_id: (Default value = 0)
415 :param decap_next_index: (Default value = 0xFFFFFFFF)
416 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
417 :param vni: (Default value = 0)
418
419 """
420 return self.api(self.papi.geneve_add_del_tunnel,
421 {'is_add': is_add,
422 'is_ipv6': is_ipv6,
423 'local_address': local_addr,
424 'remote_address': remote_addr,
425 'mcast_sw_if_index': mcast_sw_if_index,
426 'encap_vrf_id': encap_vrf_id,
427 'decap_next_index': decap_next_index,
428 'vni': vni})
429
Jan4af521d2016-11-15 17:05:00 +0100430 def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1,
431 learn=1, arp_term=0, is_add=1):
432 """Create/delete bridge domain.
433
434 :param int bd_id: Bridge domain index.
435 :param int flood: Enable/disable bcast/mcast flooding in the BD.
436 (Default value = 1)
437 :param int uu_flood: Enable/disable unknown unicast flood in the BD.
438 (Default value = 1)
439 :param int forward: Enable/disable forwarding on all interfaces in
440 the BD. (Default value = 1)
441 :param int learn: Enable/disable learning on all interfaces in the BD.
442 (Default value = 1)
443 :param int arp_term: Enable/disable arp termination in the BD.
444 (Default value = 1)
445 :param int is_add: Add or delete flag. (Default value = 1)
446 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100447 return self.api(self.papi.bridge_domain_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200448 {'bd_id': bd_id,
449 'flood': flood,
450 'uu_flood': uu_flood,
451 'forward': forward,
452 'learn': learn,
453 'arp_term': arp_term,
454 'is_add': is_add})
Jan4af521d2016-11-15 17:05:00 +0100455
Eyal Baric86e5922017-07-02 18:33:16 +0300456 def bd_ip_mac_add_del(self, bd_id, mac, ip, is_ipv6=0, is_add=1):
457 return self.api(self.papi.bd_ip_mac_add_del,
458 {'bd_id': bd_id,
459 'is_add': is_add,
460 'is_ipv6': is_ipv6,
461 'ip_address': ip,
462 'mac_address': mac})
463
Eyal Bari20197482017-09-13 12:29:08 +0300464 def want_ip4_arp_events(self, enable_disable=1, address=0):
465 return self.api(self.papi.want_ip4_arp_events,
466 {'enable_disable': enable_disable,
467 'address': address,
468 'pid': os.getpid(), })
469
Eyal Baric125ecc2017-09-20 11:29:17 +0300470 def want_ip6_nd_events(self, enable_disable=1, address=0):
471 return self.api(self.papi.want_ip6_nd_events,
472 {'enable_disable': enable_disable,
473 'address': address,
474 'pid': os.getpid(), })
475
Juraj Sloboda4b9669d2018-01-15 10:39:21 +0100476 def want_ip6_ra_events(self, enable_disable=1):
477 return self.api(self.papi.want_ip6_ra_events,
478 {'enable_disable': enable_disable,
479 'pid': os.getpid(), })
480
481 def ip6nd_send_router_solicitation(self, sw_if_index, irt=1, mrt=120,
482 mrc=0, mrd=0):
483 return self.api(self.papi.ip6nd_send_router_solicitation,
484 {'irt': irt,
485 'mrt': mrt,
486 'mrc': mrc,
487 'mrd': mrd,
488 'sw_if_index': sw_if_index})
489
Juraj Slobodac0374232018-02-01 15:18:49 +0100490 def ip6_nd_address_autoconfig(self, sw_if_index, enable,
491 install_default_routes):
492 return self.api(self.papi.ip6_nd_address_autoconfig,
493 {'sw_if_index': sw_if_index,
494 'enable': enable,
495 'install_default_routes': install_default_routes})
496
Eyal Bari24db0ec2017-09-27 21:43:51 +0300497 def want_macs_learn_events(self, enable_disable=1, scan_delay=0,
498 max_macs_in_event=0, learn_limit=0):
499 return self.api(self.papi.want_l2_macs_events,
500 {'enable_disable': enable_disable,
501 'scan_delay': scan_delay,
502 'max_macs_in_event': max_macs_in_event,
503 'learn_limit': learn_limit,
504 'pid': os.getpid(), })
505
Juraj Slobodadd3b8f72018-05-04 14:20:06 +0200506 def want_dhcp6_reply_events(self, enable_disable=1):
507 return self.api(self.papi.want_dhcp6_reply_events,
508 {'enable_disable': enable_disable,
509 'pid': os.getpid()})
510
Juraj Sloboda81119e82018-05-25 14:02:20 +0200511 def want_dhcp6_pd_reply_events(self, enable_disable=1):
512 return self.api(self.papi.want_dhcp6_pd_reply_events,
513 {'enable_disable': enable_disable,
514 'pid': os.getpid()})
515
516 def dhcp6_clients_enable_disable(self, enable=1):
517 return self.api(self.papi.dhcp6_clients_enable_disable,
518 {'enable': enable})
519
Juraj Slobodadd3b8f72018-05-04 14:20:06 +0200520 def dhcp6_send_client_message(self, msg_type, sw_if_index, T1, T2,
521 addresses, server_index=0xFFFFFFFF,
522 irt=0, mrt=0, mrc=1, mrd=0, stop=0,
523 ):
524 return self.api(self.papi.dhcp6_send_client_message,
525 {'sw_if_index': sw_if_index,
526 'server_index': server_index,
527 'irt': irt,
528 'mrt': mrt,
529 'mrc': mrc,
530 'mrd': mrd,
531 'stop': stop,
532 'msg_type': msg_type,
533 'T1': T1,
534 'T2': T2,
535 'n_addresses': len(addresses),
536 'addresses': addresses})
537
Juraj Sloboda81119e82018-05-25 14:02:20 +0200538 def dhcp6_pd_send_client_message(self, msg_type, sw_if_index, T1, T2,
539 prefixes, server_index=0xFFFFFFFF,
540 irt=0, mrt=0, mrc=1, mrd=0, stop=0,
541 ):
542 return self.api(self.papi.dhcp6_pd_send_client_message,
543 {'sw_if_index': sw_if_index,
544 'server_index': server_index,
545 'irt': irt,
546 'mrt': mrt,
547 'mrc': mrc,
548 'mrd': mrd,
549 'stop': stop,
550 'msg_type': msg_type,
551 'T1': T1,
552 'T2': T2,
553 'n_prefixes': len(prefixes),
554 'prefixes': prefixes})
555
Juraj Slobodadd3b8f72018-05-04 14:20:06 +0200556 def dhcp6_client_enable_disable(self, sw_if_index, prefix_group='',
557 enable=1):
558 return self.api(self.papi.dhcp6_client_enable_disable,
559 {'sw_if_index': sw_if_index,
560 'enable': enable})
561
Juraj Sloboda81119e82018-05-25 14:02:20 +0200562 def dhcp6_pd_client_enable_disable(self, sw_if_index, prefix_group='',
563 enable=1):
564 return self.api(self.papi.dhcp6_pd_client_enable_disable,
565 {'sw_if_index': sw_if_index,
566 'prefix_group': prefix_group,
567 'enable': enable})
568
569 def ip6_add_del_address_using_prefix(self, sw_if_index, address,
570 prefix_length, prefix_group,
571 is_add=1):
572 return self.api(self.papi.ip6_add_del_address_using_prefix,
573 {'sw_if_index': sw_if_index,
574 'prefix_group': prefix_group,
575 'address': address,
576 'prefix_length': prefix_length,
577 'is_add': is_add})
578
Jan4af521d2016-11-15 17:05:00 +0100579 def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0,
580 filter_mac=0, bvi_mac=0):
581 """Create/delete L2 FIB entry.
582
583 :param str mac: MAC address to create FIB entry for.
584 :param int bd_id: Bridge domain index.
585 :param int sw_if_index: Software interface index of the interface.
586 :param int is_add: Add or delete flag. (Default value = 1)
587 :param int static_mac: Set to 1 to create static MAC entry.
588 (Default value = 0)
589 :param int filter_mac: Set to 1 to drop packet that's source or
590 destination MAC address contains defined MAC address.
591 (Default value = 0)
592 :param int bvi_mac: Set to 1 to create entry that points to BVI
593 interface. (Default value = 0)
594 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100595 return self.api(self.papi.l2fib_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200596 {'mac': self._convert_mac(mac),
597 'bd_id': bd_id,
598 'sw_if_index': sw_if_index,
599 'is_add': is_add,
600 'static_mac': static_mac,
601 'filter_mac': filter_mac,
602 'bvi_mac': bvi_mac})
Jan4af521d2016-11-15 17:05:00 +0100603
Eyal Bari93b503e2017-05-15 10:13:15 +0300604 def l2fib_flush_int(self, sw_if_index):
605 """Flush L2 FIB entries for sw_if_index.
606
607 :param int sw_if_index: Software interface index of the interface.
608 """
609 return self.api(self.papi.l2fib_flush_int,
610 {'sw_if_index': sw_if_index})
611
612 def l2fib_flush_bd(self, bd_id):
613 """Flush L2 FIB entries for bd_id.
614
615 :param int sw_if_index: Bridge Domain id.
616 """
617 return self.api(self.papi.l2fib_flush_bd,
618 {'bd_id': bd_id})
619
620 def l2fib_flush_all(self):
621 """Flush all L2 FIB.
622 """
623 return self.api(self.papi.l2fib_flush_all, {})
624
Klement Sekeraf62ae122016-10-11 11:47:09 +0200625 def sw_interface_set_l2_bridge(self, sw_if_index, bd_id,
626 shg=0, bvi=0, enable=1):
Jan4af521d2016-11-15 17:05:00 +0100627 """Add/remove interface to/from bridge domain.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200628
Jan4af521d2016-11-15 17:05:00 +0100629 :param int sw_if_index: Software interface index of the interface.
630 :param int bd_id: Bridge domain index.
631 :param int shg: Split-horizon group index. (Default value = 0)
632 :param int bvi: Set interface as a bridge group virtual interface.
633 (Default value = 0)
634 :param int enable: Add or remove interface. (Default value = 1)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200635 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100636 return self.api(self.papi.sw_interface_set_l2_bridge,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200637 {'rx_sw_if_index': sw_if_index,
638 'bd_id': bd_id,
639 'shg': shg,
640 'bvi': bvi,
641 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200642
Jan00dad122016-11-29 10:04:53 +0100643 def bridge_flags(self, bd_id, is_set, feature_bitmap):
Chris Luked0421942018-04-10 15:19:54 -0400644 """Enable/disable required feature of the bridge domain with defined
645 ID.
Jan00dad122016-11-29 10:04:53 +0100646
647 :param int bd_id: Bridge domain ID.
648 :param int is_set: Set to 1 to enable, set to 0 to disable the feature.
649 :param int feature_bitmap: Bitmap value of the feature to be set:
650 - learn (1 << 0),
651 - forward (1 << 1),
652 - flood (1 << 2),
653 - uu-flood (1 << 3) or
654 - arp-term (1 << 4).
655 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100656 return self.api(self.papi.bridge_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200657 {'bd_id': bd_id,
658 'is_set': is_set,
659 'feature_bitmap': feature_bitmap})
Jan00dad122016-11-29 10:04:53 +0100660
661 def bridge_domain_dump(self, bd_id=0):
662 """
663
664 :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all
665 existing bridge domains returned)
666 :return: Dictionary of bridge domain(s) data.
667 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100668 return self.api(self.papi.bridge_domain_dump,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200669 {'bd_id': bd_id})
Jan00dad122016-11-29 10:04:53 +0100670
Klement Sekeraf62ae122016-10-11 11:47:09 +0200671 def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index,
672 enable):
673 """Create or delete unidirectional cross-connect from Tx interface to
674 Rx interface.
675
Jan4af521d2016-11-15 17:05:00 +0100676 :param int rx_sw_if_index: Software interface index of Rx interface.
677 :param int tx_sw_if_index: Software interface index of Tx interface.
678 :param int enable: Create cross-connect if equal to 1, delete
679 cross-connect if equal to 0.
Klement Sekeraf62ae122016-10-11 11:47:09 +0200680
681 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100682 return self.api(self.papi.sw_interface_set_l2_xconnect,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200683 {'rx_sw_if_index': rx_sw_if_index,
684 'tx_sw_if_index': tx_sw_if_index,
685 'enable': enable})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200686
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200687 def sw_interface_set_l2_tag_rewrite(
688 self,
689 sw_if_index,
690 vtr_oper,
691 push=0,
692 tag1=0,
693 tag2=0):
Neale Ranns177bbdc2016-11-15 09:46:51 +0000694 """L2 interface vlan tag rewrite configure request
695 :param client_index - opaque cookie to identify the sender
696 :param context - sender context, to match reply w/ request
697 :param sw_if_index - interface the operation is applied to
698 :param vtr_op - Choose from l2_vtr_op_t enum values
699 :param push_dot1q - first pushed flag dot1q id set, else dot1ad
700 :param tag1 - Needed for any push or translate vtr op
701 :param tag2 - Needed for any push 2 or translate x-2 vtr ops
702
703 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100704 return self.api(self.papi.l2_interface_vlan_tag_rewrite,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200705 {'sw_if_index': sw_if_index,
706 'vtr_op': vtr_oper,
707 'push_dot1q': push,
708 'tag1': tag1,
709 'tag2': tag2})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000710
Neale Ranns55d03782017-10-21 06:34:22 -0700711 def sw_interface_set_l2_emulation(
712 self,
713 sw_if_index,
714 enable=1):
715 """L2 Emulation
716 :param sw_if_index - interface the operation is applied to
717
718 """
719 return self.api(self.papi.l2_emulation,
720 {'sw_if_index': sw_if_index,
721 'enable': enable})
722
Neale Rannsa07bd702017-08-07 07:53:49 -0700723 def sw_interface_set_flags(self, sw_if_index, admin_up_down):
Klement Sekeraf62ae122016-10-11 11:47:09 +0200724 """
725
726 :param admin_up_down:
727 :param sw_if_index:
Klement Sekeraf62ae122016-10-11 11:47:09 +0200728
729 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100730 return self.api(self.papi.sw_interface_set_flags,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200731 {'sw_if_index': sw_if_index,
Neale Rannsa07bd702017-08-07 07:53:49 -0700732 'admin_up_down': admin_up_down})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200733
Ole Troand7231612018-06-07 10:17:57 +0200734 def sw_interface_set_mtu(self, sw_if_index, mtu=[0, 0, 0, 0]):
Neale Rannsffd78d12018-02-09 06:05:16 -0800735 """
736 :param sw_if_index:
737 :param mtu:
738
739 """
740 return self.api(self.papi.sw_interface_set_mtu,
741 {'sw_if_index': sw_if_index,
742 'mtu': mtu})
743
Neale Ranns25b04942018-04-04 09:34:50 -0700744 def sw_interface_set_promiscuous(self, sw_if_index, enable):
745 """
746 :param sw_if_index:
747 :param enable:
748
749 """
750 return self.api(self.papi.sw_interface_set_promiscuous,
751 {'sw_if_index': sw_if_index,
752 'enable': enable})
753
Neale Rannsc819fc62018-02-16 02:44:05 -0800754 def sw_interface_set_mac_address(self, sw_if_index, mac):
755 return self.api(self.papi.sw_interface_set_mac_address,
756 {'sw_if_index': sw_if_index,
757 'mac_address': mac})
758
Klement Sekeraf62ae122016-10-11 11:47:09 +0200759 def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan,
760 no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0,
761 default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0):
762 """Create subinterface
763 from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad
764
765 :param sub_id: param inner_vlan:
766 :param sw_if_index:
767 :param outer_vlan:
768 :param inner_vlan:
769 :param no_tags: (Default value = 0)
770 :param one_tag: (Default value = 0)
771 :param two_tags: (Default value = 0)
772 :param dot1ad: (Default value = 0)
773 :param exact_match: (Default value = 0)
774 :param default_sub: (Default value = 0)
775 :param outer_vlan_id_any: (Default value = 0)
776 :param inner_vlan_id_any: (Default value = 0)
777
778 """
779 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100780 self.papi.create_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200781 {'sw_if_index': sw_if_index,
782 'sub_id': sub_id,
783 'no_tags': no_tags,
784 'one_tag': one_tag,
785 'two_tags': two_tags,
786 'dot1ad': dot1ad,
787 'exact_match': exact_match,
788 'default_sub': default_sub,
789 'outer_vlan_id_any': outer_vlan_id_any,
790 'inner_vlan_id_any': inner_vlan_id_any,
791 'outer_vlan_id': outer_vlan,
792 'inner_vlan_id': inner_vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200793
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200794 def create_p2pethernet_subif(self, sw_if_index, remote_mac, subif_id):
795 """Create p2p ethernet subinterface
796
797 :param sw_if_index: main (parent) interface
798 :param remote_mac: client (remote) mac address
799
800 """
801 return self.api(
802 self.papi.p2p_ethernet_add,
803 {'parent_if_index': sw_if_index,
804 'remote_mac': remote_mac,
805 'subif_id': subif_id})
806
Neale Ranns177bbdc2016-11-15 09:46:51 +0000807 def delete_subif(self, sw_if_index):
808 """Delete subinterface
809
810 :param sw_if_index:
811 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100812 return self.api(self.papi.delete_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200813 {'sw_if_index': sw_if_index})
Neale Ranns177bbdc2016-11-15 09:46:51 +0000814
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200815 def delete_p2pethernet_subif(self, sw_if_index, remote_mac):
816 """Delete p2p ethernet subinterface
817
818 :param sw_if_index: main (parent) interface
819 :param remote_mac: client (remote) mac address
820
821 """
822 return self.api(
823 self.papi.p2p_ethernet_del,
824 {'parent_if_index': sw_if_index,
825 'remote_mac': remote_mac})
826
Klement Sekeraf62ae122016-10-11 11:47:09 +0200827 def create_vlan_subif(self, sw_if_index, vlan):
828 """
829
830 :param vlan:
831 :param sw_if_index:
832
833 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100834 return self.api(self.papi.create_vlan_subif,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200835 {'sw_if_index': sw_if_index,
836 'vlan_id': vlan})
Klement Sekeraf62ae122016-10-11 11:47:09 +0200837
Matej Klotton0178d522016-11-04 11:11:44 +0100838 def create_loopback(self, mac=''):
839 """
840
841 :param mac: (Optional)
842 """
Ole Troan7e3a8752016-12-05 10:27:09 +0100843 return self.api(self.papi.create_loopback,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200844 {'mac_address': mac})
Matej Klotton0178d522016-11-04 11:11:44 +0100845
Matej Klotton8d8a1da2016-12-22 11:06:56 +0100846 def delete_loopback(self, sw_if_index):
847 return self.api(self.papi.delete_loopback,
848 {'sw_if_index': sw_if_index, })
849
Neale Ranns15002542017-09-10 04:39:11 -0700850 def ip_table_add_del(self,
851 table_id,
852 is_add=1,
853 is_ipv6=0):
854 """
855
856 :param table_id
857 :param is_add: (Default value = 1)
858 :param is_ipv6: (Default value = 0)
859
860 """
861
862 return self.api(
863 self.papi.ip_table_add_del,
864 {'table_id': table_id,
865 'is_add': is_add,
866 'is_ipv6': is_ipv6})
867
Klement Sekeraf62ae122016-10-11 11:47:09 +0200868 def ip_add_del_route(
869 self,
870 dst_address,
871 dst_address_length,
872 next_hop_address,
873 next_hop_sw_if_index=0xFFFFFFFF,
874 table_id=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200875 next_hop_table_id=0,
Neale Rannsad422ed2016-11-02 14:20:04 +0000876 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200877 next_hop_n_out_labels=0,
878 next_hop_out_label_stack=[],
879 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Ranns810086d2017-11-05 16:26:46 -0800880 next_hop_id=0xFFFFFFFF,
Neale Rannsad422ed2016-11-02 14:20:04 +0000881 is_resolve_host=0,
882 is_resolve_attached=0,
883 classify_table_index=0xFFFFFFFF,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200884 is_add=1,
885 is_drop=0,
Juraj Sloboda86a2c572016-10-27 10:44:25 +0200886 is_unreach=0,
887 is_prohibit=0,
Klement Sekeraf62ae122016-10-11 11:47:09 +0200888 is_ipv6=0,
889 is_local=0,
890 is_classify=0,
891 is_multipath=0,
Neale Rannsf068c3e2018-01-03 04:18:48 -0800892 is_dvr=0,
Neale Ranns810086d2017-11-05 16:26:46 -0800893 is_udp_encap=0,
Marek Gradzki0164a062017-10-13 10:22:59 +0200894 is_source_lookup=0):
Klement Sekeraf62ae122016-10-11 11:47:09 +0200895 """
896
897 :param dst_address_length:
898 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
899 :param dst_address:
900 :param next_hop_address:
901 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
902 :param vrf_id: (Default value = 0)
903 :param lookup_in_vrf: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200904 :param classify_table_index: (Default value = 0xFFFFFFFF)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200905 :param is_add: (Default value = 1)
906 :param is_drop: (Default value = 0)
907 :param is_ipv6: (Default value = 0)
908 :param is_local: (Default value = 0)
909 :param is_classify: (Default value = 0)
910 :param is_multipath: (Default value = 0)
911 :param is_resolve_host: (Default value = 0)
912 :param is_resolve_attached: (Default value = 0)
Neale Rannsf068c3e2018-01-03 04:18:48 -0800913 :param is_dvr: (Default value = 0)
Neale Ranns054c03a2017-10-13 05:15:07 -0700914 :param is_source_lookup: (Default value = 0)
Klement Sekeraf62ae122016-10-11 11:47:09 +0200915 :param next_hop_weight: (Default value = 1)
916
917 """
Neale Rannsad422ed2016-11-02 14:20:04 +0000918
Klement Sekeraf62ae122016-10-11 11:47:09 +0200919 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100920 self.papi.ip_add_del_route,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200921 {'next_hop_sw_if_index': next_hop_sw_if_index,
922 'table_id': table_id,
923 'classify_table_index': classify_table_index,
924 'next_hop_table_id': next_hop_table_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200925 'is_add': is_add,
926 'is_drop': is_drop,
927 'is_unreach': is_unreach,
928 'is_prohibit': is_prohibit,
929 'is_ipv6': is_ipv6,
930 'is_local': is_local,
931 'is_classify': is_classify,
932 'is_multipath': is_multipath,
933 'is_resolve_host': is_resolve_host,
934 'is_resolve_attached': is_resolve_attached,
Neale Rannsf068c3e2018-01-03 04:18:48 -0800935 'is_dvr': is_dvr,
Neale Ranns054c03a2017-10-13 05:15:07 -0700936 'is_source_lookup': is_source_lookup,
Neale Ranns810086d2017-11-05 16:26:46 -0800937 'is_udp_encap': is_udp_encap,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200938 'next_hop_weight': next_hop_weight,
939 'dst_address_length': dst_address_length,
940 'dst_address': dst_address,
Neale Ranns810086d2017-11-05 16:26:46 -0800941 'next_hop_id': next_hop_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200942 'next_hop_address': next_hop_address,
943 'next_hop_n_out_labels': next_hop_n_out_labels,
944 'next_hop_via_label': next_hop_via_label,
945 'next_hop_out_label_stack': next_hop_out_label_stack})
Matej Klotton0178d522016-11-04 11:11:44 +0100946
Matej Klotton16a14cd2016-12-07 15:09:13 +0100947 def ip_fib_dump(self):
948 return self.api(self.papi.ip_fib_dump, {})
949
Jan Gelety057bb8c2016-12-20 17:32:45 +0100950 def ip6_fib_dump(self):
951 return self.api(self.papi.ip6_fib_dump, {})
952
Matej Klotton0178d522016-11-04 11:11:44 +0100953 def ip_neighbor_add_del(self,
954 sw_if_index,
955 mac_address,
956 dst_address,
Matej Klotton0178d522016-11-04 11:11:44 +0100957 is_add=1,
958 is_ipv6=0,
959 is_static=0,
Neale Rannsb3b2de72017-03-08 05:17:22 -0800960 is_no_adj_fib=0,
Matej Klotton0178d522016-11-04 11:11:44 +0100961 ):
962 """ Add neighbor MAC to IPv4 or IPv6 address.
963
964 :param sw_if_index:
965 :param mac_address:
966 :param dst_address:
Matej Klotton0178d522016-11-04 11:11:44 +0100967 :param is_add: (Default value = 1)
968 :param is_ipv6: (Default value = 0)
969 :param is_static: (Default value = 0)
Neale Rannsb3b2de72017-03-08 05:17:22 -0800970 :param is_no_adj_fib: (Default value = 0)
Matej Klotton0178d522016-11-04 11:11:44 +0100971 """
972
973 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +0100974 self.papi.ip_neighbor_add_del,
Neale Rannsbaf2e902017-02-25 04:20:00 -0800975 {'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200976 'is_add': is_add,
977 'is_ipv6': is_ipv6,
978 'is_static': is_static,
Neale Rannsb3b2de72017-03-08 05:17:22 -0800979 'is_no_adj_fib': is_no_adj_fib,
Klement Sekera0e3c0de2016-09-29 14:43:44 +0200980 'mac_address': mac_address,
981 'dst_address': dst_address
Ole Troan7e3a8752016-12-05 10:27:09 +0100982 }
Matej Klotton0178d522016-11-04 11:11:44 +0100983 )
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +0100984
Neale Ranns39f9d8b2017-02-16 21:57:05 -0800985 def ip_neighbor_dump(self,
986 sw_if_index,
987 is_ipv6=0):
988 """ Return IP neighbor dump.
989
990 :param sw_if_index:
991 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
992 """
993
994 return self.api(
995 self.papi.ip_neighbor_dump,
996 {'is_ipv6': is_ipv6,
997 'sw_if_index': sw_if_index
998 }
999 )
1000
1001 def proxy_arp_add_del(self,
1002 low_address,
1003 hi_address,
1004 vrf_id=0,
1005 is_add=1):
1006 """ Config Proxy Arp Range.
1007
1008 :param low_address: Start address in the rnage to Proxy for
1009 :param hi_address: End address in the rnage to Proxy for
1010 :param vrf_id: The VRF/table in which to proxy
1011 """
1012
1013 return self.api(
1014 self.papi.proxy_arp_add_del,
Neale Ranns0053de62018-05-22 08:40:52 -07001015 {'proxy':
1016 {
1017 'vrf_id': vrf_id,
1018 'low_address': low_address,
1019 'hi_address': hi_address,
1020 },
1021 'is_add': is_add})
Neale Ranns39f9d8b2017-02-16 21:57:05 -08001022
1023 def proxy_arp_intfc_enable_disable(self,
1024 sw_if_index,
1025 is_enable=1):
1026 """ Enable/Disable an interface for proxy ARP requests
1027
1028 :param sw_if_index: Interface
1029 :param enable_disable: Enable/Disable
1030 """
1031
1032 return self.api(
1033 self.papi.proxy_arp_intfc_enable_disable,
1034 {'sw_if_index': sw_if_index,
1035 'enable_disable': is_enable
1036 }
1037 )
1038
Jane546d3b2016-12-08 13:10:03 +01001039 def reset_vrf(self,
1040 vrf_id,
1041 is_ipv6=0,
1042 ):
1043 """ Reset VRF (remove all routes etc.) request.
1044
1045 :param int vrf_id: ID of the FIB table / VRF to reset.
1046 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
1047 """
1048
1049 return self.api(
1050 self.papi.reset_vrf,
1051 {'vrf_id': vrf_id,
1052 'is_ipv6': is_ipv6,
1053 }
1054 )
1055
1056 def reset_fib(self,
1057 vrf_id,
1058 is_ipv6=0,
1059 ):
1060 """ Reset VRF (remove all routes etc.) request.
1061
1062 :param int vrf_id: ID of the FIB table / VRF to reset.
1063 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
1064 """
1065
1066 return self.api(
1067 self.papi.reset_fib,
1068 {'vrf_id': vrf_id,
1069 'is_ipv6': is_ipv6,
1070 }
1071 )
1072
1073 def ip_dump(self,
1074 is_ipv6=0,
1075 ):
1076 """ Return IP dump.
1077
1078 :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
1079 """
1080
1081 return self.api(
1082 self.papi.ip_dump,
1083 {'is_ipv6': is_ipv6,
1084 }
1085 )
1086
Klement Sekera7bb873a2016-11-18 07:38:42 +01001087 def sw_interface_span_enable_disable(
Eyal Bari001fd402017-07-16 09:34:53 +03001088 self, sw_if_index_from, sw_if_index_to, state=1, is_l2=0):
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +01001089 """
1090
1091 :param sw_if_index_from:
1092 :param sw_if_index_to:
Matej Klottondeb69842016-12-09 15:05:46 +01001093 :param state:
Eyal Bari001fd402017-07-16 09:34:53 +03001094 :param is_l2:
Pavel Kotucekf6e3dc42016-11-04 09:58:01 +01001095 """
Ole Troan7e3a8752016-12-05 10:27:09 +01001096 return self.api(self.papi.sw_interface_span_enable_disable,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001097 {'sw_if_index_from': sw_if_index_from,
1098 'sw_if_index_to': sw_if_index_to,
Eyal Bari001fd402017-07-16 09:34:53 +03001099 'state': state,
1100 'is_l2': is_l2,
1101 })
Neale Ranns177bbdc2016-11-15 09:46:51 +00001102
1103 def gre_tunnel_add_del(self,
1104 src_address,
1105 dst_address,
1106 outer_fib_id=0,
John Loa43ccae2018-02-13 17:15:23 -05001107 tunnel_type=0,
1108 instance=0xFFFFFFFF,
1109 session_id=0,
Neale Ranns177bbdc2016-11-15 09:46:51 +00001110 is_add=1,
1111 is_ip6=0):
1112 """ Add a GRE tunnel
1113
1114 :param src_address:
1115 :param dst_address:
1116 :param outer_fib_id: (Default value = 0)
John Loa43ccae2018-02-13 17:15:23 -05001117 :param tunnel_type: (Default value = 0)
1118 :param instance: (Default value = 0xFFFFFFFF)
1119 :param session_id: (Defalt value = 0)
Neale Ranns177bbdc2016-11-15 09:46:51 +00001120 :param is_add: (Default value = 1)
1121 :param is_ipv6: (Default value = 0)
Neale Ranns177bbdc2016-11-15 09:46:51 +00001122 """
1123
1124 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +01001125 self.papi.gre_add_del_tunnel,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001126 {'is_add': is_add,
1127 'is_ipv6': is_ip6,
John Loa43ccae2018-02-13 17:15:23 -05001128 'tunnel_type': tunnel_type,
1129 'instance': instance,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001130 'src_address': src_address,
1131 'dst_address': dst_address,
John Loa43ccae2018-02-13 17:15:23 -05001132 'outer_fib_id': outer_fib_id,
1133 'session_id': session_id}
Neale Ranns177bbdc2016-11-15 09:46:51 +00001134 )
Neale Rannsad422ed2016-11-02 14:20:04 +00001135
Neale Ranns810086d2017-11-05 16:26:46 -08001136 def udp_encap_add_del(self,
1137 id,
1138 src_ip,
1139 dst_ip,
1140 src_port,
1141 dst_port,
1142 table_id=0,
1143 is_add=1,
1144 is_ip6=0):
1145 """ Add a GRE tunnel
1146 :param id: user provided ID
1147 :param src_ip:
1148 :param dst_ip:
1149 :param src_port:
1150 :param dst_port:
1151 :param outer_fib_id: (Default value = 0)
1152 :param is_add: (Default value = 1)
1153 :param is_ipv6: (Default value = 0)
1154 """
1155
1156 return self.api(
1157 self.papi.udp_encap_add_del,
1158 {'id': id,
1159 'is_add': is_add,
1160 'is_ip6': is_ip6,
1161 'src_ip': src_ip,
1162 'dst_ip': dst_ip,
1163 'src_port': src_port,
1164 'dst_port': dst_port,
1165 'table_id': table_id}
1166 )
1167
1168 def udp_encap_dump(self):
1169 return self.api(self.papi.udp_encap_dump, {})
1170
Neale Ranns43b1f442018-03-20 01:47:35 -07001171 def want_udp_encap_stats(self, enable=1):
1172 return self.api(self.papi.want_udp_encap_stats,
1173 {'enable': enable,
1174 'pid': os.getpid()})
1175
Neale Ranns5a8123b2017-01-26 01:18:23 -08001176 def mpls_fib_dump(self):
1177 return self.api(self.papi.mpls_fib_dump, {})
1178
Neale Ranns15002542017-09-10 04:39:11 -07001179 def mpls_table_add_del(
1180 self,
1181 table_id,
1182 is_add=1):
1183 """
1184
1185 :param table_id
1186 :param is_add: (Default value = 1)
1187
1188 """
1189
1190 return self.api(
1191 self.papi.mpls_table_add_del,
1192 {'mt_table_id': table_id,
1193 'mt_is_add': is_add})
1194
Neale Rannsad422ed2016-11-02 14:20:04 +00001195 def mpls_route_add_del(
1196 self,
1197 label,
1198 eos,
Neale Rannsda78f952017-05-24 09:15:43 -07001199 next_hop_proto,
Neale Rannsad422ed2016-11-02 14:20:04 +00001200 next_hop_address,
1201 next_hop_sw_if_index=0xFFFFFFFF,
1202 table_id=0,
1203 next_hop_table_id=0,
1204 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001205 next_hop_n_out_labels=0,
1206 next_hop_out_label_stack=[],
1207 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +00001208 is_resolve_host=0,
1209 is_resolve_attached=0,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001210 is_interface_rx=0,
1211 is_rpf_id=0,
1212 is_multicast=0,
Neale Rannsad422ed2016-11-02 14:20:04 +00001213 is_add=1,
1214 is_drop=0,
1215 is_multipath=0,
1216 classify_table_index=0xFFFFFFFF,
Marek Gradzki0164a062017-10-13 10:22:59 +02001217 is_classify=0):
Neale Rannsad422ed2016-11-02 14:20:04 +00001218 """
1219
1220 :param dst_address_length:
1221 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
1222 :param dst_address:
1223 :param next_hop_address:
1224 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
1225 :param vrf_id: (Default value = 0)
1226 :param lookup_in_vrf: (Default value = 0)
1227 :param classify_table_index: (Default value = 0xFFFFFFFF)
Neale Rannsad422ed2016-11-02 14:20:04 +00001228 :param is_add: (Default value = 1)
1229 :param is_drop: (Default value = 0)
1230 :param is_ipv6: (Default value = 0)
1231 :param is_local: (Default value = 0)
1232 :param is_classify: (Default value = 0)
1233 :param is_multipath: (Default value = 0)
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001234 :param is_multicast: (Default value = 0)
Neale Rannsad422ed2016-11-02 14:20:04 +00001235 :param is_resolve_host: (Default value = 0)
1236 :param is_resolve_attached: (Default value = 0)
Neale Rannsad422ed2016-11-02 14:20:04 +00001237 :param next_hop_weight: (Default value = 1)
1238
1239 """
Neale Rannsad422ed2016-11-02 14:20:04 +00001240 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +01001241 self.papi.mpls_route_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001242 {'mr_label': label,
1243 'mr_eos': eos,
1244 'mr_table_id': table_id,
1245 'mr_classify_table_index': classify_table_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001246 'mr_is_add': is_add,
1247 'mr_is_classify': is_classify,
1248 'mr_is_multipath': is_multipath,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001249 'mr_is_multicast': is_multicast,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001250 'mr_is_resolve_host': is_resolve_host,
1251 'mr_is_resolve_attached': is_resolve_attached,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001252 'mr_is_interface_rx': is_interface_rx,
1253 'mr_is_rpf_id': is_rpf_id,
Neale Rannsda78f952017-05-24 09:15:43 -07001254 'mr_next_hop_proto': next_hop_proto,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001255 'mr_next_hop_weight': next_hop_weight,
1256 'mr_next_hop': next_hop_address,
1257 'mr_next_hop_n_out_labels': next_hop_n_out_labels,
1258 'mr_next_hop_sw_if_index': next_hop_sw_if_index,
1259 'mr_next_hop_table_id': next_hop_table_id,
1260 'mr_next_hop_via_label': next_hop_via_label,
1261 'mr_next_hop_out_label_stack': next_hop_out_label_stack})
Neale Rannsad422ed2016-11-02 14:20:04 +00001262
1263 def mpls_ip_bind_unbind(
1264 self,
1265 label,
1266 dst_address,
1267 dst_address_length,
1268 table_id=0,
1269 ip_table_id=0,
1270 is_ip4=1,
Neale Rannsad422ed2016-11-02 14:20:04 +00001271 is_bind=1):
1272 """
1273 """
1274 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +01001275 self.papi.mpls_ip_bind_unbind,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001276 {'mb_mpls_table_id': table_id,
1277 'mb_label': label,
1278 'mb_ip_table_id': ip_table_id,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001279 'mb_is_bind': is_bind,
1280 'mb_is_ip4': is_ip4,
1281 'mb_address_length': dst_address_length,
1282 'mb_address': dst_address})
Neale Rannsad422ed2016-11-02 14:20:04 +00001283
1284 def mpls_tunnel_add_del(
1285 self,
1286 tun_sw_if_index,
1287 next_hop_proto_is_ip4,
1288 next_hop_address,
1289 next_hop_sw_if_index=0xFFFFFFFF,
1290 next_hop_table_id=0,
1291 next_hop_weight=1,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001292 next_hop_n_out_labels=0,
1293 next_hop_out_label_stack=[],
1294 next_hop_via_label=MPLS_LABEL_INVALID,
Neale Rannsad422ed2016-11-02 14:20:04 +00001295 is_add=1,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001296 l2_only=0,
1297 is_multicast=0):
Neale Rannsad422ed2016-11-02 14:20:04 +00001298 """
1299
1300 :param dst_address_length:
1301 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
1302 :param dst_address:
1303 :param next_hop_address:
1304 :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF)
1305 :param vrf_id: (Default value = 0)
1306 :param lookup_in_vrf: (Default value = 0)
1307 :param classify_table_index: (Default value = 0xFFFFFFFF)
Neale Rannsad422ed2016-11-02 14:20:04 +00001308 :param is_add: (Default value = 1)
1309 :param is_drop: (Default value = 0)
1310 :param is_ipv6: (Default value = 0)
1311 :param is_local: (Default value = 0)
1312 :param is_classify: (Default value = 0)
1313 :param is_multipath: (Default value = 0)
1314 :param is_resolve_host: (Default value = 0)
1315 :param is_resolve_attached: (Default value = 0)
Neale Rannsad422ed2016-11-02 14:20:04 +00001316 :param next_hop_weight: (Default value = 1)
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001317 :param is_multicast: (Default value = 0)
Neale Rannsad422ed2016-11-02 14:20:04 +00001318
1319 """
Neale Rannsad422ed2016-11-02 14:20:04 +00001320 return self.api(
Ole Troan7e3a8752016-12-05 10:27:09 +01001321 self.papi.mpls_tunnel_add_del,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001322 {'mt_sw_if_index': tun_sw_if_index,
1323 'mt_is_add': is_add,
1324 'mt_l2_only': l2_only,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001325 'mt_is_multicast': is_multicast,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001326 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4,
1327 'mt_next_hop_weight': next_hop_weight,
1328 'mt_next_hop': next_hop_address,
1329 'mt_next_hop_n_out_labels': next_hop_n_out_labels,
1330 'mt_next_hop_sw_if_index': next_hop_sw_if_index,
1331 'mt_next_hop_table_id': next_hop_table_id,
1332 'mt_next_hop_out_label_stack': next_hop_out_label_stack})
Matus Fabiande886752016-12-07 03:38:19 -08001333
Matus Fabian2ba92e32017-08-21 07:05:03 -07001334 def nat44_interface_add_del_feature(
Matus Fabiande886752016-12-07 03:38:19 -08001335 self,
1336 sw_if_index,
1337 is_inside=1,
1338 is_add=1):
Matus Fabian2ba92e32017-08-21 07:05:03 -07001339 """Enable/disable NAT44 feature on the interface
Matus Fabiande886752016-12-07 03:38:19 -08001340
1341 :param sw_if_index: Software index of the interface
1342 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
1343 :param is_add: 1 if add, 0 if delete (Default value = 1)
1344 """
1345 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001346 self.papi.nat44_interface_add_del_feature,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001347 {'is_add': is_add,
1348 'is_inside': is_inside,
1349 'sw_if_index': sw_if_index})
Matus Fabiande886752016-12-07 03:38:19 -08001350
Matus Fabian2ba92e32017-08-21 07:05:03 -07001351 def nat44_interface_add_del_output_feature(
Matus Fabian93d84c92017-07-19 08:06:01 -07001352 self,
1353 sw_if_index,
1354 is_inside=1,
1355 is_add=1):
Matus Fabian2ba92e32017-08-21 07:05:03 -07001356 """Enable/disable NAT44 output feature on the interface
Matus Fabian93d84c92017-07-19 08:06:01 -07001357
1358 :param sw_if_index: Software index of the interface
1359 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
1360 :param is_add: 1 if add, 0 if delete (Default value = 1)
1361 """
1362 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001363 self.papi.nat44_interface_add_del_output_feature,
Matus Fabian93d84c92017-07-19 08:06:01 -07001364 {'is_add': is_add,
1365 'is_inside': is_inside,
1366 'sw_if_index': sw_if_index})
1367
Matus Fabian2ba92e32017-08-21 07:05:03 -07001368 def nat44_add_del_static_mapping(
Matus Fabiande886752016-12-07 03:38:19 -08001369 self,
1370 local_ip,
Matus Fabian36532bd2017-01-23 23:42:28 -08001371 external_ip=0,
1372 external_sw_if_index=0xFFFFFFFF,
Matus Fabiande886752016-12-07 03:38:19 -08001373 local_port=0,
1374 external_port=0,
1375 addr_only=1,
1376 vrf_id=0,
Matus Fabian09d96f42017-02-02 01:43:00 -08001377 protocol=0,
Matus Fabianb932d262017-12-18 05:38:24 -08001378 twice_nat=0,
Juraj Sloboda1e5c07d2018-04-10 13:51:54 +02001379 self_twice_nat=0,
Matus Fabiane82488f2018-01-18 03:38:45 -08001380 out2in_only=0,
Matus Fabian5f224992018-01-25 21:59:16 -08001381 tag="",
Matus Fabian2ba92e32017-08-21 07:05:03 -07001382 is_add=1):
1383 """Add/delete NAT44 static mapping
Matus Fabiande886752016-12-07 03:38:19 -08001384
1385 :param local_ip: Local IP address
1386 :param external_ip: External IP address
Matus Fabian36532bd2017-01-23 23:42:28 -08001387 :param external_sw_if_index: External interface instead of IP address
Matus Fabiande886752016-12-07 03:38:19 -08001388 :param local_port: Local port number (Default value = 0)
1389 :param external_port: External port number (Default value = 0)
1390 :param addr_only: 1 if address only mapping, 0 if address and port
1391 :param vrf_id: VRF ID
Matus Fabian09d96f42017-02-02 01:43:00 -08001392 :param protocol: IP protocol (Default value = 0)
Matus Fabianb932d262017-12-18 05:38:24 -08001393 :param twice_nat: 1 if translate external host address and port
Juraj Sloboda1e5c07d2018-04-10 13:51:54 +02001394 :param self_twice_nat: 1 if translate external host address and port
1395 whenever external host address equals
1396 local address of internal host
Matus Fabiane82488f2018-01-18 03:38:45 -08001397 :param out2in_only: if 1 rule is matching only out2in direction
Matus Fabian5f224992018-01-25 21:59:16 -08001398 :param tag: Opaque string tag
Matus Fabiande886752016-12-07 03:38:19 -08001399 :param is_add: 1 if add, 0 if delete (Default value = 1)
Matus Fabiande886752016-12-07 03:38:19 -08001400 """
1401 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001402 self.papi.nat44_add_del_static_mapping,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001403 {'is_add': is_add,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001404 'addr_only': addr_only,
1405 'local_ip_address': local_ip,
1406 'external_ip_address': external_ip,
1407 'local_port': local_port,
1408 'external_port': external_port,
Matus Fabian36532bd2017-01-23 23:42:28 -08001409 'external_sw_if_index': external_sw_if_index,
Matus Fabian09d96f42017-02-02 01:43:00 -08001410 'vrf_id': vrf_id,
Matus Fabianb932d262017-12-18 05:38:24 -08001411 'protocol': protocol,
Matus Fabiane82488f2018-01-18 03:38:45 -08001412 'twice_nat': twice_nat,
Juraj Sloboda1e5c07d2018-04-10 13:51:54 +02001413 'self_twice_nat': self_twice_nat,
Matus Fabian5f224992018-01-25 21:59:16 -08001414 'out2in_only': out2in_only,
1415 'tag': tag})
Matus Fabiande886752016-12-07 03:38:19 -08001416
Matus Fabianab7a8052017-11-28 04:29:41 -08001417 def nat44_add_del_identity_mapping(
1418 self,
1419 ip='0',
1420 sw_if_index=0xFFFFFFFF,
1421 port=0,
1422 addr_only=1,
1423 vrf_id=0,
1424 protocol=0,
Matus Fabian5f224992018-01-25 21:59:16 -08001425 tag='',
Matus Fabianab7a8052017-11-28 04:29:41 -08001426 is_add=1):
1427 """Add/delete NAT44 identity mapping
1428
1429 :param ip: IP address (Default value = 0)
1430 :param sw_if_index: Interface instead of IP address
1431 :param port: Port number (Default value = 0)
1432 :param addr_only: 1 if address only mapping, 0 if address and port
1433 :param vrf_id: VRF ID
1434 :param protocol: IP protocol (Default value = 0)
Matus Fabian5f224992018-01-25 21:59:16 -08001435 :param tag: Opaque string tag
Matus Fabianab7a8052017-11-28 04:29:41 -08001436 :param is_add: 1 if add, 0 if delete (Default value = 1)
1437 """
1438 return self.api(
1439 self.papi.nat44_add_del_identity_mapping,
1440 {'is_add': is_add,
1441 'addr_only': addr_only,
1442 'ip_address': ip,
1443 'port': port,
1444 'sw_if_index': sw_if_index,
1445 'vrf_id': vrf_id,
Matus Fabian5f224992018-01-25 21:59:16 -08001446 'tag': tag,
Matus Fabianab7a8052017-11-28 04:29:41 -08001447 'protocol': protocol})
1448
Matus Fabian2ba92e32017-08-21 07:05:03 -07001449 def nat44_add_del_address_range(
Matus Fabiande886752016-12-07 03:38:19 -08001450 self,
1451 first_ip_address,
1452 last_ip_address,
1453 is_add=1,
Matus Fabianb932d262017-12-18 05:38:24 -08001454 vrf_id=0xFFFFFFFF,
1455 twice_nat=0):
Matus Fabian2ba92e32017-08-21 07:05:03 -07001456 """Add/del NAT44 address range
Matus Fabiande886752016-12-07 03:38:19 -08001457
1458 :param first_ip_address: First IP address
1459 :param last_ip_address: Last IP address
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001460 :param vrf_id: VRF id for the address range
Matus Fabianb932d262017-12-18 05:38:24 -08001461 :param twice_nat: twice NAT address for extenal hosts
Matus Fabiande886752016-12-07 03:38:19 -08001462 :param is_add: 1 if add, 0 if delete (Default value = 1)
Matus Fabiande886752016-12-07 03:38:19 -08001463 """
1464 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001465 self.papi.nat44_add_del_address_range,
1466 {'first_ip_address': first_ip_address,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001467 'last_ip_address': last_ip_address,
Juraj Slobodaeab38d92017-03-06 19:55:21 -08001468 'vrf_id': vrf_id,
Matus Fabianb932d262017-12-18 05:38:24 -08001469 'twice_nat': twice_nat,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001470 'is_add': is_add})
Matus Fabiande886752016-12-07 03:38:19 -08001471
Matus Fabian2ba92e32017-08-21 07:05:03 -07001472 def nat44_address_dump(self):
1473 """Dump NAT44 addresses
1474 :return: Dictionary of NAT44 addresses
Matus Fabiande886752016-12-07 03:38:19 -08001475 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001476 return self.api(self.papi.nat44_address_dump, {})
Matus Fabiande886752016-12-07 03:38:19 -08001477
Matus Fabian2ba92e32017-08-21 07:05:03 -07001478 def nat44_interface_dump(self):
1479 """Dump interfaces with NAT44 feature
1480 :return: Dictionary of interfaces with NAT44 feature
Matus Fabiande886752016-12-07 03:38:19 -08001481 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001482 return self.api(self.papi.nat44_interface_dump, {})
Matus Fabiande886752016-12-07 03:38:19 -08001483
Matus Fabian2ba92e32017-08-21 07:05:03 -07001484 def nat44_interface_output_feature_dump(self):
1485 """Dump interfaces with NAT44 output feature
1486 :return: Dictionary of interfaces with NAT44 output feature
Matus Fabian93d84c92017-07-19 08:06:01 -07001487 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001488 return self.api(self.papi.nat44_interface_output_feature_dump, {})
Matus Fabian93d84c92017-07-19 08:06:01 -07001489
Matus Fabian2ba92e32017-08-21 07:05:03 -07001490 def nat44_static_mapping_dump(self):
1491 """Dump NAT44 static mappings
1492 :return: Dictionary of NAT44 static mappings
Matus Fabiande886752016-12-07 03:38:19 -08001493 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001494 return self.api(self.papi.nat44_static_mapping_dump, {})
Klement Sekera0e3c0de2016-09-29 14:43:44 +02001495
Matus Fabianab7a8052017-11-28 04:29:41 -08001496 def nat44_identity_mapping_dump(self):
1497 """Dump NAT44 identity mappings
1498 :return: Dictionary of NAT44 identity mappings
1499 """
1500 return self.api(self.papi.nat44_identity_mapping_dump, {})
1501
Matus Fabian2ba92e32017-08-21 07:05:03 -07001502 def nat_show_config(self):
1503 """Show NAT plugin config
1504 :return: NAT plugin config parameters
Matus Fabian9902fcd2016-12-21 23:58:46 -08001505 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001506 return self.api(self.papi.nat_show_config, {})
Matus Fabian9902fcd2016-12-21 23:58:46 -08001507
Matus Fabian2ba92e32017-08-21 07:05:03 -07001508 def nat44_add_interface_addr(
Matus Fabian8bf68e82017-01-12 04:24:35 -08001509 self,
1510 sw_if_index,
Matus Fabianb932d262017-12-18 05:38:24 -08001511 twice_nat=0,
Matus Fabian8bf68e82017-01-12 04:24:35 -08001512 is_add=1):
Matus Fabian2ba92e32017-08-21 07:05:03 -07001513 """Add/del NAT44 address from interface
Matus Fabian8bf68e82017-01-12 04:24:35 -08001514
1515 :param sw_if_index: Software index of the interface
Matus Fabianb932d262017-12-18 05:38:24 -08001516 :param twice_nat: twice NAT address for extenal hosts
Matus Fabian8bf68e82017-01-12 04:24:35 -08001517 :param is_add: 1 if add, 0 if delete (Default value = 1)
1518 """
Matus Fabianb932d262017-12-18 05:38:24 -08001519 return self.api(
1520 self.papi.nat44_add_del_interface_addr,
1521 {'is_add': is_add,
1522 'sw_if_index': sw_if_index,
1523 'twice_nat': twice_nat})
Matus Fabian8bf68e82017-01-12 04:24:35 -08001524
Matus Fabian2ba92e32017-08-21 07:05:03 -07001525 def nat44_interface_addr_dump(self):
1526 """Dump NAT44 addresses interfaces
1527 :return: Dictionary of NAT44 addresses interfaces
Matus Fabian8bf68e82017-01-12 04:24:35 -08001528 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001529 return self.api(self.papi.nat44_interface_addr_dump, {})
Matus Fabian8bf68e82017-01-12 04:24:35 -08001530
Matus Fabian2ba92e32017-08-21 07:05:03 -07001531 def nat_ipfix(
Matus Fabianeea28d72017-01-13 04:15:54 -08001532 self,
1533 domain_id=1,
1534 src_port=4739,
1535 enable=1):
Matus Fabian2ba92e32017-08-21 07:05:03 -07001536 """Enable/disable NAT IPFIX logging
Matus Fabianeea28d72017-01-13 04:15:54 -08001537
1538 :param domain_id: Observation domain ID (Default value = 1)
1539 :param src_port: Source port number (Default value = 4739)
1540 :param enable: 1 if enable, 0 if disable (Default value = 1)
1541 """
1542 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001543 self.papi.nat_ipfix_enable_disable,
Matus Fabianeea28d72017-01-13 04:15:54 -08001544 {'domain_id': domain_id,
1545 'src_port': src_port,
1546 'enable': enable})
1547
Matus Fabian2ba92e32017-08-21 07:05:03 -07001548 def nat44_user_session_dump(
magalik23caa882017-02-08 23:25:45 -08001549 self,
1550 ip_address,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001551 vrf_id):
1552 """Dump NAT44 user's sessions
magalik23caa882017-02-08 23:25:45 -08001553
1554 :param ip_address: ip adress of the user to be dumped
1555 :param cpu_index: cpu_index on which the user is
1556 :param vrf_id: VRF ID
1557 :return: Dictionary of S-NAT sessions
1558 """
1559 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001560 self.papi.nat44_user_session_dump,
magalik23caa882017-02-08 23:25:45 -08001561 {'ip_address': ip_address,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001562 'vrf_id': vrf_id})
magalik23caa882017-02-08 23:25:45 -08001563
Matus Fabian2ba92e32017-08-21 07:05:03 -07001564 def nat44_user_dump(self):
1565 """Dump NAT44 users
magalik23caa882017-02-08 23:25:45 -08001566
Matus Fabian2ba92e32017-08-21 07:05:03 -07001567 :return: Dictionary of NAT44 users
magalik23caa882017-02-08 23:25:45 -08001568 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001569 return self.api(self.papi.nat44_user_dump, {})
magalik23caa882017-02-08 23:25:45 -08001570
Matus Fabian704018c2017-09-04 02:17:18 -07001571 def nat44_add_del_lb_static_mapping(
1572 self,
1573 external_addr,
1574 external_port,
1575 protocol,
1576 vrf_id=0,
Matus Fabianb932d262017-12-18 05:38:24 -08001577 twice_nat=0,
Juraj Sloboda1e5c07d2018-04-10 13:51:54 +02001578 self_twice_nat=0,
Matus Fabian240b5ef2018-01-11 04:09:17 -08001579 out2in_only=0,
Matus Fabian5f224992018-01-25 21:59:16 -08001580 tag='',
Matus Fabian704018c2017-09-04 02:17:18 -07001581 local_num=0,
Ole Troan895b6e82017-10-20 13:28:20 +02001582 locals=[],
Matus Fabian704018c2017-09-04 02:17:18 -07001583 is_add=1):
1584 """Add/delete NAT44 load balancing static mapping
1585
Matus Fabianb932d262017-12-18 05:38:24 -08001586 :param twice_nat: 1 if translate external host address and port
Matus Fabian5f224992018-01-25 21:59:16 -08001587 :param tag: Opaque string tag
Matus Fabian704018c2017-09-04 02:17:18 -07001588 :param is_add - 1 if add, 0 if delete
1589 """
1590 return self.api(
1591 self.papi.nat44_add_del_lb_static_mapping,
1592 {'is_add': is_add,
1593 'external_addr': external_addr,
1594 'external_port': external_port,
1595 'protocol': protocol,
1596 'vrf_id': vrf_id,
Matus Fabianb932d262017-12-18 05:38:24 -08001597 'twice_nat': twice_nat,
Juraj Sloboda1e5c07d2018-04-10 13:51:54 +02001598 'self_twice_nat': self_twice_nat,
Matus Fabian240b5ef2018-01-11 04:09:17 -08001599 'out2in_only': out2in_only,
Matus Fabian5f224992018-01-25 21:59:16 -08001600 'tag': tag,
Matus Fabian704018c2017-09-04 02:17:18 -07001601 'local_num': local_num,
1602 'locals': locals})
1603
1604 def nat44_lb_static_mapping_dump(self):
1605 """Dump NAT44 load balancing static mappings
1606
1607 :return: Dictionary of NAT44 load balancing static mapping
1608 """
1609 return self.api(self.papi.nat44_lb_static_mapping_dump, {})
1610
Matus Fabian5ba86f72017-10-26 03:37:38 -07001611 def nat44_del_session(
1612 self,
1613 addr,
1614 port,
1615 protocol,
1616 vrf_id=0,
Matus Fabian70a26ac2018-05-14 06:20:28 -07001617 is_in=1,
1618 ext_host_address=None,
1619 ext_host_port=0):
Matus Fabian5ba86f72017-10-26 03:37:38 -07001620 """Delete NAT44 session
1621
1622 :param addr: IPv4 address
1623 :param por: port number
1624 :param protocol: IP protocol number
1625 :param vrf_id: VRF ID
1626 :param is_in: 1 if inside network addres and port pari, 0 if outside
Matus Fabian70a26ac2018-05-14 06:20:28 -07001627 :param ext_host_address: external host IPv4 address
1628 :param ext_host_port: external host port
Matus Fabian5ba86f72017-10-26 03:37:38 -07001629 """
Matus Fabian70a26ac2018-05-14 06:20:28 -07001630 if ext_host_address is None:
1631 return self.api(
1632 self.papi.nat44_del_session,
1633 {'address': addr,
1634 'port': port,
1635 'protocol': protocol,
1636 'vrf_id': vrf_id,
1637 'is_in': is_in})
1638 else:
1639 return self.api(
1640 self.papi.nat44_del_session,
1641 {'address': addr,
1642 'port': port,
1643 'protocol': protocol,
1644 'vrf_id': vrf_id,
1645 'is_in': is_in,
1646 'ext_host_valid': 1,
1647 'ext_host_address': ext_host_address,
1648 'ext_host_port': ext_host_port})
Matus Fabian5ba86f72017-10-26 03:37:38 -07001649
Juraj Sloboda7b929792017-11-23 13:20:48 +01001650 def nat44_forwarding_enable_disable(
1651 self,
1652 enable):
1653 """Enable/disable forwarding for NAT44
1654
1655 :param enable: 1 for enable, 0 for disable
1656 """
1657 return self.api(
1658 self.papi.nat44_forwarding_enable_disable,
1659 {'enable': enable})
1660
Matus Fabianefcd1e92017-08-15 06:59:19 -07001661 def nat_set_reass(
1662 self,
1663 timeout=2,
1664 max_reass=1024,
1665 max_frag=5,
1666 drop_frag=0,
1667 is_ip6=0):
1668 """Set NAT virtual fragmentation reassembly
1669
1670 :param timeout: reassembly timeout (Default 2sec)
1671 :param max_reass: maximum concurrent reassemblies (Default 1024)
1672 :param max_frag: maximum fragmets per reassembly (Default 5)
1673 :param drop_frag: if 0 translate fragments, otherwise drop fragments
1674 :param is_ip6: 1 if IPv6, 0 if IPv4
1675 """
1676 return self.api(
1677 self.papi.nat_set_reass,
1678 {'timeout': timeout,
1679 'max_reass': max_reass,
1680 'max_frag': max_frag,
1681 'drop_frag': drop_frag,
1682 'is_ip6': is_ip6})
1683
1684 def nat_get_reass(self):
1685 """Get NAT virtual fragmentation reassembly configuration
1686
1687 :return: NAT virtual fragmentation reassembly configuration
1688 """
1689 return self.api(self.papi.nat_get_reass, {})
1690
1691 def nat_reass_dump(self):
1692 """Dump NAT virtual fragmentation reassemblies
1693
1694 :return: Dictionary of NAT virtual fragmentation reassemblies
1695 """
1696 return self.api(self.papi.nat_reass_dump, {})
1697
Matus Fabian2ba92e32017-08-21 07:05:03 -07001698 def nat_det_add_del_map(
Matus Fabian066f0342017-02-10 03:48:01 -08001699 self,
1700 in_addr,
1701 in_plen,
1702 out_addr,
1703 out_plen,
1704 is_add=1):
Matus Fabian2ba92e32017-08-21 07:05:03 -07001705 """Add/delete deterministic NAT mapping
Matus Fabian066f0342017-02-10 03:48:01 -08001706
1707 :param is_add - 1 if add, 0 if delete
1708 :param in_addr - inside IP address
1709 :param in_plen - inside IP address prefix length
1710 :param out_addr - outside IP address
1711 :param out_plen - outside IP address prefix length
1712 """
1713 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001714 self.papi.nat_det_add_del_map,
Matus Fabian066f0342017-02-10 03:48:01 -08001715 {'is_add': is_add,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001716 'is_nat44': 1,
Matus Fabian066f0342017-02-10 03:48:01 -08001717 'in_addr': in_addr,
1718 'in_plen': in_plen,
1719 'out_addr': out_addr,
1720 'out_plen': out_plen})
1721
Matus Fabian2ba92e32017-08-21 07:05:03 -07001722 def nat_det_forward(
Matus Fabian066f0342017-02-10 03:48:01 -08001723 self,
1724 in_addr):
1725 """Get outside address and port range from inside address
1726
1727 :param in_addr - inside IP address
1728 """
1729 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001730 self.papi.nat_det_forward,
1731 {'in_addr': in_addr,
1732 'is_nat44': 1})
Matus Fabian066f0342017-02-10 03:48:01 -08001733
Matus Fabian2ba92e32017-08-21 07:05:03 -07001734 def nat_det_reverse(
Matus Fabian066f0342017-02-10 03:48:01 -08001735 self,
1736 out_addr,
1737 out_port):
1738 """Get inside address from outside address and port
1739
1740 :param out_addr - outside IP address
1741 :param out_port - outside port
1742 """
1743 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001744 self.papi.nat_det_reverse,
Matus Fabian066f0342017-02-10 03:48:01 -08001745 {'out_addr': out_addr,
1746 'out_port': out_port})
1747
Matus Fabian2ba92e32017-08-21 07:05:03 -07001748 def nat_det_map_dump(self):
1749 """Dump deterministic NAT mappings
Martin17a75cb2017-03-08 05:53:20 -08001750
Matus Fabian2ba92e32017-08-21 07:05:03 -07001751 :return: Dictionary of deterministic NAT mappings
Martin17a75cb2017-03-08 05:53:20 -08001752 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001753 return self.api(self.papi.nat_det_map_dump, {})
Martin17a75cb2017-03-08 05:53:20 -08001754
Matus Fabian2ba92e32017-08-21 07:05:03 -07001755 def nat_det_set_timeouts(
Matus Fabian6a0946f2017-04-12 03:36:13 -07001756 self,
1757 udp=300,
1758 tcp_established=7440,
1759 tcp_transitory=240,
1760 icmp=60):
1761 """Set values of timeouts for deterministic NAT (in seconds)
1762
1763 :param udp - UDP timeout (Default value = 300)
1764 :param tcp_established - TCP established timeout (Default value = 7440)
1765 :param tcp_transitory - TCP transitory timeout (Default value = 240)
1766 :param icmp - ICMP timeout (Default value = 60)
1767 """
1768 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001769 self.papi.nat_det_set_timeouts,
Matus Fabian6a0946f2017-04-12 03:36:13 -07001770 {'udp': udp,
1771 'tcp_established': tcp_established,
1772 'tcp_transitory': tcp_transitory,
1773 'icmp': icmp})
1774
Matus Fabian2ba92e32017-08-21 07:05:03 -07001775 def nat_det_get_timeouts(self):
Matus Fabian6a0946f2017-04-12 03:36:13 -07001776 """Get values of timeouts for deterministic NAT
1777
1778 :return: Timeouts for deterministic NAT (in seconds)
1779 """
Matus Fabian2ba92e32017-08-21 07:05:03 -07001780 return self.api(self.papi.nat_det_get_timeouts, {})
Matus Fabian6a0946f2017-04-12 03:36:13 -07001781
Matus Fabian2ba92e32017-08-21 07:05:03 -07001782 def nat_det_close_session_out(
Martin Gálik6bc8c642017-04-19 01:12:27 -07001783 self,
1784 out_addr,
1785 out_port,
1786 ext_addr,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001787 ext_port):
1788 """Close deterministic NAT session using outside address and port
Martin Gálik6bc8c642017-04-19 01:12:27 -07001789
1790 :param out_addr - outside IP address
1791 :param out_port - outside port
1792 :param ext_addr - external host IP address
1793 :param ext_port - external host port
Martin Gálik6bc8c642017-04-19 01:12:27 -07001794 """
1795 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001796 self.papi.nat_det_close_session_out,
Martin Gálik6bc8c642017-04-19 01:12:27 -07001797 {'out_addr': out_addr,
1798 'out_port': out_port,
1799 'ext_addr': ext_addr,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001800 'ext_port': ext_port})
Martin Gálik6bc8c642017-04-19 01:12:27 -07001801
Matus Fabian2ba92e32017-08-21 07:05:03 -07001802 def nat_det_close_session_in(
Martin Gálik6bc8c642017-04-19 01:12:27 -07001803 self,
1804 in_addr,
1805 in_port,
1806 ext_addr,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001807 ext_port):
1808 """Close deterministic NAT session using inside address and port
Martin Gálik6bc8c642017-04-19 01:12:27 -07001809
1810 :param in_addr - inside IP address
1811 :param in_port - inside port
1812 :param ext_addr - external host IP address
1813 :param ext_port - external host port
Martin Gálik6bc8c642017-04-19 01:12:27 -07001814 """
1815 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001816 self.papi.nat_det_close_session_in,
Martin Gálik6bc8c642017-04-19 01:12:27 -07001817 {'in_addr': in_addr,
1818 'in_port': in_port,
1819 'ext_addr': ext_addr,
1820 'ext_port': ext_port,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001821 'is_nat44': 1})
Martin Gálik6bc8c642017-04-19 01:12:27 -07001822
Matus Fabian2ba92e32017-08-21 07:05:03 -07001823 def nat_det_session_dump(
Martin Gálik9806eae2017-04-25 01:25:08 -07001824 self,
Matus Fabian2ba92e32017-08-21 07:05:03 -07001825 user_addr):
1826 """Dump deterministic NAT sessions belonging to a user
Martin Gálik9806eae2017-04-25 01:25:08 -07001827
1828 :param user_addr - inside IP address of the user
Matus Fabian2ba92e32017-08-21 07:05:03 -07001829 :return: Dictionary of deterministic NAT sessions
Martin Gálik9806eae2017-04-25 01:25:08 -07001830 """
1831 return self.api(
Matus Fabian2ba92e32017-08-21 07:05:03 -07001832 self.papi.nat_det_session_dump,
1833 {'is_nat44': 1,
Martin Gálik9806eae2017-04-25 01:25:08 -07001834 'user_addr': user_addr})
1835
Matus Fabian06596c52017-06-06 04:53:28 -07001836 def nat64_add_del_pool_addr_range(
1837 self,
1838 start_addr,
1839 end_addr,
1840 vrf_id=0xFFFFFFFF,
1841 is_add=1):
1842 """Add/del address range to NAT64 pool
1843
1844 :param start_addr: First IP address
1845 :param end_addr: Last IP address
1846 :param vrf_id: VRF id for the address range
1847 :param is_add: 1 if add, 0 if delete (Default value = 1)
1848 """
1849 return self.api(
1850 self.papi.nat64_add_del_pool_addr_range,
1851 {'start_addr': start_addr,
1852 'end_addr': end_addr,
1853 'vrf_id': vrf_id,
1854 'is_add': is_add})
1855
1856 def nat64_pool_addr_dump(self):
1857 """Dump NAT64 pool addresses
1858 :return: Dictionary of NAT64 pool addresses
1859 """
1860 return self.api(self.papi.nat64_pool_addr_dump, {})
1861
1862 def nat64_add_del_interface(
1863 self,
1864 sw_if_index,
1865 is_inside=1,
1866 is_add=1):
1867 """Enable/disable NAT64 feature on the interface
1868 :param sw_if_index: Index of the interface
1869 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
1870 :param is_add: 1 if add, 0 if delete (Default value = 1)
1871 """
1872 return self.api(
1873 self.papi.nat64_add_del_interface,
1874 {'sw_if_index': sw_if_index,
1875 'is_inside': is_inside,
1876 'is_add': is_add})
1877
1878 def nat64_interface_dump(self):
1879 """Dump interfaces with NAT64 feature
1880 :return: Dictionary of interfaces with NAT64 feature
1881 """
1882 return self.api(self.papi.nat64_interface_dump, {})
1883
1884 def nat64_add_del_static_bib(
1885 self,
1886 in_ip,
1887 out_ip,
1888 in_port,
1889 out_port,
1890 protocol,
1891 vrf_id=0,
1892 is_add=1):
1893 """Add/delete S-NAT static BIB entry
1894
1895 :param in_ip: Inside IPv6 address
1896 :param out_ip: Outside IPv4 address
1897 :param in_port: Inside port number
1898 :param out_port: Outside port number
1899 :param protocol: IP protocol
1900 :param vrf_id: VRF ID (Default value = 0)
1901 :param is_add: 1 if add, 0 if delete (Default value = 1)
1902 """
1903 return self.api(
1904 self.papi.nat64_add_del_static_bib,
1905 {'i_addr': in_ip,
1906 'o_addr': out_ip,
1907 'i_port': in_port,
1908 'o_port': out_port,
1909 'vrf_id': vrf_id,
1910 'proto': protocol,
1911 'is_add': is_add})
1912
Matus Fabianab9a59c2017-08-16 05:37:36 -07001913 def nat64_bib_dump(self, protocol=255):
Matus Fabian06596c52017-06-06 04:53:28 -07001914 """Dump NAT64 BIB
1915
Matus Fabianab9a59c2017-08-16 05:37:36 -07001916 :param protocol: IP protocol (Default value = 255, all BIBs)
Matus Fabian06596c52017-06-06 04:53:28 -07001917 :returns: Dictionary of NAT64 BIB entries
1918 """
1919 return self.api(self.papi.nat64_bib_dump, {'proto': protocol})
1920
1921 def nat64_set_timeouts(self, udp=300, icmp=60, tcp_trans=240, tcp_est=7440,
1922 tcp_incoming_syn=6):
1923 """Set values of timeouts for NAT64 (in seconds)
1924
Matus Fabian428dc912017-06-21 06:15:18 -07001925 :param udpi: UDP timeout (Default value = 300)
1926 :param icmp: ICMP timeout (Default value = 60)
1927 :param tcp_trans: TCP transitory timeout (Default value = 240)
1928 :param tcp_est: TCP established timeout (Default value = 7440)
1929 :param tcp_incoming_syn: TCP incoming SYN timeout (Default value = 6)
Matus Fabian06596c52017-06-06 04:53:28 -07001930 """
1931 return self.api(
1932 self.papi.nat64_set_timeouts,
1933 {'udp': udp,
1934 'icmp': icmp,
1935 'tcp_trans': tcp_trans,
1936 'tcp_est': tcp_est,
1937 'tcp_incoming_syn': tcp_incoming_syn})
1938
1939 def nat64_get_timeouts(self):
1940 """Get values of timeouts for NAT64
1941
1942 :return: Timeouts for NAT64 (in seconds)
1943 """
1944 return self.api(self.papi.nat64_get_timeouts, {})
1945
Matus Fabianab9a59c2017-08-16 05:37:36 -07001946 def nat64_st_dump(self, protocol=255):
Matus Fabian06596c52017-06-06 04:53:28 -07001947 """Dump NAT64 session table
1948
Matus Fabianab9a59c2017-08-16 05:37:36 -07001949 :param protocol: IP protocol (Default value = 255, all STs)
Matus Fabian06596c52017-06-06 04:53:28 -07001950 :returns: Dictionary of NAT64 sesstion table entries
1951 """
1952 return self.api(self.papi.nat64_st_dump, {'proto': protocol})
1953
Matus Fabian428dc912017-06-21 06:15:18 -07001954 def nat64_add_del_prefix(self, prefix, plen, vrf_id=0, is_add=1):
1955 """Add/del NAT64 prefix
1956
1957 :param prefix: NAT64 prefix
1958 :param plen: NAT64 prefix length
1959 :param vrf_id: VRF id of tenant (Default 0)
1960 :param is_add: 1 if add, 0 if delete (Default value = 1)
1961 """
1962 return self.api(
1963 self.papi.nat64_add_del_prefix,
1964 {'prefix': prefix,
1965 'prefix_len': plen,
1966 'vrf_id': vrf_id,
1967 'is_add': is_add})
1968
1969 def nat64_prefix_dump(self):
1970 """Dump NAT64 prefix
1971
1972 :returns: Dictionary of NAT64 prefixes
1973 """
1974 return self.api(self.papi.nat64_prefix_dump, {})
1975
Matus Fabian0938dcf2017-11-08 01:59:38 -08001976 def nat64_add_interface_addr(
1977 self,
1978 sw_if_index,
1979 is_add=1):
1980 """Add/del NAT64 address from interface
1981
1982 :param sw_if_index: Software index of the interface
1983 :param is_add: 1 if add, 0 if delete (Default value = 1)
1984 """
1985 return self.api(self.papi.nat64_add_del_interface_addr,
1986 {'is_add': is_add, 'sw_if_index': sw_if_index})
1987
Matus Fabian8ebe6252017-11-06 05:04:53 -08001988 def dslite_set_aftr_addr(self, ip6, ip4):
1989 """Set DS-Lite AFTR addresses
1990
1991 :param ip4: IPv4 address
1992 :param ip6: IPv6 address
1993 """
1994 return self.api(
1995 self.papi.dslite_set_aftr_addr,
1996 {'ip4_addr': ip4,
1997 'ip6_addr': ip6})
1998
Juraj Slobodac5c6a332018-01-09 16:08:32 +01001999 def dslite_set_b4_addr(self, ip6, ip4):
2000 """Set DS-Lite B4 IPv6 address
2001
2002 :param ip4: IPv4 address
2003 :param ip6: IPv6 address
2004 """
2005 return self.api(
2006 self.papi.dslite_set_b4_addr,
2007 {'ip4_addr': ip4,
2008 'ip6_addr': ip6})
2009
Matus Fabian8ebe6252017-11-06 05:04:53 -08002010 def dslite_add_del_pool_addr_range(
2011 self,
2012 start_addr,
2013 end_addr,
2014 is_add=1):
2015 """Add/del address range to DS-Lite pool
2016
2017 :param start_addr: First IP address
2018 :param end_addr: Last IP address
2019 :param is_add: 1 if add, 0 if delete (Default value = 1)
2020 """
2021 return self.api(
2022 self.papi.dslite_add_del_pool_addr_range,
2023 {'start_addr': start_addr,
2024 'end_addr': end_addr,
2025 'is_add': is_add})
2026
Matus Fabianf2a23cc2018-01-22 03:41:53 -08002027 def nat66_add_del_interface(
2028 self,
2029 sw_if_index,
2030 is_inside=1,
2031 is_add=1):
2032 """Enable/disable NAT66 feature on the interface
2033 :param sw_if_index: Index of the interface
2034 :param is_inside: 1 if inside, 0 if outside (Default value = 1)
2035 :param is_add: 1 if add, 0 if delete (Default value = 1)
2036 """
2037 return self.api(
2038 self.papi.nat66_add_del_interface,
2039 {'sw_if_index': sw_if_index,
2040 'is_inside': is_inside,
2041 'is_add': is_add})
2042
2043 def nat66_add_del_static_mapping(
2044 self,
2045 in_ip,
2046 out_ip,
2047 vrf_id=0,
2048 is_add=1):
2049 """Add/delete NAT66 static mapping
2050
2051 :param in_ip: Inside IPv6 address
2052 :param out_ip: Outside IPv6 address
2053 :param vrf_id: VRF ID (Default value = 0)
2054 :param is_add: 1 if add, 0 if delete (Default value = 1)
2055 """
2056 return self.api(
2057 self.papi.nat66_add_del_static_mapping,
2058 {'local_ip_address': in_ip,
2059 'external_ip_address': out_ip,
2060 'vrf_id': vrf_id,
2061 'is_add': is_add})
2062
2063 def nat66_interface_dump(self):
2064 """Dump interfaces with NAT66 feature
2065 :return: Dictionary of interfaces with NAT66 feature
2066 """
2067 return self.api(self.papi.nat66_interface_dump, {})
2068
2069 def nat66_static_mapping_dump(self):
2070 """Dump NAT66 static mappings
2071 :return: Dictionary of NAT66 static mappings
2072 """
2073 return self.api(self.papi.nat66_static_mapping_dump, {})
2074
Klement Sekera0e3c0de2016-09-29 14:43:44 +02002075 def control_ping(self):
2076 self.api(self.papi.control_ping)
2077
2078 def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx,
Klement Sekerab17dd962017-01-09 07:43:48 +01002079 detect_mult, local_addr, peer_addr, is_ipv6=0,
2080 bfd_key_id=None, conf_key_id=None):
2081 if bfd_key_id is None:
2082 return self.api(self.papi.bfd_udp_add,
2083 {
2084 'sw_if_index': sw_if_index,
2085 'desired_min_tx': desired_min_tx,
2086 'required_min_rx': required_min_rx,
2087 'local_addr': local_addr,
2088 'peer_addr': peer_addr,
2089 'is_ipv6': is_ipv6,
2090 'detect_mult': detect_mult,
2091 })
2092 else:
2093 return self.api(self.papi.bfd_udp_add,
2094 {
2095 'sw_if_index': sw_if_index,
2096 'desired_min_tx': desired_min_tx,
2097 'required_min_rx': required_min_rx,
2098 'local_addr': local_addr,
2099 'peer_addr': peer_addr,
2100 'is_ipv6': is_ipv6,
2101 'detect_mult': detect_mult,
2102 'is_authenticated': 1,
2103 'bfd_key_id': bfd_key_id,
2104 'conf_key_id': conf_key_id,
2105 })
2106
Klement Sekeraa57a9702017-02-02 06:58:07 +01002107 def bfd_udp_mod(self, sw_if_index, desired_min_tx, required_min_rx,
2108 detect_mult, local_addr, peer_addr, is_ipv6=0):
2109 return self.api(self.papi.bfd_udp_mod,
2110 {
2111 'sw_if_index': sw_if_index,
2112 'desired_min_tx': desired_min_tx,
2113 'required_min_rx': required_min_rx,
2114 'local_addr': local_addr,
2115 'peer_addr': peer_addr,
2116 'is_ipv6': is_ipv6,
2117 'detect_mult': detect_mult,
2118 })
2119
Klement Sekerab17dd962017-01-09 07:43:48 +01002120 def bfd_udp_auth_activate(self, sw_if_index, local_addr, peer_addr,
2121 is_ipv6=0, bfd_key_id=None, conf_key_id=None,
2122 is_delayed=False):
2123 return self.api(self.papi.bfd_udp_auth_activate,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02002124 {
2125 'sw_if_index': sw_if_index,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02002126 'local_addr': local_addr,
2127 'peer_addr': peer_addr,
2128 'is_ipv6': is_ipv6,
Klement Sekerab17dd962017-01-09 07:43:48 +01002129 'is_delayed': 1 if is_delayed else 0,
2130 'bfd_key_id': bfd_key_id,
2131 'conf_key_id': conf_key_id,
2132 })
2133
2134 def bfd_udp_auth_deactivate(self, sw_if_index, local_addr, peer_addr,
2135 is_ipv6=0, is_delayed=False):
2136 return self.api(self.papi.bfd_udp_auth_deactivate,
2137 {
2138 'sw_if_index': sw_if_index,
2139 'local_addr': local_addr,
2140 'peer_addr': peer_addr,
2141 'is_ipv6': is_ipv6,
2142 'is_delayed': 1 if is_delayed else 0,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02002143 })
2144
2145 def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0):
2146 return self.api(self.papi.bfd_udp_del,
2147 {
2148 'sw_if_index': sw_if_index,
2149 'local_addr': local_addr,
2150 'peer_addr': peer_addr,
2151 'is_ipv6': is_ipv6,
2152 })
2153
2154 def bfd_udp_session_dump(self):
2155 return self.api(self.papi.bfd_udp_session_dump, {})
2156
Klement Sekerab17dd962017-01-09 07:43:48 +01002157 def bfd_udp_session_set_flags(self, admin_up_down, sw_if_index, local_addr,
2158 peer_addr, is_ipv6=0):
2159 return self.api(self.papi.bfd_udp_session_set_flags, {
Klement Sekera0e3c0de2016-09-29 14:43:44 +02002160 'admin_up_down': admin_up_down,
Klement Sekerab17dd962017-01-09 07:43:48 +01002161 'sw_if_index': sw_if_index,
2162 'local_addr': local_addr,
2163 'peer_addr': peer_addr,
2164 'is_ipv6': is_ipv6,
Klement Sekera0e3c0de2016-09-29 14:43:44 +02002165 })
2166
2167 def want_bfd_events(self, enable_disable=1):
2168 return self.api(self.papi.want_bfd_events, {
2169 'enable_disable': enable_disable,
2170 'pid': os.getpid(),
2171 })
Steve Shin7957d6e2016-12-19 09:24:50 -08002172
Klement Sekerab17dd962017-01-09 07:43:48 +01002173 def bfd_auth_set_key(self, conf_key_id, auth_type, key):
2174 return self.api(self.papi.bfd_auth_set_key, {
2175 'conf_key_id': conf_key_id,
2176 'auth_type': auth_type,
2177 'key': key,
2178 'key_len': len(key),
2179 })
2180
2181 def bfd_auth_del_key(self, conf_key_id):
2182 return self.api(self.papi.bfd_auth_del_key, {
2183 'conf_key_id': conf_key_id,
2184 })
2185
2186 def bfd_auth_keys_dump(self):
2187 return self.api(self.papi.bfd_auth_keys_dump, {})
2188
Klement Sekera239790f2017-02-16 10:53:53 +01002189 def bfd_udp_set_echo_source(self, sw_if_index):
2190 return self.api(self.papi.bfd_udp_set_echo_source,
2191 {'sw_if_index': sw_if_index})
2192
Klement Sekera73884482017-02-23 09:26:30 +01002193 def bfd_udp_del_echo_source(self):
2194 return self.api(self.papi.bfd_udp_del_echo_source, {})
2195
Steve Shin7957d6e2016-12-19 09:24:50 -08002196 def classify_add_del_table(
2197 self,
2198 is_add,
2199 mask,
2200 match_n_vectors=1,
2201 table_index=0xFFFFFFFF,
2202 nbuckets=2,
2203 memory_size=2097152,
2204 skip_n_vectors=0,
2205 next_table_index=0xFFFFFFFF,
2206 miss_next_index=0xFFFFFFFF,
2207 current_data_flag=0,
2208 current_data_offset=0):
Steve Shin7957d6e2016-12-19 09:24:50 -08002209 """
2210 :param is_add:
2211 :param mask:
Klement Sekerada505f62017-01-04 12:58:53 +01002212 :param match_n_vectors: (Default value = 1)
Matej Klotton8d8a1da2016-12-22 11:06:56 +01002213 :param table_index: (Default value = 0xFFFFFFFF)
Steve Shin7957d6e2016-12-19 09:24:50 -08002214 :param nbuckets: (Default value = 2)
2215 :param memory_size: (Default value = 2097152)
2216 :param skip_n_vectors: (Default value = 0)
2217 :param next_table_index: (Default value = 0xFFFFFFFF)
2218 :param miss_next_index: (Default value = 0xFFFFFFFF)
2219 :param current_data_flag: (Default value = 0)
2220 :param current_data_offset: (Default value = 0)
2221 """
2222
2223 return self.api(
2224 self.papi.classify_add_del_table,
Klement Sekera77fabdb2017-01-02 07:46:14 +01002225 {'is_add': is_add,
2226 'table_index': table_index,
2227 'nbuckets': nbuckets,
Steve Shin7957d6e2016-12-19 09:24:50 -08002228 'memory_size': memory_size,
Klement Sekera77fabdb2017-01-02 07:46:14 +01002229 'skip_n_vectors': skip_n_vectors,
2230 'match_n_vectors': match_n_vectors,
2231 'next_table_index': next_table_index,
2232 'miss_next_index': miss_next_index,
2233 'current_data_flag': current_data_flag,
2234 'current_data_offset': current_data_offset,
2235 'mask': mask})
Steve Shin7957d6e2016-12-19 09:24:50 -08002236
2237 def classify_add_del_session(
2238 self,
2239 is_add,
2240 table_index,
2241 match,
2242 opaque_index=0xFFFFFFFF,
2243 hit_next_index=0xFFFFFFFF,
2244 advance=0,
2245 action=0,
2246 metadata=0):
2247 """
2248 :param is_add:
2249 :param table_index:
2250 :param match:
2251 :param opaque_index: (Default value = 0xFFFFFFFF)
2252 :param hit_next_index: (Default value = 0xFFFFFFFF)
2253 :param advance: (Default value = 0)
2254 :param action: (Default value = 0)
2255 :param metadata: (Default value = 0)
2256 """
2257
2258 return self.api(
2259 self.papi.classify_add_del_session,
Klement Sekera77fabdb2017-01-02 07:46:14 +01002260 {'is_add': is_add,
2261 'table_index': table_index,
2262 'hit_next_index': hit_next_index,
2263 'opaque_index': opaque_index,
2264 'advance': advance,
2265 'action': action,
2266 'metadata': metadata,
2267 'match': match})
Steve Shin7957d6e2016-12-19 09:24:50 -08002268
2269 def input_acl_set_interface(
2270 self,
2271 is_add,
2272 sw_if_index,
2273 ip4_table_index=0xFFFFFFFF,
2274 ip6_table_index=0xFFFFFFFF,
2275 l2_table_index=0xFFFFFFFF):
2276 """
2277 :param is_add:
2278 :param sw_if_index:
2279 :param ip4_table_index: (Default value = 0xFFFFFFFF)
2280 :param ip6_table_index: (Default value = 0xFFFFFFFF)
2281 :param l2_table_index: (Default value = 0xFFFFFFFF)
2282 """
2283
2284 return self.api(
2285 self.papi.input_acl_set_interface,
Klement Sekera77fabdb2017-01-02 07:46:14 +01002286 {'sw_if_index': sw_if_index,
2287 'ip4_table_index': ip4_table_index,
2288 'ip6_table_index': ip6_table_index,
2289 'l2_table_index': l2_table_index,
2290 'is_add': is_add})
2291
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +01002292 def output_acl_set_interface(
2293 self,
2294 is_add,
2295 sw_if_index,
2296 ip4_table_index=0xFFFFFFFF,
2297 ip6_table_index=0xFFFFFFFF,
2298 l2_table_index=0xFFFFFFFF):
2299 """
2300 :param is_add:
2301 :param sw_if_index:
2302 :param ip4_table_index: (Default value = 0xFFFFFFFF)
2303 :param ip6_table_index: (Default value = 0xFFFFFFFF)
2304 :param l2_table_index: (Default value = 0xFFFFFFFF)
2305 """
2306
2307 return self.api(
2308 self.papi.output_acl_set_interface,
2309 {'sw_if_index': sw_if_index,
2310 'ip4_table_index': ip4_table_index,
2311 'ip6_table_index': ip6_table_index,
2312 'l2_table_index': l2_table_index,
2313 'is_add': is_add})
2314
Klement Sekera77fabdb2017-01-02 07:46:14 +01002315 def set_ipfix_exporter(
2316 self,
2317 collector_address,
2318 src_address,
2319 path_mtu,
2320 template_interval,
2321 vrf_id=0,
2322 collector_port=4739,
2323 udp_checksum=0):
2324 return self.api(
2325 self.papi.set_ipfix_exporter,
2326 {
2327 'collector_address': collector_address,
2328 'collector_port': collector_port,
2329 'src_address': src_address,
2330 'vrf_id': vrf_id,
2331 'path_mtu': path_mtu,
2332 'template_interval': template_interval,
2333 'udp_checksum': udp_checksum,
2334 })
Neale Rannsfca0c242017-01-13 07:57:46 -08002335
2336 def dhcp_proxy_config(self,
2337 dhcp_server,
2338 dhcp_src_address,
2339 rx_table_id=0,
2340 server_table_id=0,
2341 is_add=1,
Neale Ranns20a175a2017-02-14 07:28:41 -08002342 is_ipv6=0):
Neale Rannsfca0c242017-01-13 07:57:46 -08002343 return self.api(
Neale Ranns20a175a2017-02-14 07:28:41 -08002344 self.papi.dhcp_proxy_config,
Neale Rannsfca0c242017-01-13 07:57:46 -08002345 {
2346 'rx_vrf_id': rx_table_id,
2347 'server_vrf_id': server_table_id,
2348 'is_ipv6': is_ipv6,
2349 'is_add': is_add,
Neale Rannsfca0c242017-01-13 07:57:46 -08002350 'dhcp_server': dhcp_server,
2351 'dhcp_src_address': dhcp_src_address,
2352 })
2353
2354 def dhcp_proxy_set_vss(self,
2355 table_id,
John Lo70bfcaf2017-11-14 13:19:26 -05002356 vss_type=255,
2357 vpn_ascii_id="",
2358 oui=0,
2359 vpn_index=0,
Neale Rannsfca0c242017-01-13 07:57:46 -08002360 is_add=1,
2361 is_ip6=0):
2362 return self.api(
2363 self.papi.dhcp_proxy_set_vss,
2364 {
2365 'tbl_id': table_id,
John Lo70bfcaf2017-11-14 13:19:26 -05002366 'vss_type': vss_type,
2367 'vpn_ascii_id': vpn_ascii_id,
Neale Rannsfca0c242017-01-13 07:57:46 -08002368 'oui': oui,
John Lo70bfcaf2017-11-14 13:19:26 -05002369 'vpn_index': vpn_index,
2370 'is_add': is_add,
2371 'is_ipv6': is_ip6,
Neale Rannsfca0c242017-01-13 07:57:46 -08002372 })
Neale Ranns32e1c012016-11-22 17:07:28 +00002373
Neale Rannsdaff1782018-05-16 04:12:18 -07002374 def dhcp_client_dump(self):
2375 return self.api(self.papi.dhcp_client_dump, {})
2376
Neale Rannsa2fbf6b2017-07-18 08:23:32 -07002377 def dhcp_client(self,
2378 sw_if_index,
2379 hostname,
Neale Ranns51822bf2017-07-18 09:26:53 -07002380 client_id='',
Neale Rannsa2fbf6b2017-07-18 08:23:32 -07002381 is_add=1,
Neale Ranns54c6dc42018-01-17 10:29:10 -08002382 set_broadcast_flag=1,
Neale Rannsa2fbf6b2017-07-18 08:23:32 -07002383 want_dhcp_events=0):
2384 return self.api(
2385 self.papi.dhcp_client_config,
2386 {
Neale Rannsa2fbf6b2017-07-18 08:23:32 -07002387 'is_add': is_add,
Neale Rannsdaff1782018-05-16 04:12:18 -07002388 'client': {
2389 'sw_if_index': sw_if_index,
2390 'hostname': hostname,
2391 'id': client_id,
2392 'want_dhcp_event': want_dhcp_events,
2393 'set_broadcast_flag': set_broadcast_flag,
2394 'pid': os.getpid()}
Neale Rannsa2fbf6b2017-07-18 08:23:32 -07002395 })
2396
Neale Ranns32e1c012016-11-22 17:07:28 +00002397 def ip_mroute_add_del(self,
2398 src_address,
2399 grp_address,
2400 grp_address_length,
2401 e_flags,
Neale Rannsd792d9c2017-10-21 10:53:20 -07002402 next_hop_afi,
Neale Ranns32e1c012016-11-22 17:07:28 +00002403 next_hop_sw_if_index,
Neale Rannse821ab12017-06-01 07:45:05 -07002404 next_hop_address,
Neale Ranns32e1c012016-11-22 17:07:28 +00002405 i_flags,
Neale Rannsd792d9c2017-10-21 10:53:20 -07002406 bier_imp=0,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08002407 rpf_id=0,
Neale Ranns32e1c012016-11-22 17:07:28 +00002408 table_id=0,
Neale Ranns32e1c012016-11-22 17:07:28 +00002409 is_add=1,
2410 is_ipv6=0,
2411 is_local=0):
2412 """
Neale Rannsd792d9c2017-10-21 10:53:20 -07002413 IP Multicast Route add/del
Neale Ranns32e1c012016-11-22 17:07:28 +00002414 """
2415 return self.api(
2416 self.papi.ip_mroute_add_del,
2417 {'next_hop_sw_if_index': next_hop_sw_if_index,
2418 'entry_flags': e_flags,
2419 'itf_flags': i_flags,
Neale Ranns0f26c5a2017-03-01 15:12:11 -08002420 'table_id': table_id,
2421 'rpf_id': rpf_id,
Neale Ranns32e1c012016-11-22 17:07:28 +00002422 'is_add': is_add,
2423 'is_ipv6': is_ipv6,
2424 'is_local': is_local,
Neale Rannsd792d9c2017-10-21 10:53:20 -07002425 'bier_imp': bier_imp,
2426 'next_hop_afi': next_hop_afi,
Neale Ranns32e1c012016-11-22 17:07:28 +00002427 'grp_address_length': grp_address_length,
2428 'grp_address': grp_address,
Neale Rannse821ab12017-06-01 07:45:05 -07002429 'src_address': src_address,
2430 'nh_address': next_hop_address})
Neale Ranns32e1c012016-11-22 17:07:28 +00002431
2432 def mfib_signal_dump(self):
2433 return self.api(self.papi.mfib_signal_dump, {})
Neale Ranns5a8123b2017-01-26 01:18:23 -08002434
2435 def ip_mfib_dump(self):
2436 return self.api(self.papi.ip_mfib_dump, {})
Filip Tehlar770e89e2017-01-31 10:39:16 +01002437
Neale Rannsd792d9c2017-10-21 10:53:20 -07002438 def ip6_mfib_dump(self):
2439 return self.api(self.papi.ip6_mfib_dump, {})
2440
Filip Tehlar770e89e2017-01-31 10:39:16 +01002441 def lisp_enable_disable(self, is_enabled):
2442 return self.api(
2443 self.papi.lisp_enable_disable,
2444 {
2445 'is_en': is_enabled,
2446 })
2447
2448 def lisp_locator_set(self,
2449 ls_name,
2450 is_add=1):
2451 return self.api(
2452 self.papi.lisp_add_del_locator_set,
2453 {
2454 'is_add': is_add,
2455 'locator_set_name': ls_name
2456 })
2457
2458 def lisp_locator_set_dump(self):
2459 return self.api(self.papi.lisp_locator_set_dump, {})
2460
2461 def lisp_locator(self,
2462 ls_name,
2463 sw_if_index,
2464 priority=1,
2465 weight=1,
2466 is_add=1):
2467 return self.api(
2468 self.papi.lisp_add_del_locator,
2469 {
2470 'is_add': is_add,
2471 'locator_set_name': ls_name,
2472 'sw_if_index': sw_if_index,
2473 'priority': priority,
2474 'weight': weight
2475 })
2476
2477 def lisp_locator_dump(self, is_index_set, ls_name=None, ls_index=0):
2478 return self.api(
2479 self.papi.lisp_locator_dump,
2480 {
2481 'is_index_set': is_index_set,
2482 'ls_name': ls_name,
2483 'ls_index': ls_index,
2484 })
2485
2486 def lisp_local_mapping(self,
2487 ls_name,
2488 eid_type,
2489 eid,
2490 prefix_len,
2491 vni=0,
2492 key_id=0,
2493 key="",
2494 is_add=1):
2495 return self.api(
2496 self.papi.lisp_add_del_local_eid,
2497 {
2498 'locator_set_name': ls_name,
2499 'is_add': is_add,
2500 'eid_type': eid_type,
2501 'eid': eid,
2502 'prefix_len': prefix_len,
2503 'vni': vni,
2504 'key_id': key_id,
2505 'key': key
2506 })
2507
2508 def lisp_eid_table_dump(self,
2509 eid_set=0,
2510 prefix_length=0,
2511 vni=0,
2512 eid_type=0,
2513 eid=None,
2514 filter_opt=0):
2515 return self.api(
2516 self.papi.lisp_eid_table_dump,
2517 {
2518 'eid_set': eid_set,
2519 'prefix_length': prefix_length,
2520 'vni': vni,
2521 'eid_type': eid_type,
2522 'eid': eid,
2523 'filter': filter_opt,
2524 })
2525
2526 def lisp_remote_mapping(self,
2527 eid_type,
2528 eid,
2529 eid_prefix_len=0,
2530 vni=0,
Ole Troan895b6e82017-10-20 13:28:20 +02002531 rlocs=[],
Filip Tehlar770e89e2017-01-31 10:39:16 +01002532 rlocs_num=0,
2533 is_src_dst=0,
2534 is_add=1):
2535 return self.api(
2536 self.papi.lisp_add_del_remote_mapping,
2537 {
2538 'is_add': is_add,
2539 'eid_type': eid_type,
2540 'eid': eid,
2541 'eid_len': eid_prefix_len,
2542 'rloc_num': rlocs_num,
2543 'rlocs': rlocs,
2544 'vni': vni,
2545 'is_src_dst': is_src_dst,
2546 })
2547
2548 def lisp_adjacency(self,
2549 leid,
2550 reid,
2551 leid_len,
2552 reid_len,
2553 eid_type,
2554 is_add=1,
2555 vni=0):
2556 return self.api(
2557 self.papi.lisp_add_del_adjacency,
2558 {
2559 'is_add': is_add,
2560 'vni': vni,
2561 'eid_type': eid_type,
2562 'leid': leid,
2563 'reid': reid,
2564 'leid_len': leid_len,
2565 'reid_len': reid_len,
2566 })
2567
2568 def lisp_adjacencies_get(self, vni=0):
2569 return self.api(
2570 self.papi.lisp_adjacencies_get,
2571 {
2572 'vni': vni
2573 })
Neale Ranns80823802017-02-20 18:23:41 -08002574
2575 def map_add_domain(self,
2576 ip6_prefix,
2577 ip6_prefix_len,
2578 ip6_src,
2579 ip6_src_prefix_len,
2580 ip4_prefix,
2581 ip4_prefix_len,
2582 ea_bits_len=0,
2583 psid_offset=0,
2584 psid_length=0,
2585 is_translation=0,
Juraj Slobodacba69362017-12-19 02:09:32 +01002586 is_rfc6052=0,
Neale Ranns80823802017-02-20 18:23:41 -08002587 mtu=1280):
2588 return self.api(
2589 self.papi.map_add_domain,
2590 {
2591 'ip6_prefix': ip6_prefix,
2592 'ip6_prefix_len': ip6_prefix_len,
2593 'ip4_prefix': ip4_prefix,
2594 'ip4_prefix_len': ip4_prefix_len,
2595 'ip6_src': ip6_src,
2596 'ip6_src_prefix_len': ip6_src_prefix_len,
2597 'ea_bits_len': ea_bits_len,
2598 'psid_offset': psid_offset,
2599 'psid_length': psid_length,
2600 'is_translation': is_translation,
Juraj Slobodacba69362017-12-19 02:09:32 +01002601 'is_rfc6052': is_rfc6052,
Neale Ranns80823802017-02-20 18:23:41 -08002602 'mtu': mtu
2603 })
Hongjun Nief486b12017-04-12 19:21:16 +08002604
2605 def gtpu_add_del_tunnel(
2606 self,
2607 src_addr,
2608 dst_addr,
2609 is_add=1,
2610 is_ipv6=0,
2611 mcast_sw_if_index=0xFFFFFFFF,
2612 encap_vrf_id=0,
2613 decap_next_index=0xFFFFFFFF,
2614 teid=0):
2615 """
2616
2617 :param is_add: (Default value = 1)
2618 :param is_ipv6: (Default value = 0)
2619 :param src_addr:
2620 :param dst_addr:
2621 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
2622 :param encap_vrf_id: (Default value = 0)
2623 :param decap_next_index: (Default value = 0xFFFFFFFF)
2624 :param teid: (Default value = 0)
2625
2626 """
2627 return self.api(self.papi.gtpu_add_del_tunnel,
2628 {'is_add': is_add,
2629 'is_ipv6': is_ipv6,
2630 'src_address': src_addr,
2631 'dst_address': dst_addr,
2632 'mcast_sw_if_index': mcast_sw_if_index,
2633 'encap_vrf_id': encap_vrf_id,
2634 'decap_next_index': decap_next_index,
2635 'teid': teid})
Hongjun Ni8a0a0ae2017-05-27 20:23:09 +08002636
2637 def vxlan_gpe_add_del_tunnel(
2638 self,
2639 src_addr,
2640 dst_addr,
2641 mcast_sw_if_index=0xFFFFFFFF,
2642 is_add=1,
2643 is_ipv6=0,
2644 encap_vrf_id=0,
2645 decap_vrf_id=0,
2646 protocol=3,
2647 vni=0):
2648 """
2649
2650 :param local:
2651 :param remote:
2652 :param is_add: (Default value = 1)
2653 :param is_ipv6: (Default value = 0)
2654 :param encap_vrf_id: (Default value = 0)
2655 :param decap_vrf_id: (Default value = 0)
2656 :param mcast_sw_if_index: (Default value = 0xFFFFFFFF)
2657 :param protocol: (Default value = 3)
2658 :param vni: (Default value = 0)
2659
2660 """
2661 return self.api(self.papi.vxlan_gpe_add_del_tunnel,
2662 {'is_add': is_add,
2663 'is_ipv6': is_ipv6,
2664 'local': src_addr,
2665 'remote': dst_addr,
2666 'mcast_sw_if_index': mcast_sw_if_index,
2667 'encap_vrf_id': encap_vrf_id,
2668 'decap_vrf_id': decap_vrf_id,
2669 'protocol': protocol,
2670 'vni': vni})
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08002671
2672 def pppoe_add_del_session(
2673 self,
2674 client_ip,
2675 client_mac,
2676 session_id=0,
2677 is_add=1,
2678 is_ipv6=0,
2679 decap_vrf_id=0):
2680 """
2681
2682 :param is_add: (Default value = 1)
2683 :param is_ipv6: (Default value = 0)
2684 :param client_ip:
2685 :param session_id: (Default value = 0)
2686 :param client_mac:
2687 :param decap_vrf_id: (Default value = 0)
2688
2689 """
2690 return self.api(self.papi.pppoe_add_del_session,
2691 {'is_add': is_add,
2692 'is_ipv6': is_ipv6,
2693 'session_id': session_id,
2694 'client_ip': client_ip,
2695 'decap_vrf_id': decap_vrf_id,
2696 'client_mac': client_mac})
Kris Michielsen91074432017-06-22 13:00:20 +02002697
2698 def sr_localsid_add_del(self,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02002699 localsid,
Kris Michielsen91074432017-06-22 13:00:20 +02002700 behavior,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02002701 nh_addr4,
2702 nh_addr6,
Kris Michielsen91074432017-06-22 13:00:20 +02002703 is_del=0,
2704 end_psp=0,
2705 sw_if_index=0xFFFFFFFF,
2706 vlan_index=0,
2707 fib_table=0,
2708 ):
2709 """ Add/del IPv6 SR local-SID.
2710
Pablo Camarillo3337bd22018-06-19 15:49:02 +02002711 :param localsid:
Kris Michielsen91074432017-06-22 13:00:20 +02002712 :param behavior: END=1; END.X=2; END.DX2=4; END.DX6=5;
2713 :param behavior: END.DX4=6; END.DT6=7; END.DT4=8
Pablo Camarillo3337bd22018-06-19 15:49:02 +02002714 :param nh_addr4:
2715 :param nh_addr6:
Kris Michielsen91074432017-06-22 13:00:20 +02002716 :param is_del: (Default value = 0)
2717 :param end_psp: (Default value = 0)
2718 :param sw_if_index: (Default value = 0xFFFFFFFF)
2719 :param vlan_index: (Default value = 0)
2720 :param fib_table: (Default value = 0)
2721 """
2722 return self.api(
2723 self.papi.sr_localsid_add_del,
2724 {'is_del': is_del,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02002725 'localsid': localsid,
Kris Michielsen91074432017-06-22 13:00:20 +02002726 'end_psp': end_psp,
2727 'behavior': behavior,
2728 'sw_if_index': sw_if_index,
2729 'vlan_index': vlan_index,
2730 'fib_table': fib_table,
Pablo Camarillo3337bd22018-06-19 15:49:02 +02002731 'nh_addr4': nh_addr4,
2732 'nh_addr6': nh_addr6
Kris Michielsen91074432017-06-22 13:00:20 +02002733 }
2734 )
2735
2736 def sr_policy_add(
2737 self,
2738 bsid_addr,
2739 weight=1,
2740 is_encap=1,
2741 type=0,
2742 fib_table=0,
2743 n_segments=0,
2744 segments=[]):
2745 """
2746 :param bsid_addr: bindingSID of the SR Policy
2747 :param weight: weight of the sid list. optional. (default: 1)
2748 :param is_encap: (bool) whether SR policy should Encap or SRH insert \
2749 (default: Encap)
2750 :param type: type/behavior of the SR policy. (default or spray) \
2751 (default: default)
2752 :param fib_table: VRF where to install the FIB entry for the BSID \
2753 (default: 0)
2754 :param n_segments: number of segments \
2755 (default: 0)
2756 :param segments: a vector of IPv6 address composing the segment list \
2757 (default: [])
2758 """
2759 return self.api(
2760 self.papi.sr_policy_add,
2761 {'bsid_addr': bsid_addr,
2762 'weight': weight,
2763 'is_encap': is_encap,
2764 'type': type,
2765 'fib_table': fib_table,
2766 'n_segments': n_segments,
2767 'segments': segments
2768 }
2769 )
2770
2771 def sr_policy_del(
2772 self,
2773 bsid_addr,
2774 sr_policy_index=0):
2775 """
2776 :param bsid: bindingSID of the SR Policy
2777 :param sr_policy_index: index of the sr policy (default: 0)
2778 """
2779 return self.api(
2780 self.papi.sr_policy_del,
2781 {'bsid_addr': bsid_addr,
2782 'sr_policy_index': sr_policy_index
2783 })
2784
2785 def sr_steering_add_del(
2786 self,
2787 is_del,
2788 bsid_addr,
2789 sr_policy_index,
2790 table_id,
2791 prefix_addr,
2792 mask_width,
2793 sw_if_index,
2794 traffic_type):
2795 """
2796 Steer traffic L2 and L3 traffic through a given SR policy
2797
2798 :param is_del: delete or add
2799 :param bsid_addr: bindingSID of the SR Policy (alt to sr_policy_index)
2800 :param sr_policy: is the index of the SR Policy (alt to bsid)
2801 :param table_id: is the VRF where to install the FIB entry for the BSID
2802 :param prefix_addr: is the IPv4/v6 address for L3 traffic type
2803 :param mask_width: is the mask for L3 traffic type
2804 :param sw_if_index: is the incoming interface for L2 traffic
2805 :param traffic_type: type of traffic (IPv4: 4, IPv6: 6, L2: 2)
2806 """
2807 return self.api(
2808 self.papi.sr_steering_add_del,
2809 {'is_del': is_del,
2810 'bsid_addr': bsid_addr,
2811 'sr_policy_index': sr_policy_index,
2812 'table_id': table_id,
2813 'prefix_addr': prefix_addr,
2814 'mask_width': mask_width,
2815 'sw_if_index': sw_if_index,
2816 'traffic_type': traffic_type
2817 })
Pavel Kotucek932f7412017-09-07 14:44:52 +02002818
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02002819 def acl_add_replace(self, acl_index, r, tag='',
2820 expected_retval=0):
2821 """Add/replace an ACL
2822 :param int acl_index: ACL index to replace, 2^32-1 to create new ACL.
2823 :param acl_rule r: ACL rules array.
2824 :param str tag: symbolic tag (description) for this ACL.
2825 :param int count: number of rules.
2826 """
2827 return self.api(self.papi.acl_add_replace,
2828 {'acl_index': acl_index,
2829 'r': r,
2830 'count': len(r),
2831 'tag': tag},
2832 expected_retval=expected_retval)
2833
Andrew Yourtchenko987abe92017-09-27 13:50:31 +02002834 def acl_del(self, acl_index, expected_retval=0):
2835 """
2836
2837 :param acl_index:
2838 :return:
2839 """
2840 return self.api(self.papi.acl_del,
2841 {'acl_index': acl_index},
2842 expected_retval=expected_retval)
2843
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02002844 def acl_interface_set_acl_list(self, sw_if_index, n_input, acls,
2845 expected_retval=0):
2846 return self.api(self.papi.acl_interface_set_acl_list,
2847 {'sw_if_index': sw_if_index,
2848 'count': len(acls),
2849 'n_input': n_input,
2850 'acls': acls},
2851 expected_retval=expected_retval)
2852
Andrew Yourtchenkoc43b3f92018-02-06 17:42:32 +01002853 def acl_interface_set_etype_whitelist(self, sw_if_index,
2854 n_input, whitelist,
2855 expected_retval=0):
2856 return self.api(self.papi.acl_interface_set_etype_whitelist,
2857 {'sw_if_index': sw_if_index,
2858 'count': len(whitelist),
2859 'n_input': n_input,
2860 'whitelist': whitelist},
2861 expected_retval=expected_retval)
2862
Pavel Kotucek8daa80a2017-09-25 09:44:05 +02002863 def acl_interface_add_del(self,
2864 sw_if_index,
2865 acl_index,
2866 is_add=1):
2867 """ Add/Delete ACL to/from interface
2868
2869 :param sw_if_index:
2870 :param acl_index:
2871 :param is_add: (Default value = 1)
2872 """
2873
2874 return self.api(self.papi.acl_interface_add_del,
2875 {'is_add': is_add,
2876 'is_input': 1,
2877 'sw_if_index': sw_if_index,
2878 'acl_index': acl_index})
2879
Andrew Yourtchenko51d26512017-09-14 18:26:36 +02002880 def acl_dump(self, acl_index, expected_retval=0):
2881 return self.api(self.papi.acl_dump,
2882 {'acl_index': acl_index},
2883 expected_retval=expected_retval)
2884
Andrew Yourtchenko0e89dfc2018-03-23 09:34:29 +01002885 def acl_interface_list_dump(self, sw_if_index=0xFFFFFFFF,
2886 expected_retval=0):
2887 return self.api(self.papi.acl_interface_list_dump,
2888 {'sw_if_index': sw_if_index},
2889 expected_retval=expected_retval)
2890
Pavel Kotucekc29940c2017-09-07 08:17:31 +02002891 def macip_acl_add(self, rules, tag=""):
2892 """ Add MACIP acl
2893
2894 :param rules: list of rules for given acl
2895 :param tag: acl tag
2896 """
2897
2898 return self.api(self.papi.macip_acl_add,
2899 {'r': rules,
2900 'count': len(rules),
2901 'tag': tag})
2902
Pavel Kotucek932f7412017-09-07 14:44:52 +02002903 def macip_acl_add_replace(self, rules, acl_index=0xFFFFFFFF, tag=""):
2904 """ Add MACIP acl
2905
2906 :param rules: list of rules for given acl
2907 :param tag: acl tag
2908 """
2909
Pavel Kotucekc29940c2017-09-07 08:17:31 +02002910 return self.api(self.papi.macip_acl_add_replace,
2911 {'acl_index': acl_index,
2912 'r': rules,
Pavel Kotucek932f7412017-09-07 14:44:52 +02002913 'count': len(rules),
2914 'tag': tag})
2915
2916 def macip_acl_del(self, acl_index):
2917 """
2918
2919 :param acl_index:
2920 :return:
2921 """
2922 return self.api(self.papi.macip_acl_del,
2923 {'acl_index': acl_index})
2924
2925 def macip_acl_interface_add_del(self,
2926 sw_if_index,
2927 acl_index,
2928 is_add=1):
2929 """ Add MACIP acl to interface
2930
2931 :param sw_if_index:
2932 :param acl_index:
2933 :param is_add: (Default value = 1)
2934 """
2935
2936 return self.api(self.papi.macip_acl_interface_add_del,
2937 {'is_add': is_add,
2938 'sw_if_index': sw_if_index,
2939 'acl_index': acl_index})
2940
2941 def macip_acl_interface_get(self):
2942 """ Return interface acls dump
2943 """
2944 return self.api(
2945 self.papi.macip_acl_interface_get, {})
2946
2947 def macip_acl_dump(self, acl_index=4294967295):
2948 """ Return MACIP acl dump
2949 """
2950
2951 return self.api(
2952 self.papi.macip_acl_dump, {'acl_index': acl_index})
Neale Rannsd91c1db2017-07-31 02:30:50 -07002953
2954 def policer_add_del(self,
2955 name,
2956 cir,
2957 eir,
2958 cb,
2959 eb,
2960 is_add=1,
2961 rate_type=0,
2962 round_type=0,
2963 ptype=0,
2964 color_aware=0,
2965 conform_action_type=1,
2966 conform_dscp=0,
2967 exceed_action_type=0,
2968 exceed_dscp=0,
2969 violate_action_type=0,
2970 violate_dscp=0):
2971 return self.api(self.papi.policer_add_del,
2972 {'name': name,
2973 'cir': cir,
2974 'eir': eir,
2975 'cb': cb,
2976 'eb': eb,
2977 'is_add': is_add,
2978 'rate_type': rate_type,
2979 'round_type': round_type,
2980 'type': ptype,
2981 'color_aware': color_aware,
2982 'conform_action_type': conform_action_type,
2983 'conform_dscp': conform_dscp,
2984 'exceed_action_type': exceed_action_type,
2985 'exceed_dscp': exceed_dscp,
2986 'violate_action_type': violate_action_type,
2987 'violate_dscp': violate_dscp})
2988
2989 def ip_punt_police(self,
2990 policer_index,
2991 is_ip6=0,
2992 is_add=1):
2993 return self.api(self.papi.ip_punt_police,
2994 {'policer_index': policer_index,
2995 'is_add': is_add,
2996 'is_ip6': is_ip6})
2997
2998 def ip_punt_redirect(self,
2999 rx_sw_if_index,
3000 tx_sw_if_index,
3001 nh,
3002 is_ip6=0,
3003 is_add=1):
3004 return self.api(self.papi.ip_punt_redirect,
3005 {'rx_sw_if_index': rx_sw_if_index,
3006 'tx_sw_if_index': tx_sw_if_index,
3007 'nh': nh,
3008 'is_add': is_add,
3009 'is_ip6': is_ip6})
Neale Rannsd792d9c2017-10-21 10:53:20 -07003010
3011 def bier_table_add_del(self,
3012 bti,
3013 mpls_label,
3014 is_add=1):
3015 """ BIER Table add/del """
3016 return self.api(
3017 self.papi.bier_table_add_del,
3018 {'bt_tbl_id': {"bt_set": bti.set_id,
3019 "bt_sub_domain": bti.sub_domain_id,
3020 "bt_hdr_len_id": bti.hdr_len_id},
3021 'bt_label': mpls_label,
3022 'bt_is_add': is_add})
3023
3024 def bier_table_dump(self):
3025 return self.api(self.papi.bier_table_dump, {})
3026
3027 def bier_route_add_del(self,
3028 bti,
3029 bp,
Neale Ranns91286372017-12-05 13:24:04 -08003030 paths,
Neale Rannsd792d9c2017-10-21 10:53:20 -07003031 is_add=1):
3032 """ BIER Route add/del """
3033 return self.api(
3034 self.papi.bier_route_add_del,
3035 {'br_tbl_id': {"bt_set": bti.set_id,
3036 "bt_sub_domain": bti.sub_domain_id,
3037 "bt_hdr_len_id": bti.hdr_len_id},
3038 'br_bp': bp,
Neale Ranns31ed7442018-02-23 05:29:09 -08003039 'br_n_paths': len(paths),
3040 'br_paths': paths,
Neale Rannsd792d9c2017-10-21 10:53:20 -07003041 'br_is_add': is_add})
3042
3043 def bier_route_dump(self, bti):
3044 return self.api(
3045 self.papi.bier_route_dump,
3046 {'br_tbl_id': {"bt_set": bti.set_id,
3047 "bt_sub_domain": bti.sub_domain_id,
3048 "bt_hdr_len_id": bti.hdr_len_id}})
3049
3050 def bier_imp_add(self,
3051 bti,
3052 src,
3053 ibytes,
3054 is_add=1):
3055 """ BIER Imposition Add """
3056 return self.api(
3057 self.papi.bier_imp_add,
3058 {'bi_tbl_id': {"bt_set": bti.set_id,
3059 "bt_sub_domain": bti.sub_domain_id,
3060 "bt_hdr_len_id": bti.hdr_len_id},
3061 'bi_src': src,
3062 'bi_n_bytes': len(ibytes),
3063 'bi_bytes': ibytes})
3064
3065 def bier_imp_del(self, bi_index):
3066 """ BIER Imposition del """
3067 return self.api(
3068 self.papi.bier_imp_del,
3069 {'bi_index': bi_index})
3070
3071 def bier_imp_dump(self):
3072 return self.api(self.papi.bier_imp_dump, {})
3073
3074 def bier_disp_table_add_del(self,
3075 bdti,
3076 is_add=1):
3077 """ BIER Disposition Table add/del """
3078 return self.api(
3079 self.papi.bier_disp_table_add_del,
3080 {'bdt_tbl_id': bdti,
3081 'bdt_is_add': is_add})
3082
3083 def bier_disp_table_dump(self):
3084 return self.api(self.papi.bier_disp_table_dump, {})
3085
3086 def bier_disp_entry_add_del(self,
3087 bdti,
3088 bp,
3089 payload_proto,
Neale Rannsf0510722018-01-31 11:35:41 -08003090 next_hop_afi,
Neale Rannsd792d9c2017-10-21 10:53:20 -07003091 next_hop,
3092 next_hop_tbl_id=0,
3093 next_hop_rpf_id=~0,
3094 next_hop_is_ip4=1,
3095 is_add=1):
3096 """ BIER Route add/del """
Neale Ranns31ed7442018-02-23 05:29:09 -08003097 lstack = []
3098 while (len(lstack) < 16):
3099 lstack.append({})
Neale Rannsd792d9c2017-10-21 10:53:20 -07003100 return self.api(
3101 self.papi.bier_disp_entry_add_del,
3102 {'bde_tbl_id': bdti,
3103 'bde_bp': bp,
3104 'bde_payload_proto': payload_proto,
3105 'bde_n_paths': 1,
3106 'bde_paths': [{'next_hop': next_hop,
3107 'table_id': next_hop_tbl_id,
Neale Rannsf0510722018-01-31 11:35:41 -08003108 'afi': next_hop_afi,
Neale Rannsd792d9c2017-10-21 10:53:20 -07003109 'rpf_id': next_hop_rpf_id,
3110 'n_labels': 0,
Neale Ranns31ed7442018-02-23 05:29:09 -08003111 'label_stack': lstack}],
Neale Rannsd792d9c2017-10-21 10:53:20 -07003112 'bde_is_add': is_add})
3113
3114 def bier_disp_entry_dump(self, bdti):
3115 return self.api(
3116 self.papi.bier_disp_entry_dump,
3117 {'bde_tbl_id': bdti})
Gabriel Ganne8527f122017-10-02 11:41:24 +02003118
3119 def add_node_next(self, node_name, next_name):
3120 """ Set the next node for a given node request
3121
3122 :param node_name:
3123 :param next_name:
3124 """
3125 return self.api(self.papi.add_node_next,
3126 {'node_name': node_name,
3127 'next_name': next_name})
Florin Coras3ea6ce22017-12-11 09:09:05 -08003128
3129 def session_enable_disable(self, is_enabled):
3130 return self.api(
3131 self.papi.session_enable_disable,
3132 {'is_enable': is_enabled})
“mystarrocks”23f0c452017-12-11 07:11:51 -08003133
3134 def ipsec_spd_add_del(self, spd_id, is_add=1):
3135 """ SPD add/del - Wrapper to add or del ipsec SPD
3136 Sample CLI : 'ipsec spd add 1'
3137
3138 :param spd_id - SPD ID to be created in the vpp . mandatory
3139 :param is_add - create (1) or delete(0) SPD (Default 1 - add) .
3140 optional
3141 :returns: reply from the API
3142 """
3143 return self.api(
3144 self.papi.ipsec_spd_add_del, {
3145 'spd_id': spd_id, 'is_add': is_add})
3146
3147 def ipsec_interface_add_del_spd(self, spd_id, sw_if_index, is_add=1):
3148 """ IPSEC interface SPD add/del - \
3149 Wrapper to associate/disassociate SPD to interface in VPP
3150 Sample CLI : 'set interface ipsec spd GigabitEthernet0/6/0 1'
3151
3152 :param spd_id - SPD ID to associate with the interface . mandatory
3153 :param sw_if_index - Interface Index which needs to ipsec \
3154 association mandatory
3155 :param is_add - add(1) or del(0) association with interface \
3156 (Default 1 - add) . optional
3157 :returns: reply from the API
3158 """
3159 return self.api(
Klement Sekera4b089f22018-04-17 18:04:57 +02003160 self.papi.ipsec_interface_add_del_spd,
3161 {'spd_id': spd_id, 'sw_if_index': sw_if_index, 'is_add': is_add})
“mystarrocks”23f0c452017-12-11 07:11:51 -08003162
3163 def ipsec_sad_add_del_entry(self,
3164 sad_id,
3165 spi,
Klement Sekera31da2e32018-06-24 22:49:55 +02003166 integrity_algorithm,
3167 integrity_key,
3168 crypto_algorithm,
3169 crypto_key,
3170 protocol,
“mystarrocks”23f0c452017-12-11 07:11:51 -08003171 tunnel_src_address='',
3172 tunnel_dst_address='',
Ole Troane0d2bd62018-06-22 22:36:46 +02003173 is_tunnel=1,
Klement Sekera31da2e32018-06-24 22:49:55 +02003174 is_add=1,
Klement Sekera4b089f22018-04-17 18:04:57 +02003175 udp_encap=0):
“mystarrocks”23f0c452017-12-11 07:11:51 -08003176 """ IPSEC SA add/del
Klement Sekera31da2e32018-06-24 22:49:55 +02003177 :param sad_id: security association ID
3178 :param spi: security param index of the SA in decimal
3179 :param integrity_algorithm:
3180 :param integrity_key:
3181 :param crypto_algorithm:
3182 :param crypto_key:
3183 :param protocol: AH(0) or ESP(1) protocol
3184 :param tunnel_src_address: tunnel mode outer src address
3185 :param tunnel_dst_address: tunnel mode outer dst address
3186 :param is_add:
3187 :param is_tunnel:
“mystarrocks”23f0c452017-12-11 07:11:51 -08003188 :** reference /vpp/src/vnet/ipsec/ipsec.h file for enum values of
3189 crypto and ipsec algorithms
3190 """
3191 return self.api(
3192 self.papi.ipsec_sad_add_del_entry,
3193 {'sad_id': sad_id,
3194 'spi': spi,
3195 'tunnel_src_address': tunnel_src_address,
3196 'tunnel_dst_address': tunnel_dst_address,
3197 'protocol': protocol,
3198 'integrity_algorithm': integrity_algorithm,
Klement Sekera31da2e32018-06-24 22:49:55 +02003199 'integrity_key_length': len(integrity_key),
“mystarrocks”23f0c452017-12-11 07:11:51 -08003200 'integrity_key': integrity_key,
3201 'crypto_algorithm': crypto_algorithm,
Klement Sekera31da2e32018-06-24 22:49:55 +02003202 'crypto_key_length': len(crypto_key) if crypto_key is not None
3203 else 0,
“mystarrocks”23f0c452017-12-11 07:11:51 -08003204 'crypto_key': crypto_key,
3205 'is_add': is_add,
Klement Sekera4b089f22018-04-17 18:04:57 +02003206 'is_tunnel': is_tunnel,
3207 'udp_encap': udp_encap})
“mystarrocks”23f0c452017-12-11 07:11:51 -08003208
3209 def ipsec_spd_add_del_entry(self,
3210 spd_id,
Klement Sekera31da2e32018-06-24 22:49:55 +02003211 sa_id,
“mystarrocks”23f0c452017-12-11 07:11:51 -08003212 local_address_start,
3213 local_address_stop,
3214 remote_address_start,
3215 remote_address_stop,
3216 local_port_start=0,
3217 local_port_stop=65535,
3218 remote_port_start=0,
3219 remote_port_stop=65535,
3220 protocol=0,
“mystarrocks”23f0c452017-12-11 07:11:51 -08003221 policy=0,
3222 priority=100,
3223 is_outbound=1,
3224 is_add=1,
3225 is_ip_any=0):
3226 """ IPSEC policy SPD add/del -
3227 Wrapper to configure ipsec SPD policy entries in VPP
Klement Sekera31da2e32018-06-24 22:49:55 +02003228 :param spd_id: SPD ID for the policy
3229 :param local_address_start: local-ip-range start address
3230 :param local_address_stop : local-ip-range stop address
3231 :param remote_address_start: remote-ip-range start address
3232 :param remote_address_stop : remote-ip-range stop address
3233 :param local_port_start: (Default value = 0)
3234 :param local_port_stop: (Default value = 65535)
3235 :param remote_port_start: (Default value = 0)
3236 :param remote_port_stop: (Default value = 65535)
3237 :param protocol: Any(0), AH(51) & ESP(50) protocol (Default value = 0)
3238 :param sa_id: Security Association ID for mapping it to SPD
3239 :param policy: bypass(0), discard(1), resolve(2) or protect(3) action
3240 (Default value = 0)
3241 :param priority: value for the spd action (Default value = 100)
3242 :param is_outbound: flag for inbound(0) or outbound(1)
3243 (Default value = 1)
3244 :param is_add: (Default value = 1)
“mystarrocks”23f0c452017-12-11 07:11:51 -08003245 """
3246 return self.api(
3247 self.papi.ipsec_spd_add_del_entry,
3248 {'spd_id': spd_id,
Klement Sekera31da2e32018-06-24 22:49:55 +02003249 'sa_id': sa_id,
“mystarrocks”23f0c452017-12-11 07:11:51 -08003250 'local_address_start': local_address_start,
3251 'local_address_stop': local_address_stop,
3252 'remote_address_start': remote_address_start,
3253 'remote_address_stop': remote_address_stop,
3254 'local_port_start': local_port_start,
3255 'local_port_stop': local_port_stop,
3256 'remote_port_start': remote_port_start,
3257 'remote_port_stop': remote_port_stop,
3258 'is_add': is_add,
3259 'protocol': protocol,
3260 'policy': policy,
3261 'priority': priority,
3262 'is_outbound': is_outbound,
“mystarrocks”23f0c452017-12-11 07:11:51 -08003263 'is_ip_any': is_ip_any})
Florin Corasb795bd02017-12-14 11:30:48 -08003264
Klement Sekera31da2e32018-06-24 22:49:55 +02003265 def ipsec_tunnel_if_add_del(self, local_ip, remote_ip, local_spi,
3266 remote_spi, crypto_alg, local_crypto_key,
3267 remote_crypto_key, integ_alg, local_integ_key,
3268 remote_integ_key, is_add=1, esn=0,
3269 anti_replay=1, renumber=0, show_instance=0):
3270 return self.api(
3271 self.papi.ipsec_tunnel_if_add_del,
3272 {'local_ip': local_ip, 'remote_ip': remote_ip,
3273 'local_spi': local_spi, 'remote_spi': remote_spi,
3274 'crypto_alg': crypto_alg,
3275 'local_crypto_key_len': len(local_crypto_key),
3276 'local_crypto_key': local_crypto_key,
3277 'remote_crypto_key_len': len(remote_crypto_key),
3278 'remote_crypto_key': remote_crypto_key, 'integ_alg': integ_alg,
3279 'local_integ_key_len': len(local_integ_key),
3280 'local_integ_key': local_integ_key,
3281 'remote_integ_key_len': len(remote_integ_key),
3282 'remote_integ_key': remote_integ_key, 'is_add': is_add,
3283 'esn': esn, 'anti_replay': anti_replay, 'renumber': renumber,
3284 'show_instance': show_instance
3285 })
3286
Florin Corasb795bd02017-12-14 11:30:48 -08003287 def app_namespace_add(self,
3288 namespace_id,
3289 ip4_fib_id=0,
3290 ip6_fib_id=0,
3291 sw_if_index=0xFFFFFFFF,
3292 secret=0):
3293 return self.api(
3294 self.papi.app_namespace_add_del,
3295 {'secret': secret,
3296 'sw_if_index': sw_if_index,
3297 'ip4_fib_id': ip4_fib_id,
3298 'ip6_fib_id': ip6_fib_id,
3299 'namespace_id': namespace_id,
3300 'namespace_id_len': len(namespace_id)})
Klement Sekera75e7d132017-09-20 08:26:30 +02003301
3302 def punt_socket_register(self, l4_port, pathname, header_version=1,
3303 is_ip4=1, l4_protocol=0x11):
3304 """ Punt to socket """
3305 return self.api(self.papi.punt_socket_register,
3306 {'is_ip4': is_ip4,
3307 'l4_protocol': l4_protocol,
3308 'l4_port': l4_port,
3309 'pathname': pathname,
3310 'header_version': header_version})
3311
3312 def ip_reassembly_set(self, timeout_ms, max_reassemblies,
3313 expire_walk_interval_ms, is_ip6=0):
3314 """ Set IP reassembly parameters """
3315 return self.api(self.papi.ip_reassembly_set,
3316 {'is_ip6': is_ip6,
3317 'timeout_ms': timeout_ms,
3318 'expire_walk_interval_ms': expire_walk_interval_ms,
3319 'max_reassemblies': max_reassemblies})
3320
3321 def ip_reassembly_get(self, is_ip6=0):
3322 """ Get IP reassembly parameters """
3323 return self.api(self.papi.ip_reassembly_get, {'is_ip6': is_ip6})
Neale Rannsbc27d1b2018-02-05 01:13:38 -08003324
Klement Sekera4c533132018-02-22 11:41:12 +01003325 def ip_reassembly_enable_disable(self, sw_if_index, enable_ip4=False,
3326 enable_ip6=False):
3327 """ Enable/disable IP reassembly """
3328 return self.api(self.papi.ip_reassembly_enable_disable,
3329 {'sw_if_index': sw_if_index,
3330 'enable_ip4': 1 if enable_ip4 else 0,
3331 'enable_ip6': 1 if enable_ip6 else 0,
3332 })
3333
Neale Rannsbc27d1b2018-02-05 01:13:38 -08003334 def gbp_endpoint_add_del(self, is_add, sw_if_index, addr, is_ip6, epg):
3335 """ GBP endpoint Add/Del """
3336 return self.api(self.papi.gbp_endpoint_add_del,
3337 {'is_add': is_add,
3338 'endpoint': {
3339 'is_ip6': is_ip6,
3340 'sw_if_index': sw_if_index,
3341 'address': addr,
3342 'epg_id': epg}})
3343
3344 def gbp_endpoint_dump(self):
3345 """ GBP endpoint Dump """
3346 return self.api(self.papi.gbp_endpoint_dump, {})
3347
Neale Ranns25b04942018-04-04 09:34:50 -07003348 def gbp_endpoint_group_add_del(self, is_add, epg, bd,
3349 ip4_rd,
3350 ip6_rd,
3351 uplink_sw_if_index):
3352 """ GBP endpoint group Add/Del """
3353 return self.api(self.papi.gbp_endpoint_group_add_del,
3354 {'is_add': is_add,
3355 'epg': {
3356 'uplink_sw_if_index': uplink_sw_if_index,
3357 'bd_id': bd,
3358 'ip4_table_id': ip4_rd,
3359 'ip6_table_id': ip6_rd,
3360 'epg_id': epg}})
3361
3362 def gbp_endpoint_group_dump(self):
3363 """ GBP endpoint group Dump """
3364 return self.api(self.papi.gbp_endpoint_group_dump, {})
3365
3366 def gbp_recirc_add_del(self, is_add, sw_if_index, epg, is_ext):
3367 """ GBP recirc Add/Del """
3368 return self.api(self.papi.gbp_recirc_add_del,
3369 {'is_add': is_add,
3370 'recirc': {
3371 'is_ext': is_ext,
3372 'sw_if_index': sw_if_index,
3373 'epg_id': epg}})
3374
3375 def gbp_recirc_dump(self):
3376 """ GBP recirc Dump """
3377 return self.api(self.papi.gbp_recirc_dump, {})
3378
3379 def gbp_subnet_add_del(self, is_add, table_id,
3380 is_internal,
3381 addr, addr_len,
3382 sw_if_index=0xffffffff,
3383 epg_id=0xffffffff,
3384 is_ip6=False):
3385 """ GBP Subnet Add/Del """
3386 return self.api(self.papi.gbp_subnet_add_del,
3387 {'is_add': is_add,
3388 'subnet': {
3389 'is_internal': is_internal,
3390 'is_ip6': is_ip6,
3391 'sw_if_index': sw_if_index,
3392 'epg_id': epg_id,
3393 'address': addr,
3394 'address_length': addr_len,
3395 'table_id': table_id}})
3396
3397 def gbp_subnet_dump(self):
3398 """ GBP Subnet Dump """
3399 return self.api(self.papi.gbp_subnet_dump, {})
3400
Neale Rannsbc27d1b2018-02-05 01:13:38 -08003401 def gbp_contract_add_del(self, is_add, src_epg, dst_epg, acl_index):
3402 """ GBP contract Add/Del """
3403 return self.api(self.papi.gbp_contract_add_del,
3404 {'is_add': is_add,
3405 'contract': {
3406 'acl_index': acl_index,
3407 'src_epg': src_epg,
3408 'dst_epg': dst_epg}})
3409
3410 def gbp_contract_dump(self):
3411 """ GBP contract Dump """
3412 return self.api(self.papi.gbp_contract_dump, {})
Ole Troan6ee40512018-02-12 18:14:39 +01003413
Ole Troan298c6952018-03-08 12:30:43 +01003414 def ipip_6rd_add_tunnel(self, fib_index, ip6_prefix, ip6_prefix_len,
3415 ip4_prefix, ip4_prefix_len, ip4_src,
3416 security_check):
Ole Troan6ee40512018-02-12 18:14:39 +01003417 """ 6RD tunnel Add """
Ole Troan298c6952018-03-08 12:30:43 +01003418 return self.api(self.papi.ipip_6rd_add_tunnel,
Ole Troan6ee40512018-02-12 18:14:39 +01003419 {'fib_index': fib_index,
3420 'ip6_prefix': ip6_prefix,
3421 'ip6_prefix_len': ip6_prefix_len,
3422 'ip4_prefix': ip4_prefix,
3423 'ip4_prefix_len': ip4_prefix_len,
3424 'ip4_src': ip4_src,
Ole Troan6ee40512018-02-12 18:14:39 +01003425 'security_check': security_check})
3426
Ole Troan298c6952018-03-08 12:30:43 +01003427 def ipip_6rd_del_tunnel(self, sw_if_index):
Ole Troan6ee40512018-02-12 18:14:39 +01003428 """ 6RD tunnel Delete """
Ole Troan298c6952018-03-08 12:30:43 +01003429 return self.api(self.papi.ipip_6rd_del_tunnel,
3430 {'sw_if_index': sw_if_index})
3431
3432 def ipip_add_tunnel(self, src_address, dst_address, is_ipv6=1,
Ole Troand57f6362018-05-24 13:21:43 +02003433 instance=0xFFFFFFFF, fib_index=0, tc_tos=0):
Ole Troan298c6952018-03-08 12:30:43 +01003434 """ IPIP tunnel Add/Del """
3435 return self.api(self.papi.ipip_add_tunnel,
3436 {'is_ipv6': is_ipv6,
3437 'instance': instance,
3438 'src_address': src_address,
3439 'dst_address': dst_address,
Ole Troand57f6362018-05-24 13:21:43 +02003440 'fib_index': fib_index,
3441 'tc_tos': tc_tos})
Ole Troan298c6952018-03-08 12:30:43 +01003442
3443 def ipip_del_tunnel(self, sw_if_index):
3444 """ IPIP tunnel Delete """
3445 return self.api(self.papi.ipip_del_tunnel,
Ole Troan6ee40512018-02-12 18:14:39 +01003446 {'sw_if_index': sw_if_index})
Neale Ranns039cbfe2018-02-27 03:45:38 -08003447
3448 def qos_egress_map_update(self, id, outputs):
3449 """ QOS egress map update """
3450 return self.api(self.papi.qos_egress_map_update,
3451 {'map_id': id,
3452 'rows': outputs})
3453
3454 def qos_egress_map_delete(self, id):
3455 """ QOS egress map delete """
3456 return self.api(self.papi.qos_egress_map_delete,
3457 {'map_id': id})
3458
3459 def qos_mark_enable_disable(self, sw_if_index,
3460 output_source,
3461 map_id,
3462 enable):
3463 """ QOS Mark Enable/Disable """
3464 return self.api(self.papi.qos_mark_enable_disable,
3465 {'map_id': map_id,
3466 'sw_if_index': sw_if_index,
3467 'output_source': output_source,
3468 'enable': enable})
3469
3470 def qos_record_enable_disable(self, sw_if_index, input_source, enable):
3471 """ IP QoS recording Enble/Disable """
3472 return self.api(self.papi.qos_record_enable_disable,
3473 {'sw_if_index': sw_if_index,
3474 'input_source': input_source,
3475 'enable': enable})
Jakub Grajciar7b867a82017-12-08 16:28:42 +01003476
Neale Ranns947ea622018-06-07 23:48:20 -07003477 def igmp_enable_disable(self, sw_if_index, enable, host):
3478 """ Enable/disable IGMP on a given interface """
3479 return self.api(self.papi.igmp_enable_disable,
3480 {'enable': enable,
3481 'mode': host,
3482 'sw_if_index': sw_if_index})
3483
3484 def igmp_listen(self, filter, sw_if_index, saddrs, gaddr):
Jakub Grajciar7b867a82017-12-08 16:28:42 +01003485 """ Listen for new (S,G) on specified interface
3486
3487 :param enable: add/del
3488 :param sw_if_index: interface sw index
3489 :param saddr: source ip4 addr
3490 :param gaddr: group ip4 addr
3491 """
3492 return self.api(self.papi.igmp_listen,
Neale Ranns947ea622018-06-07 23:48:20 -07003493 {
3494 'group':
3495 {
3496 'filter': filter,
3497 'sw_if_index': sw_if_index,
3498 'n_srcs': len(saddrs),
3499 'saddrs': saddrs,
3500 'gaddr':
3501 {
3502 'address': gaddr
3503 }
3504 }
3505 })
Jakub Grajciar7b867a82017-12-08 16:28:42 +01003506
3507 def igmp_dump(self, sw_if_index=None):
3508 """ Dump all (S,G) interface configurations """
3509 if sw_if_index is None:
Neale Ranns947ea622018-06-07 23:48:20 -07003510 sw_if_index = 0xffffffff
3511 return self.api(self.papi.igmp_dump,
3512 {'sw_if_index': sw_if_index})
Jakub Grajciar7b867a82017-12-08 16:28:42 +01003513
3514 def igmp_clear_interface(self, sw_if_index):
3515 """ Remove all (S,G)s from specified interface
3516 doesn't send IGMP report!
3517 """
3518 return self.api(
3519 self.papi.igmp_clear_interface, {
3520 'sw_if_index': sw_if_index})
3521
3522 def want_igmp_events(self, enable=1):
3523 return self.api(self.papi.want_igmp_events, {'enable': enable,
3524 'pid': os.getpid()})
Steven9cd2d7a2017-12-20 12:43:01 -08003525
3526 def bond_create(
3527 self,
3528 mode,
3529 lb,
3530 use_custom_mac,
3531 mac_address=''):
3532 """
3533 :param mode: mode
3534 :param lb: load balance
3535 :param use_custom_mac: use custom mac
3536 :param mac_address: mac address
3537 """
3538 return self.api(
3539 self.papi.bond_create,
3540 {'mode': mode,
3541 'lb': lb,
3542 'use_custom_mac': use_custom_mac,
3543 'mac_address': mac_address
3544 })
3545
3546 def bond_delete(
3547 self,
3548 sw_if_index):
3549 """
3550 :param sw_if_index: interface the operation is applied to
3551 """
3552 return self.api(self.papi.bond_delete,
3553 {'sw_if_index': sw_if_index})
3554
3555 def bond_enslave(
3556 self,
3557 sw_if_index,
3558 bond_sw_if_index,
3559 is_passive,
3560 is_long_timeout):
3561 """
3562 :param sw_if_index: slave sw_if_index
3563 :param bond_sw_if_index: bond sw_if_index
3564 :param is_passive: is passive lacp speaker
3565 :param is_long_time: 90 seconds timeout instead of 3 seconds timeout
3566 """
3567 return self.api(
3568 self.papi.bond_enslave,
3569 {'sw_if_index': sw_if_index,
3570 'bond_sw_if_index': bond_sw_if_index,
3571 'is_passive': is_passive,
3572 'is_long_timeout': is_long_timeout
3573 })
3574
3575 def bond_detach_slave(
3576 self,
3577 sw_if_index):
3578 """
3579 :param sw_if_index: slave interface the operation is applied to
3580 """
3581 return self.api(self.papi.bond_detach_slave,
3582 {'sw_if_index': sw_if_index})
3583
3584 def sw_interface_slave_dump(
3585 self,
3586 sw_if_index):
3587 """
3588 :param sw_if_index: bond sw_if_index
3589 """
3590 return self.api(self.papi.sw_interface_slave_dump,
3591 {'sw_if_index': sw_if_index})
3592
3593 def sw_interface_bond_dump(
3594 self):
3595 """
3596
3597 """
3598 return self.api(self.papi.sw_interface_bond_dump,
3599 {})
Stevene8fa6202017-08-30 14:36:45 -07003600
3601 def create_vhost_user_if(
3602 self,
3603 is_server,
3604 sock_filename,
3605 renumber,
3606 custom_dev_instance,
3607 use_custom_mac,
3608 mac_address,
3609 tag=''):
3610 """
3611 :param is_server: is server
3612 :param sock_filename: socket name
3613 :param renumber: renumber
3614 :param custom_dev_instance: custom dev instance
3615 :param use_custom_mac: use custom mac
3616 :param mac_address: mac address
3617 :param tag: tag (default ''
3618 """
3619 return self.api(
3620 self.papi.create_vhost_user_if,
3621 {'is_server': is_server,
3622 'sock_filename': sock_filename,
3623 'renumber': renumber,
3624 'custom_dev_instance': custom_dev_instance,
3625 'use_custom_mac': use_custom_mac,
3626 'mac_address': mac_address,
3627 'tag': tag
3628 })
3629
3630 def delete_vhost_user_if(
3631 self,
3632 sw_if_index):
3633 """
3634 :param sw_if_index: interface the operation is applied to
3635 """
3636 return self.api(self.papi.delete_vhost_user_if,
3637 {'sw_if_index': sw_if_index, })
3638
3639 def sw_interface_vhost_user_dump(
3640 self):
3641 """
3642
3643 """
3644 return self.api(self.papi.sw_interface_vhost_user_dump,
3645 {})
Andrew Yourtchenko669d07d2017-11-17 14:38:18 +01003646
3647 def abf_policy_add_del(self, is_add, policy):
3648 return self.api(
3649 self.papi.abf_policy_add_del,
3650 {'is_add': is_add,
3651 'policy': policy})
3652
3653 def abf_itf_attach_add_del(self, is_add, attach):
3654 return self.api(
3655 self.papi.abf_itf_attach_add_del,
3656 {'is_add': is_add,
3657 'attach': attach})
3658
3659 def abf_policy_dump(self):
3660 return self.api(
3661 self.papi.abf_policy_dump, {})
3662
3663 def abf_itf_attach_dump(self):
3664 return self.api(
3665 self.papi.abf_itf_attach_dump, {})
Neale Ranns17ff3c12018-07-04 10:24:24 -07003666
3667 def pipe_create(self, is_specified, user_instance):
3668 return self.api(self.papi.pipe_create,
3669 {'is_specified': is_specified,
3670 'user_instance': user_instance})
3671
3672 def pipe_delete(self, parent_sw_if_index):
3673 return self.api(self.papi.pipe_delete,
3674 {'parent_sw_if_index': parent_sw_if_index})
3675
3676 def pipe_dump(self):
3677 return self.api(self.papi.pipe_dump, {})