Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1 | import os |
| 2 | import fnmatch |
| 3 | import time |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 4 | from hook import Hook |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 5 | from collections import deque |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 6 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 7 | # Sphinx creates auto-generated documentation by importing the python source |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 8 | # 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 Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 11 | do_import = True |
| 12 | try: |
| 13 | no_vpp_papi = os.getenv("NO_VPP_PAPI") |
| 14 | if no_vpp_papi == "1": |
| 15 | do_import = False |
| 16 | except: |
| 17 | pass |
| 18 | |
| 19 | if do_import: |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 20 | from vpp_papi import VPP |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 21 | from vpp_l2 import L2_PORT_TYPE |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 22 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 23 | # from vnet/vnet/mpls/mpls_types.h |
| 24 | MPLS_IETF_MAX_LABEL = 0xfffff |
| 25 | MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1 |
| 26 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 27 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 28 | class L2_VTR_OP: |
Eyal Bari | 284293a | 2017-06-06 14:18:55 +0300 | [diff] [blame] | 29 | L2_DISABLED = 0 |
| 30 | L2_PUSH_1 = 1 |
| 31 | L2_PUSH_2 = 2 |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 32 | L2_POP_1 = 3 |
Eyal Bari | 284293a | 2017-06-06 14:18:55 +0300 | [diff] [blame] | 33 | L2_POP_2 = 4 |
| 34 | L2_TRANSLATE_1_1 = 5 |
| 35 | L2_TRANSLATE_1_2 = 6 |
| 36 | L2_TRANSLATE_2_1 = 7 |
| 37 | L2_TRANSLATE_2_2 = 8 |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 38 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 39 | |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 40 | class QOS_SOURCE: |
| 41 | EXT = 0 |
| 42 | VLAN = 1 |
| 43 | MPLS = 2 |
| 44 | IP = 3 |
| 45 | |
| 46 | |
Klement Sekera | 7388448 | 2017-02-23 09:26:30 +0100 | [diff] [blame] | 47 | class UnexpectedApiReturnValueError(Exception): |
| 48 | """ exception raised when the API return value is unexpected """ |
| 49 | pass |
| 50 | |
| 51 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 52 | class VppPapiProvider(object): |
| 53 | """VPP-api provider using vpp-papi |
| 54 | |
| 55 | @property hook: hook object providing before and after api/cli hooks |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 56 | """ |
| 57 | |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 58 | _zero, _negative = range(2) |
| 59 | |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 60 | def __init__(self, name, shm_prefix, test_class, read_timeout): |
Klement Sekera | 277b89c | 2016-10-28 13:20:27 +0200 | [diff] [blame] | 61 | self.hook = Hook("vpp-papi-provider") |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 62 | self.name = name |
| 63 | self.shm_prefix = shm_prefix |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 64 | self.test_class = test_class |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 65 | self._expect_api_retval = self._zero |
| 66 | self._expect_stack = [] |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 67 | jsonfiles = [] |
| 68 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 69 | install_dir = os.getenv('VPP_TEST_INSTALL_PATH') |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 70 | for root, dirnames, filenames in os.walk(install_dir): |
| 71 | for filename in fnmatch.filter(filenames, '*.api.json'): |
| 72 | jsonfiles.append(os.path.join(root, filename)) |
| 73 | |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 74 | self.vpp = VPP(jsonfiles, logger=test_class.logger, |
| 75 | read_timeout=read_timeout) |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 76 | self._events = deque() |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 77 | |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 78 | def __enter__(self): |
| 79 | return self |
| 80 | |
Klement Sekera | 7d6afb3 | 2018-11-08 11:52:04 +0100 | [diff] [blame] | 81 | def assert_negative_api_retval(self): |
| 82 | """ Expect API failure - used with with, e.g.: |
| 83 | with self.vapi.assert_negative_api_retval(): |
| 84 | self.vapi.<api call expected to fail> |
| 85 | """ |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 86 | self._expect_stack.append(self._expect_api_retval) |
| 87 | self._expect_api_retval = self._negative |
| 88 | return self |
| 89 | |
Klement Sekera | 7d6afb3 | 2018-11-08 11:52:04 +0100 | [diff] [blame] | 90 | def assert_zero_api_retval(self): |
| 91 | """ Expect API success - used with with, e.g.: |
| 92 | with self.vapi.assert_negative_api_retval(): |
| 93 | self.vapi.<api call expected to succeed> |
| 94 | |
| 95 | note: this is useful only inside another with block |
| 96 | as success is the default expected value |
| 97 | """ |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 98 | self._expect_stack.append(self._expect_api_retval) |
| 99 | self._expect_api_retval = self._zero |
| 100 | return self |
| 101 | |
| 102 | def __exit__(self, exc_type, exc_value, traceback): |
| 103 | self._expect_api_retval = self._expect_stack.pop() |
| 104 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 105 | def register_hook(self, hook): |
| 106 | """Replace hook registration with new hook |
| 107 | |
| 108 | :param hook: |
| 109 | |
| 110 | """ |
| 111 | self.hook = hook |
| 112 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 113 | def collect_events(self): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 114 | """ Collect all events from the internal queue and clear the queue. """ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 115 | e = self._events |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 116 | self._events = deque() |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 117 | return e |
| 118 | |
| 119 | def wait_for_event(self, timeout, name=None): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 120 | """ Wait for and return next event. """ |
Klement Sekera | acb9b8e | 2017-02-14 02:55:31 +0100 | [diff] [blame] | 121 | if name: |
Klement Sekera | acb9b8e | 2017-02-14 02:55:31 +0100 | [diff] [blame] | 122 | self.test_class.logger.debug("Expecting event '%s' within %ss", |
| 123 | name, timeout) |
Eyal Bari | 2019748 | 2017-09-13 12:29:08 +0300 | [diff] [blame] | 124 | else: |
| 125 | self.test_class.logger.debug("Expecting event within %ss", |
| 126 | timeout) |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 127 | if self._events: |
| 128 | self.test_class.logger.debug("Not waiting, event already queued") |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 129 | limit = time.time() + timeout |
| 130 | while time.time() < limit: |
| 131 | if self._events: |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 132 | e = self._events.popleft() |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 133 | if name and type(e).__name__ != name: |
| 134 | raise Exception( |
| 135 | "Unexpected event received: %s, expected: %s" % |
| 136 | (type(e).__name__, name)) |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 137 | self.test_class.logger.debug("Returning event %s:%s" % |
| 138 | (name, e)) |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 139 | return e |
| 140 | time.sleep(0) # yield |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 141 | raise Exception("Event did not occur within timeout") |
| 142 | |
| 143 | def __call__(self, name, event): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 144 | """ Enqueue event in the internal event queue. """ |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 145 | # FIXME use the name instead of relying on type(e).__name__ ? |
| 146 | # FIXME #2 if this throws, it is eaten silently, Ole? |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 147 | self.test_class.logger.debug("New event: %s: %s" % (name, event)) |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 148 | self._events.append(event) |
| 149 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 150 | def connect(self): |
| 151 | """Connect the API to VPP""" |
Klement Sekera | 7112c54 | 2017-03-01 09:53:19 +0100 | [diff] [blame] | 152 | self.vpp.connect(self.name, self.shm_prefix) |
| 153 | self.papi = self.vpp.api |
| 154 | self.vpp.register_event_callback(self) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 155 | |
| 156 | def disconnect(self): |
| 157 | """Disconnect the API from VPP""" |
Klement Sekera | 7112c54 | 2017-03-01 09:53:19 +0100 | [diff] [blame] | 158 | self.vpp.disconnect() |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 159 | |
| 160 | def api(self, api_fn, api_args, expected_retval=0): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 161 | """ Call API function and check it's return value. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 162 | Call the appropriate hooks before and after the API call |
| 163 | |
| 164 | :param api_fn: API function to call |
| 165 | :param api_args: tuple of API function arguments |
| 166 | :param expected_retval: Expected return value (Default value = 0) |
| 167 | :returns: reply from the API |
| 168 | |
| 169 | """ |
| 170 | self.hook.before_api(api_fn.__name__, api_args) |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 171 | reply = api_fn(**api_args) |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 172 | if self._expect_api_retval == self._negative: |
| 173 | if hasattr(reply, 'retval') and reply.retval >= 0: |
| 174 | msg = "API call passed unexpectedly: expected negative "\ |
| 175 | "return value instead of %d in %s" % \ |
| 176 | (reply.retval, repr(reply)) |
| 177 | self.test_class.logger.info(msg) |
Klement Sekera | 7388448 | 2017-02-23 09:26:30 +0100 | [diff] [blame] | 178 | raise UnexpectedApiReturnValueError(msg) |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 179 | elif self._expect_api_retval == self._zero: |
| 180 | if hasattr(reply, 'retval') and reply.retval != expected_retval: |
Neale Ranns | 88fc83e | 2017-04-05 08:11:14 -0700 | [diff] [blame] | 181 | msg = "API call failed, expected %d return value instead "\ |
| 182 | "of %d in %s" % (expected_retval, reply.retval, |
| 183 | repr(reply)) |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 184 | self.test_class.logger.info(msg) |
Klement Sekera | 7388448 | 2017-02-23 09:26:30 +0100 | [diff] [blame] | 185 | raise UnexpectedApiReturnValueError(msg) |
Klement Sekera | e0545ef | 2017-01-25 08:00:40 +0100 | [diff] [blame] | 186 | else: |
| 187 | raise Exception("Internal error, unexpected value for " |
| 188 | "self._expect_api_retval %s" % |
| 189 | self._expect_api_retval) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 190 | self.hook.after_api(api_fn.__name__, api_args) |
| 191 | return reply |
| 192 | |
| 193 | def cli(self, cli): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 194 | """ Execute a CLI, calling the before/after hooks appropriately. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 195 | |
| 196 | :param cli: CLI to execute |
| 197 | :returns: CLI output |
| 198 | |
| 199 | """ |
| 200 | self.hook.before_cli(cli) |
| 201 | cli += '\n' |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 202 | r = self.papi.cli_inband(length=len(cli), cmd=cli) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 203 | self.hook.after_cli(cli) |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 204 | if hasattr(r, 'reply'): |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 205 | return r.reply.decode().rstrip('\x00') |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 206 | |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 207 | def ppcli(self, cli): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 208 | """ Helper method to print CLI command in case of info logging level. |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 209 | |
| 210 | :param cli: CLI to execute |
| 211 | :returns: CLI output |
| 212 | """ |
Ed Warnicke | b8ff5d6 | 2016-11-28 13:59:22 -0600 | [diff] [blame] | 213 | return cli + "\n" + str(self.cli(cli)) |
Jan | 49c0fca | 2016-10-26 15:44:27 +0200 | [diff] [blame] | 214 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 215 | def _convert_mac(self, mac): |
Mohsin Kazmi | 57938f6 | 2017-10-27 21:28:07 +0200 | [diff] [blame] | 216 | return mac.replace(':', '').decode('hex') |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 217 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 218 | def show_version(self): |
| 219 | """ """ |
Klement Sekera | 7112c54 | 2017-03-01 09:53:19 +0100 | [diff] [blame] | 220 | return self.api(self.papi.show_version, {}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 221 | |
| 222 | def pg_create_interface(self, pg_index): |
| 223 | """ |
| 224 | |
| 225 | :param pg_index: |
| 226 | |
| 227 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 228 | return self.api(self.papi.pg_create_interface, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 229 | {"interface_id": pg_index}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 230 | |
| 231 | def sw_interface_dump(self, filter=None): |
| 232 | """ |
| 233 | |
| 234 | :param filter: (Default value = None) |
| 235 | |
| 236 | """ |
| 237 | if filter is not None: |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 238 | args = {"name_filter_valid": 1, "name_filter": filter} |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 239 | else: |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 240 | args = {} |
| 241 | return self.api(self.papi.sw_interface_dump, args) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 242 | |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 243 | def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id): |
Klement Sekera | e4504c6 | 2016-12-08 10:16:41 +0100 | [diff] [blame] | 244 | """ Set the IPvX Table-id for the Interface |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 245 | |
| 246 | :param sw_if_index: |
| 247 | :param is_ipv6: |
| 248 | :param table_id: |
| 249 | |
| 250 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 251 | return self.api(self.papi.sw_interface_set_table, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 252 | {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6, |
| 253 | 'vrf_id': table_id}) |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 254 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 255 | def sw_interface_get_table(self, sw_if_index, is_ipv6): |
| 256 | """ Get the IPvX Table-id for the Interface |
| 257 | |
| 258 | :param sw_if_index: |
| 259 | :param is_ipv6: |
| 260 | :return table_id |
| 261 | |
| 262 | """ |
| 263 | return self.api(self.papi.sw_interface_get_table, |
| 264 | {'sw_if_index': sw_if_index, 'is_ipv6': is_ipv6}) |
| 265 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 266 | def sw_interface_add_del_address(self, sw_if_index, addr, addr_len, |
| 267 | is_ipv6=0, is_add=1, del_all=0): |
| 268 | """ |
| 269 | |
| 270 | :param addr: param is_ipv6: (Default value = 0) |
| 271 | :param sw_if_index: |
| 272 | :param addr_len: |
| 273 | :param is_ipv6: (Default value = 0) |
| 274 | :param is_add: (Default value = 1) |
| 275 | :param del_all: (Default value = 0) |
| 276 | |
| 277 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 278 | return self.api(self.papi.sw_interface_add_del_address, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 279 | {'sw_if_index': sw_if_index, |
| 280 | 'is_add': is_add, |
| 281 | 'is_ipv6': is_ipv6, |
| 282 | 'del_all': del_all, |
| 283 | 'address_length': addr_len, |
| 284 | 'address': addr}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 285 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 286 | def ip_address_dump(self, sw_if_index, is_ipv6=0): |
| 287 | return self.api(self.papi.ip_address_dump, |
| 288 | {'sw_if_index': sw_if_index, |
| 289 | 'is_ipv6': is_ipv6}) |
| 290 | |
Neale Ranns | 39f9d8b | 2017-02-16 21:57:05 -0800 | [diff] [blame] | 291 | def sw_interface_set_unnumbered(self, sw_if_index, ip_sw_if_index, |
| 292 | is_add=1): |
| 293 | """ Set the Interface to be unnumbered |
| 294 | |
| 295 | :param is_add: (Default value = 1) |
| 296 | :param sw_if_index - interface That will be unnumbered |
| 297 | :param ip_sw_if_index - interface with an IP addres |
| 298 | |
| 299 | """ |
| 300 | return self.api(self.papi.sw_interface_set_unnumbered, |
| 301 | {'sw_if_index': ip_sw_if_index, |
| 302 | 'unnumbered_sw_if_index': sw_if_index, |
| 303 | 'is_add': is_add}) |
| 304 | |
Neale Ranns | 404d88e | 2018-08-08 06:37:33 -0700 | [diff] [blame] | 305 | def ip_unnumbered_dump(self, sw_if_index=0xffffffff): |
| 306 | return self.api(self.papi.ip_unnumbered_dump, |
| 307 | {'sw_if_index': sw_if_index}) |
| 308 | |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 309 | def sw_interface_enable_disable_mpls(self, sw_if_index, |
| 310 | is_enable=1): |
| 311 | """ |
| 312 | Enable/Disable MPLS on the interface |
| 313 | :param sw_if_index: |
| 314 | :param is_enable: (Default value = 1) |
| 315 | |
| 316 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 317 | return self.api(self.papi.sw_interface_set_mpls_enable, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 318 | {'sw_if_index': sw_if_index, |
| 319 | 'enable': is_enable}) |
Neale Ranns | 8fe8cc2 | 2016-11-01 10:05:08 +0000 | [diff] [blame] | 320 | |
Jan Gelety | 057bb8c | 2016-12-20 17:32:45 +0100 | [diff] [blame] | 321 | def sw_interface_ra_suppress(self, sw_if_index, suppress=1): |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 322 | return self.api(self.papi.sw_interface_ip6nd_ra_config, |
Jan Gelety | 057bb8c | 2016-12-20 17:32:45 +0100 | [diff] [blame] | 323 | {'sw_if_index': sw_if_index, |
| 324 | 'suppress': suppress}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 325 | |
Neale Ranns | 227038a | 2017-04-21 01:07:59 -0700 | [diff] [blame] | 326 | def set_ip_flow_hash(self, |
| 327 | table_id, |
| 328 | src=1, |
| 329 | dst=1, |
| 330 | sport=1, |
| 331 | dport=1, |
| 332 | proto=1, |
| 333 | reverse=0, |
| 334 | is_ip6=0): |
| 335 | return self.api(self.papi.set_ip_flow_hash, |
| 336 | {'vrf_id': table_id, |
| 337 | 'src': src, |
| 338 | 'dst': dst, |
| 339 | 'dport': dport, |
| 340 | 'sport': sport, |
| 341 | 'proto': proto, |
| 342 | 'reverse': reverse, |
| 343 | 'is_ipv6': is_ip6}) |
| 344 | |
Neale Ranns | 3f844d0 | 2017-02-18 00:03:54 -0800 | [diff] [blame] | 345 | def ip6_nd_proxy(self, address, sw_if_index, is_del=0): |
| 346 | return self.api(self.papi.ip6nd_proxy_add_del, |
| 347 | {'address': address, |
| 348 | 'sw_if_index': sw_if_index, |
| 349 | 'is_del': is_del}) |
| 350 | |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 351 | def ip6_sw_interface_ra_config(self, sw_if_index, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 352 | no, |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 353 | suppress, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 354 | send_unicast): |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 355 | return self.api(self.papi.sw_interface_ip6nd_ra_config, |
| 356 | {'sw_if_index': sw_if_index, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 357 | 'is_no': no, |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 358 | 'suppress': suppress, |
| 359 | 'send_unicast': send_unicast}) |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 360 | |
Neale Ranns | 87df12d | 2017-02-18 08:16:41 -0800 | [diff] [blame] | 361 | def ip6_sw_interface_ra_prefix(self, |
| 362 | sw_if_index, |
| 363 | address, |
| 364 | address_length, |
| 365 | use_default=0, |
| 366 | no_advertise=0, |
| 367 | off_link=0, |
| 368 | no_autoconfig=0, |
| 369 | no_onlink=0, |
| 370 | is_no=0, |
| 371 | val_lifetime=0xffffffff, |
| 372 | pref_lifetime=0xffffffff): |
| 373 | return self.api(self.papi.sw_interface_ip6nd_ra_prefix, |
| 374 | {'sw_if_index': sw_if_index, |
| 375 | 'address': address, |
| 376 | 'address_length': address_length, |
| 377 | 'use_default': use_default, |
| 378 | 'no_advertise': no_advertise, |
| 379 | 'off_link': off_link, |
| 380 | 'no_autoconfig': no_autoconfig, |
| 381 | 'no_onlink': no_onlink, |
| 382 | 'is_no': is_no, |
| 383 | 'val_lifetime': val_lifetime, |
| 384 | 'pref_lifetime': pref_lifetime}) |
| 385 | |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 386 | def ip6_sw_interface_enable_disable(self, sw_if_index, enable): |
| 387 | """ |
| 388 | Enable/Disable An interface for IPv6 |
| 389 | """ |
| 390 | return self.api(self.papi.sw_interface_ip6_enable_disable, |
| 391 | {'sw_if_index': sw_if_index, |
| 392 | 'enable': enable}) |
| 393 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 394 | def vxlan_add_del_tunnel( |
| 395 | self, |
| 396 | src_addr, |
| 397 | dst_addr, |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 398 | mcast_sw_if_index=0xFFFFFFFF, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 399 | is_add=1, |
| 400 | is_ipv6=0, |
| 401 | encap_vrf_id=0, |
| 402 | decap_next_index=0xFFFFFFFF, |
Jon Loeliger | 3d460bd | 2018-02-01 16:36:12 -0600 | [diff] [blame] | 403 | vni=0, |
| 404 | instance=0xFFFFFFFF): |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 405 | """ |
| 406 | |
| 407 | :param dst_addr: |
| 408 | :param src_addr: |
| 409 | :param is_add: (Default value = 1) |
| 410 | :param is_ipv6: (Default value = 0) |
| 411 | :param encap_vrf_id: (Default value = 0) |
| 412 | :param decap_next_index: (Default value = 0xFFFFFFFF) |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 413 | :param mcast_sw_if_index: (Default value = 0xFFFFFFFF) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 414 | :param vni: (Default value = 0) |
Jon Loeliger | 3d460bd | 2018-02-01 16:36:12 -0600 | [diff] [blame] | 415 | :param instance: (Default value = 0xFFFFFFFF) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 416 | |
| 417 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 418 | return self.api(self.papi.vxlan_add_del_tunnel, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 419 | {'is_add': is_add, |
| 420 | 'is_ipv6': is_ipv6, |
| 421 | 'src_address': src_addr, |
| 422 | 'dst_address': dst_addr, |
| 423 | 'mcast_sw_if_index': mcast_sw_if_index, |
| 424 | 'encap_vrf_id': encap_vrf_id, |
| 425 | 'decap_next_index': decap_next_index, |
Jon Loeliger | 3d460bd | 2018-02-01 16:36:12 -0600 | [diff] [blame] | 426 | 'vni': vni, |
| 427 | 'instance': instance}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 428 | |
Marco Varlese | b598f1d | 2017-09-19 14:25:28 +0200 | [diff] [blame] | 429 | def geneve_add_del_tunnel( |
| 430 | self, |
| 431 | local_addr, |
| 432 | remote_addr, |
| 433 | mcast_sw_if_index=0xFFFFFFFF, |
| 434 | is_add=1, |
| 435 | is_ipv6=0, |
| 436 | encap_vrf_id=0, |
| 437 | decap_next_index=0xFFFFFFFF, |
| 438 | vni=0): |
| 439 | """ |
| 440 | |
| 441 | :param remote_addr: |
| 442 | :param local_addr: |
| 443 | :param is_add: (Default value = 1) |
| 444 | :param is_ipv6: (Default value = 0) |
| 445 | :param encap_vrf_id: (Default value = 0) |
| 446 | :param decap_next_index: (Default value = 0xFFFFFFFF) |
| 447 | :param mcast_sw_if_index: (Default value = 0xFFFFFFFF) |
| 448 | :param vni: (Default value = 0) |
| 449 | |
| 450 | """ |
| 451 | return self.api(self.papi.geneve_add_del_tunnel, |
| 452 | {'is_add': is_add, |
| 453 | 'is_ipv6': is_ipv6, |
| 454 | 'local_address': local_addr, |
| 455 | 'remote_address': remote_addr, |
| 456 | 'mcast_sw_if_index': mcast_sw_if_index, |
| 457 | 'encap_vrf_id': encap_vrf_id, |
| 458 | 'decap_next_index': decap_next_index, |
| 459 | 'vni': vni}) |
| 460 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 461 | def bridge_domain_add_del(self, bd_id, flood=1, uu_flood=1, forward=1, |
| 462 | learn=1, arp_term=0, is_add=1): |
| 463 | """Create/delete bridge domain. |
| 464 | |
| 465 | :param int bd_id: Bridge domain index. |
| 466 | :param int flood: Enable/disable bcast/mcast flooding in the BD. |
| 467 | (Default value = 1) |
| 468 | :param int uu_flood: Enable/disable unknown unicast flood in the BD. |
| 469 | (Default value = 1) |
| 470 | :param int forward: Enable/disable forwarding on all interfaces in |
| 471 | the BD. (Default value = 1) |
| 472 | :param int learn: Enable/disable learning on all interfaces in the BD. |
| 473 | (Default value = 1) |
| 474 | :param int arp_term: Enable/disable arp termination in the BD. |
| 475 | (Default value = 1) |
| 476 | :param int is_add: Add or delete flag. (Default value = 1) |
| 477 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 478 | return self.api(self.papi.bridge_domain_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 479 | {'bd_id': bd_id, |
| 480 | 'flood': flood, |
| 481 | 'uu_flood': uu_flood, |
| 482 | 'forward': forward, |
| 483 | 'learn': learn, |
| 484 | 'arp_term': arp_term, |
| 485 | 'is_add': is_add}) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 486 | |
Eyal Bari | c86e592 | 2017-07-02 18:33:16 +0300 | [diff] [blame] | 487 | def bd_ip_mac_add_del(self, bd_id, mac, ip, is_ipv6=0, is_add=1): |
| 488 | return self.api(self.papi.bd_ip_mac_add_del, |
| 489 | {'bd_id': bd_id, |
| 490 | 'is_add': is_add, |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 491 | 'ip': ip, |
| 492 | 'mac': mac}) |
Eyal Bari | c86e592 | 2017-07-02 18:33:16 +0300 | [diff] [blame] | 493 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 494 | def bd_ip_mac_dump(self, bd_id): |
| 495 | return self.api(self.papi.bd_ip_mac_dump, |
| 496 | {'bd_id': bd_id}) |
| 497 | |
Eyal Bari | 2019748 | 2017-09-13 12:29:08 +0300 | [diff] [blame] | 498 | def want_ip4_arp_events(self, enable_disable=1, address=0): |
| 499 | return self.api(self.papi.want_ip4_arp_events, |
| 500 | {'enable_disable': enable_disable, |
| 501 | 'address': address, |
| 502 | 'pid': os.getpid(), }) |
| 503 | |
Eyal Bari | c125ecc | 2017-09-20 11:29:17 +0300 | [diff] [blame] | 504 | def want_ip6_nd_events(self, enable_disable=1, address=0): |
| 505 | return self.api(self.papi.want_ip6_nd_events, |
| 506 | {'enable_disable': enable_disable, |
| 507 | 'address': address, |
| 508 | 'pid': os.getpid(), }) |
| 509 | |
Juraj Sloboda | 4b9669d | 2018-01-15 10:39:21 +0100 | [diff] [blame] | 510 | def want_ip6_ra_events(self, enable_disable=1): |
| 511 | return self.api(self.papi.want_ip6_ra_events, |
| 512 | {'enable_disable': enable_disable, |
| 513 | 'pid': os.getpid(), }) |
| 514 | |
| 515 | def ip6nd_send_router_solicitation(self, sw_if_index, irt=1, mrt=120, |
| 516 | mrc=0, mrd=0): |
| 517 | return self.api(self.papi.ip6nd_send_router_solicitation, |
| 518 | {'irt': irt, |
| 519 | 'mrt': mrt, |
| 520 | 'mrc': mrc, |
| 521 | 'mrd': mrd, |
| 522 | 'sw_if_index': sw_if_index}) |
| 523 | |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 524 | def ip6_nd_address_autoconfig(self, sw_if_index, enable, |
| 525 | install_default_routes): |
| 526 | return self.api(self.papi.ip6_nd_address_autoconfig, |
| 527 | {'sw_if_index': sw_if_index, |
| 528 | 'enable': enable, |
| 529 | 'install_default_routes': install_default_routes}) |
| 530 | |
Juraj Sloboda | b3f9050 | 2018-10-04 15:15:16 +0200 | [diff] [blame] | 531 | def want_interface_events(self, enable_disable=1): |
| 532 | return self.api(self.papi.want_interface_events, |
| 533 | {'enable_disable': enable_disable, |
| 534 | 'pid': os.getpid(), }) |
| 535 | |
Eyal Bari | 24db0ec | 2017-09-27 21:43:51 +0300 | [diff] [blame] | 536 | def want_macs_learn_events(self, enable_disable=1, scan_delay=0, |
| 537 | max_macs_in_event=0, learn_limit=0): |
| 538 | return self.api(self.papi.want_l2_macs_events, |
| 539 | {'enable_disable': enable_disable, |
| 540 | 'scan_delay': scan_delay, |
| 541 | 'max_macs_in_event': max_macs_in_event, |
| 542 | 'learn_limit': learn_limit, |
| 543 | 'pid': os.getpid(), }) |
| 544 | |
Juraj Sloboda | dd3b8f7 | 2018-05-04 14:20:06 +0200 | [diff] [blame] | 545 | def want_dhcp6_reply_events(self, enable_disable=1): |
| 546 | return self.api(self.papi.want_dhcp6_reply_events, |
| 547 | {'enable_disable': enable_disable, |
| 548 | 'pid': os.getpid()}) |
| 549 | |
Juraj Sloboda | 81119e8 | 2018-05-25 14:02:20 +0200 | [diff] [blame] | 550 | def want_dhcp6_pd_reply_events(self, enable_disable=1): |
| 551 | return self.api(self.papi.want_dhcp6_pd_reply_events, |
| 552 | {'enable_disable': enable_disable, |
| 553 | 'pid': os.getpid()}) |
| 554 | |
| 555 | def dhcp6_clients_enable_disable(self, enable=1): |
| 556 | return self.api(self.papi.dhcp6_clients_enable_disable, |
| 557 | {'enable': enable}) |
| 558 | |
Juraj Sloboda | dd3b8f7 | 2018-05-04 14:20:06 +0200 | [diff] [blame] | 559 | def dhcp6_send_client_message(self, msg_type, sw_if_index, T1, T2, |
| 560 | addresses, server_index=0xFFFFFFFF, |
| 561 | irt=0, mrt=0, mrc=1, mrd=0, stop=0, |
| 562 | ): |
| 563 | return self.api(self.papi.dhcp6_send_client_message, |
| 564 | {'sw_if_index': sw_if_index, |
| 565 | 'server_index': server_index, |
| 566 | 'irt': irt, |
| 567 | 'mrt': mrt, |
| 568 | 'mrc': mrc, |
| 569 | 'mrd': mrd, |
| 570 | 'stop': stop, |
| 571 | 'msg_type': msg_type, |
| 572 | 'T1': T1, |
| 573 | 'T2': T2, |
| 574 | 'n_addresses': len(addresses), |
| 575 | 'addresses': addresses}) |
| 576 | |
Juraj Sloboda | 81119e8 | 2018-05-25 14:02:20 +0200 | [diff] [blame] | 577 | def dhcp6_pd_send_client_message(self, msg_type, sw_if_index, T1, T2, |
| 578 | prefixes, server_index=0xFFFFFFFF, |
| 579 | irt=0, mrt=0, mrc=1, mrd=0, stop=0, |
| 580 | ): |
| 581 | return self.api(self.papi.dhcp6_pd_send_client_message, |
| 582 | {'sw_if_index': sw_if_index, |
| 583 | 'server_index': server_index, |
| 584 | 'irt': irt, |
| 585 | 'mrt': mrt, |
| 586 | 'mrc': mrc, |
| 587 | 'mrd': mrd, |
| 588 | 'stop': stop, |
| 589 | 'msg_type': msg_type, |
| 590 | 'T1': T1, |
| 591 | 'T2': T2, |
| 592 | 'n_prefixes': len(prefixes), |
| 593 | 'prefixes': prefixes}) |
| 594 | |
Juraj Sloboda | dd3b8f7 | 2018-05-04 14:20:06 +0200 | [diff] [blame] | 595 | def dhcp6_client_enable_disable(self, sw_if_index, prefix_group='', |
| 596 | enable=1): |
| 597 | return self.api(self.papi.dhcp6_client_enable_disable, |
| 598 | {'sw_if_index': sw_if_index, |
| 599 | 'enable': enable}) |
| 600 | |
Juraj Sloboda | 81119e8 | 2018-05-25 14:02:20 +0200 | [diff] [blame] | 601 | def dhcp6_pd_client_enable_disable(self, sw_if_index, prefix_group='', |
| 602 | enable=1): |
| 603 | return self.api(self.papi.dhcp6_pd_client_enable_disable, |
| 604 | {'sw_if_index': sw_if_index, |
| 605 | 'prefix_group': prefix_group, |
| 606 | 'enable': enable}) |
| 607 | |
| 608 | def ip6_add_del_address_using_prefix(self, sw_if_index, address, |
| 609 | prefix_length, prefix_group, |
| 610 | is_add=1): |
| 611 | return self.api(self.papi.ip6_add_del_address_using_prefix, |
| 612 | {'sw_if_index': sw_if_index, |
| 613 | 'prefix_group': prefix_group, |
| 614 | 'address': address, |
| 615 | 'prefix_length': prefix_length, |
| 616 | 'is_add': is_add}) |
| 617 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 618 | def l2fib_add_del(self, mac, bd_id, sw_if_index, is_add=1, static_mac=0, |
| 619 | filter_mac=0, bvi_mac=0): |
| 620 | """Create/delete L2 FIB entry. |
| 621 | |
| 622 | :param str mac: MAC address to create FIB entry for. |
| 623 | :param int bd_id: Bridge domain index. |
| 624 | :param int sw_if_index: Software interface index of the interface. |
| 625 | :param int is_add: Add or delete flag. (Default value = 1) |
| 626 | :param int static_mac: Set to 1 to create static MAC entry. |
| 627 | (Default value = 0) |
| 628 | :param int filter_mac: Set to 1 to drop packet that's source or |
| 629 | destination MAC address contains defined MAC address. |
| 630 | (Default value = 0) |
| 631 | :param int bvi_mac: Set to 1 to create entry that points to BVI |
| 632 | interface. (Default value = 0) |
| 633 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 634 | return self.api(self.papi.l2fib_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 635 | {'mac': self._convert_mac(mac), |
| 636 | 'bd_id': bd_id, |
| 637 | 'sw_if_index': sw_if_index, |
| 638 | 'is_add': is_add, |
| 639 | 'static_mac': static_mac, |
| 640 | 'filter_mac': filter_mac, |
| 641 | 'bvi_mac': bvi_mac}) |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 642 | |
Eyal Bari | 93b503e | 2017-05-15 10:13:15 +0300 | [diff] [blame] | 643 | def l2fib_flush_int(self, sw_if_index): |
| 644 | """Flush L2 FIB entries for sw_if_index. |
| 645 | |
| 646 | :param int sw_if_index: Software interface index of the interface. |
| 647 | """ |
| 648 | return self.api(self.papi.l2fib_flush_int, |
| 649 | {'sw_if_index': sw_if_index}) |
| 650 | |
| 651 | def l2fib_flush_bd(self, bd_id): |
| 652 | """Flush L2 FIB entries for bd_id. |
| 653 | |
| 654 | :param int sw_if_index: Bridge Domain id. |
| 655 | """ |
| 656 | return self.api(self.papi.l2fib_flush_bd, |
| 657 | {'bd_id': bd_id}) |
| 658 | |
| 659 | def l2fib_flush_all(self): |
| 660 | """Flush all L2 FIB. |
| 661 | """ |
| 662 | return self.api(self.papi.l2fib_flush_all, {}) |
| 663 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 664 | def l2_fib_table_dump(self, bd_id): |
| 665 | """ Dump the L2 FIB """ |
| 666 | return self.api(self.papi.l2_fib_table_dump, |
| 667 | {'bd_id': bd_id}) |
| 668 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 669 | def sw_interface_set_l2_bridge(self, sw_if_index, bd_id, |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 670 | shg=0, port_type=L2_PORT_TYPE.NORMAL, |
| 671 | enable=1): |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 672 | """Add/remove interface to/from bridge domain. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 673 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 674 | :param int sw_if_index: Software interface index of the interface. |
| 675 | :param int bd_id: Bridge domain index. |
| 676 | :param int shg: Split-horizon group index. (Default value = 0) |
| 677 | :param int bvi: Set interface as a bridge group virtual interface. |
| 678 | (Default value = 0) |
| 679 | :param int enable: Add or remove interface. (Default value = 1) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 680 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 681 | return self.api(self.papi.sw_interface_set_l2_bridge, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 682 | {'rx_sw_if_index': sw_if_index, |
| 683 | 'bd_id': bd_id, |
| 684 | 'shg': shg, |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 685 | 'port_type': port_type, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 686 | 'enable': enable}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 687 | |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 688 | def bridge_flags(self, bd_id, is_set, feature_bitmap): |
Chris Luke | d042194 | 2018-04-10 15:19:54 -0400 | [diff] [blame] | 689 | """Enable/disable required feature of the bridge domain with defined |
| 690 | ID. |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 691 | |
| 692 | :param int bd_id: Bridge domain ID. |
| 693 | :param int is_set: Set to 1 to enable, set to 0 to disable the feature. |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 694 | :param int flags: Bitmap value of the feature to be set: |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 695 | - learn (1 << 0), |
| 696 | - forward (1 << 1), |
| 697 | - flood (1 << 2), |
| 698 | - uu-flood (1 << 3) or |
| 699 | - arp-term (1 << 4). |
| 700 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 701 | return self.api(self.papi.bridge_flags, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 702 | {'bd_id': bd_id, |
| 703 | 'is_set': is_set, |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 704 | 'flags': feature_bitmap}) |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 705 | |
| 706 | def bridge_domain_dump(self, bd_id=0): |
| 707 | """ |
| 708 | |
| 709 | :param int bd_id: Bridge domain ID. (Default value = 0 => dump of all |
| 710 | existing bridge domains returned) |
| 711 | :return: Dictionary of bridge domain(s) data. |
| 712 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 713 | return self.api(self.papi.bridge_domain_dump, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 714 | {'bd_id': bd_id}) |
Jan | 00dad12 | 2016-11-29 10:04:53 +0100 | [diff] [blame] | 715 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 716 | def sw_interface_set_l2_xconnect(self, rx_sw_if_index, tx_sw_if_index, |
| 717 | enable): |
| 718 | """Create or delete unidirectional cross-connect from Tx interface to |
| 719 | Rx interface. |
| 720 | |
Jan | 4af521d | 2016-11-15 17:05:00 +0100 | [diff] [blame] | 721 | :param int rx_sw_if_index: Software interface index of Rx interface. |
| 722 | :param int tx_sw_if_index: Software interface index of Tx interface. |
| 723 | :param int enable: Create cross-connect if equal to 1, delete |
| 724 | cross-connect if equal to 0. |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 725 | |
| 726 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 727 | return self.api(self.papi.sw_interface_set_l2_xconnect, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 728 | {'rx_sw_if_index': rx_sw_if_index, |
| 729 | 'tx_sw_if_index': tx_sw_if_index, |
| 730 | 'enable': enable}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 731 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 732 | def sw_interface_set_l2_tag_rewrite( |
| 733 | self, |
| 734 | sw_if_index, |
| 735 | vtr_oper, |
| 736 | push=0, |
| 737 | tag1=0, |
| 738 | tag2=0): |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 739 | """L2 interface vlan tag rewrite configure request |
| 740 | :param client_index - opaque cookie to identify the sender |
| 741 | :param context - sender context, to match reply w/ request |
| 742 | :param sw_if_index - interface the operation is applied to |
| 743 | :param vtr_op - Choose from l2_vtr_op_t enum values |
| 744 | :param push_dot1q - first pushed flag dot1q id set, else dot1ad |
| 745 | :param tag1 - Needed for any push or translate vtr op |
| 746 | :param tag2 - Needed for any push 2 or translate x-2 vtr ops |
| 747 | |
| 748 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 749 | return self.api(self.papi.l2_interface_vlan_tag_rewrite, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 750 | {'sw_if_index': sw_if_index, |
| 751 | 'vtr_op': vtr_oper, |
| 752 | 'push_dot1q': push, |
| 753 | 'tag1': tag1, |
| 754 | 'tag2': tag2}) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 755 | |
Neale Ranns | 55d0378 | 2017-10-21 06:34:22 -0700 | [diff] [blame] | 756 | def sw_interface_set_l2_emulation( |
| 757 | self, |
| 758 | sw_if_index, |
| 759 | enable=1): |
| 760 | """L2 Emulation |
| 761 | :param sw_if_index - interface the operation is applied to |
| 762 | |
| 763 | """ |
| 764 | return self.api(self.papi.l2_emulation, |
| 765 | {'sw_if_index': sw_if_index, |
| 766 | 'enable': enable}) |
| 767 | |
Neale Ranns | 1855b8e | 2018-07-11 10:31:26 -0700 | [diff] [blame] | 768 | def sw_interface_set_ip_directed_broadcast( |
| 769 | self, |
| 770 | sw_if_index, |
| 771 | enable=1): |
| 772 | """IP Directed broadcast |
| 773 | :param sw_if_index - interface the operation is applied to |
| 774 | |
| 775 | """ |
| 776 | return self.api(self.papi.sw_interface_set_ip_directed_broadcast, |
| 777 | {'sw_if_index': sw_if_index, |
| 778 | 'enable': enable}) |
| 779 | |
Neale Ranns | a07bd70 | 2017-08-07 07:53:49 -0700 | [diff] [blame] | 780 | def sw_interface_set_flags(self, sw_if_index, admin_up_down): |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 781 | """ |
| 782 | |
| 783 | :param admin_up_down: |
| 784 | :param sw_if_index: |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 785 | |
| 786 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 787 | return self.api(self.papi.sw_interface_set_flags, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 788 | {'sw_if_index': sw_if_index, |
Neale Ranns | a07bd70 | 2017-08-07 07:53:49 -0700 | [diff] [blame] | 789 | 'admin_up_down': admin_up_down}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 790 | |
Ole Troan | d723161 | 2018-06-07 10:17:57 +0200 | [diff] [blame] | 791 | def sw_interface_set_mtu(self, sw_if_index, mtu=[0, 0, 0, 0]): |
Neale Ranns | ffd78d1 | 2018-02-09 06:05:16 -0800 | [diff] [blame] | 792 | """ |
| 793 | :param sw_if_index: |
| 794 | :param mtu: |
| 795 | |
| 796 | """ |
| 797 | return self.api(self.papi.sw_interface_set_mtu, |
| 798 | {'sw_if_index': sw_if_index, |
| 799 | 'mtu': mtu}) |
| 800 | |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 801 | def sw_interface_set_promiscuous(self, sw_if_index, enable): |
| 802 | """ |
| 803 | :param sw_if_index: |
| 804 | :param enable: |
| 805 | |
| 806 | """ |
| 807 | return self.api(self.papi.sw_interface_set_promiscuous, |
| 808 | {'sw_if_index': sw_if_index, |
| 809 | 'enable': enable}) |
| 810 | |
Neale Ranns | c819fc6 | 2018-02-16 02:44:05 -0800 | [diff] [blame] | 811 | def sw_interface_set_mac_address(self, sw_if_index, mac): |
| 812 | return self.api(self.papi.sw_interface_set_mac_address, |
| 813 | {'sw_if_index': sw_if_index, |
| 814 | 'mac_address': mac}) |
| 815 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 816 | def create_subif(self, sw_if_index, sub_id, outer_vlan, inner_vlan, |
| 817 | no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0, |
| 818 | default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0): |
| 819 | """Create subinterface |
| 820 | from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad |
| 821 | |
| 822 | :param sub_id: param inner_vlan: |
| 823 | :param sw_if_index: |
| 824 | :param outer_vlan: |
| 825 | :param inner_vlan: |
| 826 | :param no_tags: (Default value = 0) |
| 827 | :param one_tag: (Default value = 0) |
| 828 | :param two_tags: (Default value = 0) |
| 829 | :param dot1ad: (Default value = 0) |
| 830 | :param exact_match: (Default value = 0) |
| 831 | :param default_sub: (Default value = 0) |
| 832 | :param outer_vlan_id_any: (Default value = 0) |
| 833 | :param inner_vlan_id_any: (Default value = 0) |
| 834 | |
| 835 | """ |
| 836 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 837 | self.papi.create_subif, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 838 | {'sw_if_index': sw_if_index, |
| 839 | 'sub_id': sub_id, |
| 840 | 'no_tags': no_tags, |
| 841 | 'one_tag': one_tag, |
| 842 | 'two_tags': two_tags, |
| 843 | 'dot1ad': dot1ad, |
| 844 | 'exact_match': exact_match, |
| 845 | 'default_sub': default_sub, |
| 846 | 'outer_vlan_id_any': outer_vlan_id_any, |
| 847 | 'inner_vlan_id_any': inner_vlan_id_any, |
| 848 | 'outer_vlan_id': outer_vlan, |
| 849 | 'inner_vlan_id': inner_vlan}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 850 | |
Pavel Kotucek | 15ac81c | 2017-06-20 14:00:26 +0200 | [diff] [blame] | 851 | def create_p2pethernet_subif(self, sw_if_index, remote_mac, subif_id): |
| 852 | """Create p2p ethernet subinterface |
| 853 | |
| 854 | :param sw_if_index: main (parent) interface |
| 855 | :param remote_mac: client (remote) mac address |
| 856 | |
| 857 | """ |
| 858 | return self.api( |
| 859 | self.papi.p2p_ethernet_add, |
| 860 | {'parent_if_index': sw_if_index, |
| 861 | 'remote_mac': remote_mac, |
| 862 | 'subif_id': subif_id}) |
| 863 | |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 864 | def delete_subif(self, sw_if_index): |
| 865 | """Delete subinterface |
| 866 | |
| 867 | :param sw_if_index: |
| 868 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 869 | return self.api(self.papi.delete_subif, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 870 | {'sw_if_index': sw_if_index}) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 871 | |
Pavel Kotucek | 15ac81c | 2017-06-20 14:00:26 +0200 | [diff] [blame] | 872 | def delete_p2pethernet_subif(self, sw_if_index, remote_mac): |
| 873 | """Delete p2p ethernet subinterface |
| 874 | |
| 875 | :param sw_if_index: main (parent) interface |
| 876 | :param remote_mac: client (remote) mac address |
| 877 | |
| 878 | """ |
| 879 | return self.api( |
| 880 | self.papi.p2p_ethernet_del, |
| 881 | {'parent_if_index': sw_if_index, |
| 882 | 'remote_mac': remote_mac}) |
| 883 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 884 | def create_vlan_subif(self, sw_if_index, vlan): |
| 885 | """ |
| 886 | |
| 887 | :param vlan: |
| 888 | :param sw_if_index: |
| 889 | |
| 890 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 891 | return self.api(self.papi.create_vlan_subif, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 892 | {'sw_if_index': sw_if_index, |
| 893 | 'vlan_id': vlan}) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 894 | |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 895 | def create_loopback(self, mac=''): |
| 896 | """ |
| 897 | |
| 898 | :param mac: (Optional) |
| 899 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 900 | return self.api(self.papi.create_loopback, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 901 | {'mac_address': mac}) |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 902 | |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 903 | def delete_loopback(self, sw_if_index): |
| 904 | return self.api(self.papi.delete_loopback, |
| 905 | {'sw_if_index': sw_if_index, }) |
| 906 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 907 | def ip_table_add_del(self, |
| 908 | table_id, |
| 909 | is_add=1, |
| 910 | is_ipv6=0): |
| 911 | """ |
| 912 | |
| 913 | :param table_id |
| 914 | :param is_add: (Default value = 1) |
| 915 | :param is_ipv6: (Default value = 0) |
| 916 | |
| 917 | """ |
| 918 | |
| 919 | return self.api( |
| 920 | self.papi.ip_table_add_del, |
| 921 | {'table_id': table_id, |
| 922 | 'is_add': is_add, |
| 923 | 'is_ipv6': is_ipv6}) |
| 924 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 925 | def ip_add_del_route( |
| 926 | self, |
| 927 | dst_address, |
| 928 | dst_address_length, |
| 929 | next_hop_address, |
| 930 | next_hop_sw_if_index=0xFFFFFFFF, |
| 931 | table_id=0, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 932 | next_hop_table_id=0, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 933 | next_hop_weight=1, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 934 | next_hop_n_out_labels=0, |
| 935 | next_hop_out_label_stack=[], |
| 936 | next_hop_via_label=MPLS_LABEL_INVALID, |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 937 | next_hop_id=0xFFFFFFFF, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 938 | is_resolve_host=0, |
| 939 | is_resolve_attached=0, |
| 940 | classify_table_index=0xFFFFFFFF, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 941 | is_add=1, |
| 942 | is_drop=0, |
Juraj Sloboda | 86a2c57 | 2016-10-27 10:44:25 +0200 | [diff] [blame] | 943 | is_unreach=0, |
| 944 | is_prohibit=0, |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 945 | is_ipv6=0, |
| 946 | is_local=0, |
| 947 | is_classify=0, |
| 948 | is_multipath=0, |
Neale Ranns | f068c3e | 2018-01-03 04:18:48 -0800 | [diff] [blame] | 949 | is_dvr=0, |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 950 | is_udp_encap=0, |
Marek Gradzki | 0164a06 | 2017-10-13 10:22:59 +0200 | [diff] [blame] | 951 | is_source_lookup=0): |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 952 | """ |
| 953 | |
| 954 | :param dst_address_length: |
| 955 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 956 | :param dst_address: |
| 957 | :param next_hop_address: |
| 958 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 959 | :param vrf_id: (Default value = 0) |
| 960 | :param lookup_in_vrf: (Default value = 0) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 961 | :param classify_table_index: (Default value = 0xFFFFFFFF) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 962 | :param is_add: (Default value = 1) |
| 963 | :param is_drop: (Default value = 0) |
| 964 | :param is_ipv6: (Default value = 0) |
| 965 | :param is_local: (Default value = 0) |
| 966 | :param is_classify: (Default value = 0) |
| 967 | :param is_multipath: (Default value = 0) |
| 968 | :param is_resolve_host: (Default value = 0) |
| 969 | :param is_resolve_attached: (Default value = 0) |
Neale Ranns | f068c3e | 2018-01-03 04:18:48 -0800 | [diff] [blame] | 970 | :param is_dvr: (Default value = 0) |
Neale Ranns | 054c03a | 2017-10-13 05:15:07 -0700 | [diff] [blame] | 971 | :param is_source_lookup: (Default value = 0) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 972 | :param next_hop_weight: (Default value = 1) |
| 973 | |
| 974 | """ |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 975 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 976 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 977 | self.papi.ip_add_del_route, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 978 | {'next_hop_sw_if_index': next_hop_sw_if_index, |
| 979 | 'table_id': table_id, |
| 980 | 'classify_table_index': classify_table_index, |
| 981 | 'next_hop_table_id': next_hop_table_id, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 982 | 'is_add': is_add, |
| 983 | 'is_drop': is_drop, |
| 984 | 'is_unreach': is_unreach, |
| 985 | 'is_prohibit': is_prohibit, |
| 986 | 'is_ipv6': is_ipv6, |
| 987 | 'is_local': is_local, |
| 988 | 'is_classify': is_classify, |
| 989 | 'is_multipath': is_multipath, |
| 990 | 'is_resolve_host': is_resolve_host, |
| 991 | 'is_resolve_attached': is_resolve_attached, |
Neale Ranns | f068c3e | 2018-01-03 04:18:48 -0800 | [diff] [blame] | 992 | 'is_dvr': is_dvr, |
Neale Ranns | 054c03a | 2017-10-13 05:15:07 -0700 | [diff] [blame] | 993 | 'is_source_lookup': is_source_lookup, |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 994 | 'is_udp_encap': is_udp_encap, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 995 | 'next_hop_weight': next_hop_weight, |
| 996 | 'dst_address_length': dst_address_length, |
| 997 | 'dst_address': dst_address, |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 998 | 'next_hop_id': next_hop_id, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 999 | 'next_hop_address': next_hop_address, |
| 1000 | 'next_hop_n_out_labels': next_hop_n_out_labels, |
| 1001 | 'next_hop_via_label': next_hop_via_label, |
| 1002 | 'next_hop_out_label_stack': next_hop_out_label_stack}) |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 1003 | |
Matej Klotton | 16a14cd | 2016-12-07 15:09:13 +0100 | [diff] [blame] | 1004 | def ip_fib_dump(self): |
| 1005 | return self.api(self.papi.ip_fib_dump, {}) |
| 1006 | |
Jan Gelety | 057bb8c | 2016-12-20 17:32:45 +0100 | [diff] [blame] | 1007 | def ip6_fib_dump(self): |
| 1008 | return self.api(self.papi.ip6_fib_dump, {}) |
| 1009 | |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 1010 | def ip_neighbor_add_del(self, |
| 1011 | sw_if_index, |
| 1012 | mac_address, |
| 1013 | dst_address, |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 1014 | is_add=1, |
| 1015 | is_ipv6=0, |
| 1016 | is_static=0, |
Neale Ranns | b3b2de7 | 2017-03-08 05:17:22 -0800 | [diff] [blame] | 1017 | is_no_adj_fib=0, |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 1018 | ): |
| 1019 | """ Add neighbor MAC to IPv4 or IPv6 address. |
| 1020 | |
| 1021 | :param sw_if_index: |
| 1022 | :param mac_address: |
| 1023 | :param dst_address: |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 1024 | :param is_add: (Default value = 1) |
| 1025 | :param is_ipv6: (Default value = 0) |
| 1026 | :param is_static: (Default value = 0) |
Neale Ranns | b3b2de7 | 2017-03-08 05:17:22 -0800 | [diff] [blame] | 1027 | :param is_no_adj_fib: (Default value = 0) |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 1028 | """ |
| 1029 | |
| 1030 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 1031 | self.papi.ip_neighbor_add_del, |
Neale Ranns | baf2e90 | 2017-02-25 04:20:00 -0800 | [diff] [blame] | 1032 | {'sw_if_index': sw_if_index, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1033 | 'is_add': is_add, |
| 1034 | 'is_ipv6': is_ipv6, |
| 1035 | 'is_static': is_static, |
Neale Ranns | b3b2de7 | 2017-03-08 05:17:22 -0800 | [diff] [blame] | 1036 | 'is_no_adj_fib': is_no_adj_fib, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1037 | 'mac_address': mac_address, |
| 1038 | 'dst_address': dst_address |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 1039 | } |
Matej Klotton | 0178d52 | 2016-11-04 11:11:44 +0100 | [diff] [blame] | 1040 | ) |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 1041 | |
Neale Ranns | 39f9d8b | 2017-02-16 21:57:05 -0800 | [diff] [blame] | 1042 | def ip_neighbor_dump(self, |
| 1043 | sw_if_index, |
| 1044 | is_ipv6=0): |
| 1045 | """ Return IP neighbor dump. |
| 1046 | |
| 1047 | :param sw_if_index: |
| 1048 | :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0) |
| 1049 | """ |
| 1050 | |
| 1051 | return self.api( |
| 1052 | self.papi.ip_neighbor_dump, |
| 1053 | {'is_ipv6': is_ipv6, |
| 1054 | 'sw_if_index': sw_if_index |
| 1055 | } |
| 1056 | ) |
| 1057 | |
| 1058 | def proxy_arp_add_del(self, |
| 1059 | low_address, |
| 1060 | hi_address, |
| 1061 | vrf_id=0, |
| 1062 | is_add=1): |
| 1063 | """ Config Proxy Arp Range. |
| 1064 | |
| 1065 | :param low_address: Start address in the rnage to Proxy for |
| 1066 | :param hi_address: End address in the rnage to Proxy for |
| 1067 | :param vrf_id: The VRF/table in which to proxy |
| 1068 | """ |
| 1069 | |
| 1070 | return self.api( |
| 1071 | self.papi.proxy_arp_add_del, |
Neale Ranns | 0053de6 | 2018-05-22 08:40:52 -0700 | [diff] [blame] | 1072 | {'proxy': |
| 1073 | { |
| 1074 | 'vrf_id': vrf_id, |
| 1075 | 'low_address': low_address, |
| 1076 | 'hi_address': hi_address, |
| 1077 | }, |
| 1078 | 'is_add': is_add}) |
Neale Ranns | 39f9d8b | 2017-02-16 21:57:05 -0800 | [diff] [blame] | 1079 | |
| 1080 | def proxy_arp_intfc_enable_disable(self, |
| 1081 | sw_if_index, |
| 1082 | is_enable=1): |
| 1083 | """ Enable/Disable an interface for proxy ARP requests |
| 1084 | |
| 1085 | :param sw_if_index: Interface |
| 1086 | :param enable_disable: Enable/Disable |
| 1087 | """ |
| 1088 | |
| 1089 | return self.api( |
| 1090 | self.papi.proxy_arp_intfc_enable_disable, |
| 1091 | {'sw_if_index': sw_if_index, |
| 1092 | 'enable_disable': is_enable |
| 1093 | } |
| 1094 | ) |
| 1095 | |
Jan | e546d3b | 2016-12-08 13:10:03 +0100 | [diff] [blame] | 1096 | def reset_vrf(self, |
| 1097 | vrf_id, |
| 1098 | is_ipv6=0, |
| 1099 | ): |
| 1100 | """ Reset VRF (remove all routes etc.) request. |
| 1101 | |
| 1102 | :param int vrf_id: ID of the FIB table / VRF to reset. |
| 1103 | :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0) |
| 1104 | """ |
| 1105 | |
| 1106 | return self.api( |
| 1107 | self.papi.reset_vrf, |
| 1108 | {'vrf_id': vrf_id, |
| 1109 | 'is_ipv6': is_ipv6, |
| 1110 | } |
| 1111 | ) |
| 1112 | |
| 1113 | def reset_fib(self, |
| 1114 | vrf_id, |
| 1115 | is_ipv6=0, |
| 1116 | ): |
| 1117 | """ Reset VRF (remove all routes etc.) request. |
| 1118 | |
| 1119 | :param int vrf_id: ID of the FIB table / VRF to reset. |
| 1120 | :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0) |
| 1121 | """ |
| 1122 | |
| 1123 | return self.api( |
| 1124 | self.papi.reset_fib, |
| 1125 | {'vrf_id': vrf_id, |
| 1126 | 'is_ipv6': is_ipv6, |
| 1127 | } |
| 1128 | ) |
| 1129 | |
| 1130 | def ip_dump(self, |
| 1131 | is_ipv6=0, |
| 1132 | ): |
| 1133 | """ Return IP dump. |
| 1134 | |
| 1135 | :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0) |
| 1136 | """ |
| 1137 | |
| 1138 | return self.api( |
| 1139 | self.papi.ip_dump, |
| 1140 | {'is_ipv6': is_ipv6, |
| 1141 | } |
| 1142 | ) |
| 1143 | |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 1144 | def sw_interface_span_enable_disable( |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 1145 | self, sw_if_index_from, sw_if_index_to, state=1, is_l2=0): |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 1146 | """ |
| 1147 | |
| 1148 | :param sw_if_index_from: |
| 1149 | :param sw_if_index_to: |
Matej Klotton | deb6984 | 2016-12-09 15:05:46 +0100 | [diff] [blame] | 1150 | :param state: |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 1151 | :param is_l2: |
Pavel Kotucek | f6e3dc4 | 2016-11-04 09:58:01 +0100 | [diff] [blame] | 1152 | """ |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 1153 | return self.api(self.papi.sw_interface_span_enable_disable, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1154 | {'sw_if_index_from': sw_if_index_from, |
| 1155 | 'sw_if_index_to': sw_if_index_to, |
Eyal Bari | 001fd40 | 2017-07-16 09:34:53 +0300 | [diff] [blame] | 1156 | 'state': state, |
| 1157 | 'is_l2': is_l2, |
| 1158 | }) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1159 | |
| 1160 | def gre_tunnel_add_del(self, |
| 1161 | src_address, |
| 1162 | dst_address, |
| 1163 | outer_fib_id=0, |
John Lo | a43ccae | 2018-02-13 17:15:23 -0500 | [diff] [blame] | 1164 | tunnel_type=0, |
| 1165 | instance=0xFFFFFFFF, |
| 1166 | session_id=0, |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1167 | is_add=1, |
| 1168 | is_ip6=0): |
| 1169 | """ Add a GRE tunnel |
| 1170 | |
| 1171 | :param src_address: |
| 1172 | :param dst_address: |
| 1173 | :param outer_fib_id: (Default value = 0) |
John Lo | a43ccae | 2018-02-13 17:15:23 -0500 | [diff] [blame] | 1174 | :param tunnel_type: (Default value = 0) |
| 1175 | :param instance: (Default value = 0xFFFFFFFF) |
| 1176 | :param session_id: (Defalt value = 0) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1177 | :param is_add: (Default value = 1) |
| 1178 | :param is_ipv6: (Default value = 0) |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1179 | """ |
| 1180 | |
| 1181 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 1182 | self.papi.gre_add_del_tunnel, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1183 | {'is_add': is_add, |
| 1184 | 'is_ipv6': is_ip6, |
John Lo | a43ccae | 2018-02-13 17:15:23 -0500 | [diff] [blame] | 1185 | 'tunnel_type': tunnel_type, |
| 1186 | 'instance': instance, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1187 | 'src_address': src_address, |
| 1188 | 'dst_address': dst_address, |
John Lo | a43ccae | 2018-02-13 17:15:23 -0500 | [diff] [blame] | 1189 | 'outer_fib_id': outer_fib_id, |
| 1190 | 'session_id': session_id} |
Neale Ranns | 177bbdc | 2016-11-15 09:46:51 +0000 | [diff] [blame] | 1191 | ) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1192 | |
Neale Ranns | d0df49f | 2018-08-08 01:06:40 -0700 | [diff] [blame] | 1193 | def udp_encap_add(self, |
Neale Ranns | d0df49f | 2018-08-08 01:06:40 -0700 | [diff] [blame] | 1194 | src_ip, |
| 1195 | dst_ip, |
| 1196 | src_port, |
| 1197 | dst_port, |
| 1198 | table_id=0): |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 1199 | """ Add a GRE tunnel |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 1200 | :param src_ip: |
| 1201 | :param dst_ip: |
| 1202 | :param src_port: |
| 1203 | :param dst_port: |
| 1204 | :param outer_fib_id: (Default value = 0) |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 1205 | """ |
| 1206 | |
| 1207 | return self.api( |
Neale Ranns | d0df49f | 2018-08-08 01:06:40 -0700 | [diff] [blame] | 1208 | self.papi.udp_encap_add, |
| 1209 | { |
| 1210 | 'udp_encap': { |
Neale Ranns | d0df49f | 2018-08-08 01:06:40 -0700 | [diff] [blame] | 1211 | 'src_ip': src_ip, |
| 1212 | 'dst_ip': dst_ip, |
| 1213 | 'src_port': src_port, |
| 1214 | 'dst_port': dst_port, |
| 1215 | 'table_id': table_id |
| 1216 | } |
| 1217 | }) |
| 1218 | |
| 1219 | def udp_encap_del(self, id): |
| 1220 | return self.api(self.papi.udp_encap_del, {'id': id}) |
Neale Ranns | 810086d | 2017-11-05 16:26:46 -0800 | [diff] [blame] | 1221 | |
| 1222 | def udp_encap_dump(self): |
| 1223 | return self.api(self.papi.udp_encap_dump, {}) |
| 1224 | |
Neale Ranns | 43b1f44 | 2018-03-20 01:47:35 -0700 | [diff] [blame] | 1225 | def want_udp_encap_stats(self, enable=1): |
| 1226 | return self.api(self.papi.want_udp_encap_stats, |
| 1227 | {'enable': enable, |
| 1228 | 'pid': os.getpid()}) |
| 1229 | |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 1230 | def mpls_fib_dump(self): |
| 1231 | return self.api(self.papi.mpls_fib_dump, {}) |
| 1232 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 1233 | def mpls_table_add_del( |
| 1234 | self, |
| 1235 | table_id, |
| 1236 | is_add=1): |
| 1237 | """ |
| 1238 | |
| 1239 | :param table_id |
| 1240 | :param is_add: (Default value = 1) |
| 1241 | |
| 1242 | """ |
| 1243 | |
| 1244 | return self.api( |
| 1245 | self.papi.mpls_table_add_del, |
| 1246 | {'mt_table_id': table_id, |
| 1247 | 'mt_is_add': is_add}) |
| 1248 | |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1249 | def mpls_route_add_del( |
| 1250 | self, |
| 1251 | label, |
| 1252 | eos, |
Neale Ranns | da78f95 | 2017-05-24 09:15:43 -0700 | [diff] [blame] | 1253 | next_hop_proto, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1254 | next_hop_address, |
| 1255 | next_hop_sw_if_index=0xFFFFFFFF, |
| 1256 | table_id=0, |
| 1257 | next_hop_table_id=0, |
| 1258 | next_hop_weight=1, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1259 | next_hop_n_out_labels=0, |
| 1260 | next_hop_out_label_stack=[], |
| 1261 | next_hop_via_label=MPLS_LABEL_INVALID, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1262 | is_resolve_host=0, |
| 1263 | is_resolve_attached=0, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1264 | is_interface_rx=0, |
| 1265 | is_rpf_id=0, |
| 1266 | is_multicast=0, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1267 | is_add=1, |
| 1268 | is_drop=0, |
| 1269 | is_multipath=0, |
| 1270 | classify_table_index=0xFFFFFFFF, |
Marek Gradzki | 0164a06 | 2017-10-13 10:22:59 +0200 | [diff] [blame] | 1271 | is_classify=0): |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1272 | """ |
| 1273 | |
| 1274 | :param dst_address_length: |
| 1275 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 1276 | :param dst_address: |
| 1277 | :param next_hop_address: |
| 1278 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 1279 | :param vrf_id: (Default value = 0) |
| 1280 | :param lookup_in_vrf: (Default value = 0) |
| 1281 | :param classify_table_index: (Default value = 0xFFFFFFFF) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1282 | :param is_add: (Default value = 1) |
| 1283 | :param is_drop: (Default value = 0) |
| 1284 | :param is_ipv6: (Default value = 0) |
| 1285 | :param is_local: (Default value = 0) |
| 1286 | :param is_classify: (Default value = 0) |
| 1287 | :param is_multipath: (Default value = 0) |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1288 | :param is_multicast: (Default value = 0) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1289 | :param is_resolve_host: (Default value = 0) |
| 1290 | :param is_resolve_attached: (Default value = 0) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1291 | :param next_hop_weight: (Default value = 1) |
| 1292 | |
| 1293 | """ |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1294 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 1295 | self.papi.mpls_route_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1296 | {'mr_label': label, |
| 1297 | 'mr_eos': eos, |
| 1298 | 'mr_table_id': table_id, |
| 1299 | 'mr_classify_table_index': classify_table_index, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1300 | 'mr_is_add': is_add, |
| 1301 | 'mr_is_classify': is_classify, |
| 1302 | 'mr_is_multipath': is_multipath, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1303 | 'mr_is_multicast': is_multicast, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1304 | 'mr_is_resolve_host': is_resolve_host, |
| 1305 | 'mr_is_resolve_attached': is_resolve_attached, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1306 | 'mr_is_interface_rx': is_interface_rx, |
| 1307 | 'mr_is_rpf_id': is_rpf_id, |
Neale Ranns | da78f95 | 2017-05-24 09:15:43 -0700 | [diff] [blame] | 1308 | 'mr_next_hop_proto': next_hop_proto, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1309 | 'mr_next_hop_weight': next_hop_weight, |
| 1310 | 'mr_next_hop': next_hop_address, |
| 1311 | 'mr_next_hop_n_out_labels': next_hop_n_out_labels, |
| 1312 | 'mr_next_hop_sw_if_index': next_hop_sw_if_index, |
| 1313 | 'mr_next_hop_table_id': next_hop_table_id, |
| 1314 | 'mr_next_hop_via_label': next_hop_via_label, |
| 1315 | 'mr_next_hop_out_label_stack': next_hop_out_label_stack}) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1316 | |
| 1317 | def mpls_ip_bind_unbind( |
| 1318 | self, |
| 1319 | label, |
| 1320 | dst_address, |
| 1321 | dst_address_length, |
| 1322 | table_id=0, |
| 1323 | ip_table_id=0, |
| 1324 | is_ip4=1, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1325 | is_bind=1): |
| 1326 | """ |
| 1327 | """ |
| 1328 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 1329 | self.papi.mpls_ip_bind_unbind, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1330 | {'mb_mpls_table_id': table_id, |
| 1331 | 'mb_label': label, |
| 1332 | 'mb_ip_table_id': ip_table_id, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1333 | 'mb_is_bind': is_bind, |
| 1334 | 'mb_is_ip4': is_ip4, |
| 1335 | 'mb_address_length': dst_address_length, |
| 1336 | 'mb_address': dst_address}) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1337 | |
| 1338 | def mpls_tunnel_add_del( |
| 1339 | self, |
| 1340 | tun_sw_if_index, |
| 1341 | next_hop_proto_is_ip4, |
| 1342 | next_hop_address, |
| 1343 | next_hop_sw_if_index=0xFFFFFFFF, |
| 1344 | next_hop_table_id=0, |
| 1345 | next_hop_weight=1, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1346 | next_hop_n_out_labels=0, |
| 1347 | next_hop_out_label_stack=[], |
| 1348 | next_hop_via_label=MPLS_LABEL_INVALID, |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1349 | is_add=1, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1350 | l2_only=0, |
| 1351 | is_multicast=0): |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1352 | """ |
| 1353 | |
| 1354 | :param dst_address_length: |
| 1355 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 1356 | :param dst_address: |
| 1357 | :param next_hop_address: |
| 1358 | :param next_hop_sw_if_index: (Default value = 0xFFFFFFFF) |
| 1359 | :param vrf_id: (Default value = 0) |
| 1360 | :param lookup_in_vrf: (Default value = 0) |
| 1361 | :param classify_table_index: (Default value = 0xFFFFFFFF) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1362 | :param is_add: (Default value = 1) |
| 1363 | :param is_drop: (Default value = 0) |
| 1364 | :param is_ipv6: (Default value = 0) |
| 1365 | :param is_local: (Default value = 0) |
| 1366 | :param is_classify: (Default value = 0) |
| 1367 | :param is_multipath: (Default value = 0) |
| 1368 | :param is_resolve_host: (Default value = 0) |
| 1369 | :param is_resolve_attached: (Default value = 0) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1370 | :param next_hop_weight: (Default value = 1) |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1371 | :param is_multicast: (Default value = 0) |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1372 | |
| 1373 | """ |
Neale Ranns | ad422ed | 2016-11-02 14:20:04 +0000 | [diff] [blame] | 1374 | return self.api( |
Ole Troan | 7e3a875 | 2016-12-05 10:27:09 +0100 | [diff] [blame] | 1375 | self.papi.mpls_tunnel_add_del, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1376 | {'mt_sw_if_index': tun_sw_if_index, |
| 1377 | 'mt_is_add': is_add, |
| 1378 | 'mt_l2_only': l2_only, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1379 | 'mt_is_multicast': is_multicast, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1380 | 'mt_next_hop_proto_is_ip4': next_hop_proto_is_ip4, |
| 1381 | 'mt_next_hop_weight': next_hop_weight, |
| 1382 | 'mt_next_hop': next_hop_address, |
| 1383 | 'mt_next_hop_n_out_labels': next_hop_n_out_labels, |
| 1384 | 'mt_next_hop_sw_if_index': next_hop_sw_if_index, |
| 1385 | 'mt_next_hop_table_id': next_hop_table_id, |
Neale Ranns | 7c922dc | 2018-08-30 06:12:27 -0700 | [diff] [blame] | 1386 | 'mt_next_hop_via_label': next_hop_via_label, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1387 | 'mt_next_hop_out_label_stack': next_hop_out_label_stack}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1388 | |
Neale Ranns | f5fa5ae | 2018-09-26 05:07:25 -0700 | [diff] [blame] | 1389 | def mpls_tunnel_dump(self, sw_if_index=0xffffffff): |
| 1390 | return self.api(self.papi.mpls_tunnel_dump, |
| 1391 | {'sw_if_index': sw_if_index}) |
Neale Ranns | 6a30b5f | 2018-09-25 07:22:36 -0700 | [diff] [blame] | 1392 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1393 | def nat44_interface_add_del_feature( |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1394 | self, |
| 1395 | sw_if_index, |
| 1396 | is_inside=1, |
| 1397 | is_add=1): |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1398 | """Enable/disable NAT44 feature on the interface |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1399 | |
| 1400 | :param sw_if_index: Software index of the interface |
| 1401 | :param is_inside: 1 if inside, 0 if outside (Default value = 1) |
| 1402 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 1403 | """ |
| 1404 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1405 | self.papi.nat44_interface_add_del_feature, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1406 | {'is_add': is_add, |
| 1407 | 'is_inside': is_inside, |
| 1408 | 'sw_if_index': sw_if_index}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1409 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1410 | def nat44_interface_add_del_output_feature( |
Matus Fabian | 93d84c9 | 2017-07-19 08:06:01 -0700 | [diff] [blame] | 1411 | self, |
| 1412 | sw_if_index, |
| 1413 | is_inside=1, |
| 1414 | is_add=1): |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1415 | """Enable/disable NAT44 output feature on the interface |
Matus Fabian | 93d84c9 | 2017-07-19 08:06:01 -0700 | [diff] [blame] | 1416 | |
| 1417 | :param sw_if_index: Software index of the interface |
| 1418 | :param is_inside: 1 if inside, 0 if outside (Default value = 1) |
| 1419 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 1420 | """ |
| 1421 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1422 | self.papi.nat44_interface_add_del_output_feature, |
Matus Fabian | 93d84c9 | 2017-07-19 08:06:01 -0700 | [diff] [blame] | 1423 | {'is_add': is_add, |
| 1424 | 'is_inside': is_inside, |
| 1425 | 'sw_if_index': sw_if_index}) |
| 1426 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1427 | def nat44_add_del_static_mapping( |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1428 | self, |
| 1429 | local_ip, |
Matus Fabian | 36532bd | 2017-01-23 23:42:28 -0800 | [diff] [blame] | 1430 | external_ip=0, |
| 1431 | external_sw_if_index=0xFFFFFFFF, |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1432 | local_port=0, |
| 1433 | external_port=0, |
| 1434 | addr_only=1, |
| 1435 | vrf_id=0, |
Matus Fabian | 09d96f4 | 2017-02-02 01:43:00 -0800 | [diff] [blame] | 1436 | protocol=0, |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1437 | twice_nat=0, |
Juraj Sloboda | 1e5c07d | 2018-04-10 13:51:54 +0200 | [diff] [blame] | 1438 | self_twice_nat=0, |
Matus Fabian | e82488f | 2018-01-18 03:38:45 -0800 | [diff] [blame] | 1439 | out2in_only=0, |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1440 | tag="", |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1441 | is_add=1): |
| 1442 | """Add/delete NAT44 static mapping |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1443 | |
| 1444 | :param local_ip: Local IP address |
| 1445 | :param external_ip: External IP address |
Matus Fabian | 36532bd | 2017-01-23 23:42:28 -0800 | [diff] [blame] | 1446 | :param external_sw_if_index: External interface instead of IP address |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1447 | :param local_port: Local port number (Default value = 0) |
| 1448 | :param external_port: External port number (Default value = 0) |
| 1449 | :param addr_only: 1 if address only mapping, 0 if address and port |
| 1450 | :param vrf_id: VRF ID |
Matus Fabian | 09d96f4 | 2017-02-02 01:43:00 -0800 | [diff] [blame] | 1451 | :param protocol: IP protocol (Default value = 0) |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1452 | :param twice_nat: 1 if translate external host address and port |
Juraj Sloboda | 1e5c07d | 2018-04-10 13:51:54 +0200 | [diff] [blame] | 1453 | :param self_twice_nat: 1 if translate external host address and port |
| 1454 | whenever external host address equals |
| 1455 | local address of internal host |
Matus Fabian | e82488f | 2018-01-18 03:38:45 -0800 | [diff] [blame] | 1456 | :param out2in_only: if 1 rule is matching only out2in direction |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1457 | :param tag: Opaque string tag |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1458 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1459 | """ |
| 1460 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1461 | self.papi.nat44_add_del_static_mapping, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1462 | {'is_add': is_add, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1463 | 'addr_only': addr_only, |
| 1464 | 'local_ip_address': local_ip, |
| 1465 | 'external_ip_address': external_ip, |
| 1466 | 'local_port': local_port, |
| 1467 | 'external_port': external_port, |
Matus Fabian | 36532bd | 2017-01-23 23:42:28 -0800 | [diff] [blame] | 1468 | 'external_sw_if_index': external_sw_if_index, |
Matus Fabian | 09d96f4 | 2017-02-02 01:43:00 -0800 | [diff] [blame] | 1469 | 'vrf_id': vrf_id, |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1470 | 'protocol': protocol, |
Matus Fabian | e82488f | 2018-01-18 03:38:45 -0800 | [diff] [blame] | 1471 | 'twice_nat': twice_nat, |
Juraj Sloboda | 1e5c07d | 2018-04-10 13:51:54 +0200 | [diff] [blame] | 1472 | 'self_twice_nat': self_twice_nat, |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1473 | 'out2in_only': out2in_only, |
| 1474 | 'tag': tag}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1475 | |
Matus Fabian | ab7a805 | 2017-11-28 04:29:41 -0800 | [diff] [blame] | 1476 | def nat44_add_del_identity_mapping( |
| 1477 | self, |
| 1478 | ip='0', |
| 1479 | sw_if_index=0xFFFFFFFF, |
| 1480 | port=0, |
| 1481 | addr_only=1, |
| 1482 | vrf_id=0, |
| 1483 | protocol=0, |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1484 | tag='', |
Matus Fabian | ab7a805 | 2017-11-28 04:29:41 -0800 | [diff] [blame] | 1485 | is_add=1): |
| 1486 | """Add/delete NAT44 identity mapping |
| 1487 | |
| 1488 | :param ip: IP address (Default value = 0) |
| 1489 | :param sw_if_index: Interface instead of IP address |
| 1490 | :param port: Port number (Default value = 0) |
| 1491 | :param addr_only: 1 if address only mapping, 0 if address and port |
| 1492 | :param vrf_id: VRF ID |
| 1493 | :param protocol: IP protocol (Default value = 0) |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1494 | :param tag: Opaque string tag |
Matus Fabian | ab7a805 | 2017-11-28 04:29:41 -0800 | [diff] [blame] | 1495 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 1496 | """ |
| 1497 | return self.api( |
| 1498 | self.papi.nat44_add_del_identity_mapping, |
| 1499 | {'is_add': is_add, |
| 1500 | 'addr_only': addr_only, |
| 1501 | 'ip_address': ip, |
| 1502 | 'port': port, |
| 1503 | 'sw_if_index': sw_if_index, |
| 1504 | 'vrf_id': vrf_id, |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1505 | 'tag': tag, |
Matus Fabian | ab7a805 | 2017-11-28 04:29:41 -0800 | [diff] [blame] | 1506 | 'protocol': protocol}) |
| 1507 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1508 | def nat44_add_del_address_range( |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1509 | self, |
| 1510 | first_ip_address, |
| 1511 | last_ip_address, |
| 1512 | is_add=1, |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1513 | vrf_id=0xFFFFFFFF, |
| 1514 | twice_nat=0): |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1515 | """Add/del NAT44 address range |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1516 | |
| 1517 | :param first_ip_address: First IP address |
| 1518 | :param last_ip_address: Last IP address |
Juraj Sloboda | eab38d9 | 2017-03-06 19:55:21 -0800 | [diff] [blame] | 1519 | :param vrf_id: VRF id for the address range |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1520 | :param twice_nat: twice NAT address for extenal hosts |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1521 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1522 | """ |
| 1523 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1524 | self.papi.nat44_add_del_address_range, |
| 1525 | {'first_ip_address': first_ip_address, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1526 | 'last_ip_address': last_ip_address, |
Juraj Sloboda | eab38d9 | 2017-03-06 19:55:21 -0800 | [diff] [blame] | 1527 | 'vrf_id': vrf_id, |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1528 | 'twice_nat': twice_nat, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1529 | 'is_add': is_add}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1530 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1531 | def nat44_address_dump(self): |
| 1532 | """Dump NAT44 addresses |
| 1533 | :return: Dictionary of NAT44 addresses |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1534 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1535 | return self.api(self.papi.nat44_address_dump, {}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1536 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1537 | def nat44_interface_dump(self): |
| 1538 | """Dump interfaces with NAT44 feature |
| 1539 | :return: Dictionary of interfaces with NAT44 feature |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1540 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1541 | return self.api(self.papi.nat44_interface_dump, {}) |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1542 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1543 | def nat44_interface_output_feature_dump(self): |
| 1544 | """Dump interfaces with NAT44 output feature |
| 1545 | :return: Dictionary of interfaces with NAT44 output feature |
Matus Fabian | 93d84c9 | 2017-07-19 08:06:01 -0700 | [diff] [blame] | 1546 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1547 | return self.api(self.papi.nat44_interface_output_feature_dump, {}) |
Matus Fabian | 93d84c9 | 2017-07-19 08:06:01 -0700 | [diff] [blame] | 1548 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1549 | def nat44_static_mapping_dump(self): |
| 1550 | """Dump NAT44 static mappings |
| 1551 | :return: Dictionary of NAT44 static mappings |
Matus Fabian | de88675 | 2016-12-07 03:38:19 -0800 | [diff] [blame] | 1552 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1553 | return self.api(self.papi.nat44_static_mapping_dump, {}) |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 1554 | |
Matus Fabian | ab7a805 | 2017-11-28 04:29:41 -0800 | [diff] [blame] | 1555 | def nat44_identity_mapping_dump(self): |
| 1556 | """Dump NAT44 identity mappings |
| 1557 | :return: Dictionary of NAT44 identity mappings |
| 1558 | """ |
| 1559 | return self.api(self.papi.nat44_identity_mapping_dump, {}) |
| 1560 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1561 | def nat_show_config(self): |
| 1562 | """Show NAT plugin config |
| 1563 | :return: NAT plugin config parameters |
Matus Fabian | 9902fcd | 2016-12-21 23:58:46 -0800 | [diff] [blame] | 1564 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1565 | return self.api(self.papi.nat_show_config, {}) |
Matus Fabian | 9902fcd | 2016-12-21 23:58:46 -0800 | [diff] [blame] | 1566 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1567 | def nat44_add_interface_addr( |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 1568 | self, |
| 1569 | sw_if_index, |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1570 | twice_nat=0, |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 1571 | is_add=1): |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1572 | """Add/del NAT44 address from interface |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 1573 | |
| 1574 | :param sw_if_index: Software index of the interface |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1575 | :param twice_nat: twice NAT address for extenal hosts |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 1576 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 1577 | """ |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1578 | return self.api( |
| 1579 | self.papi.nat44_add_del_interface_addr, |
| 1580 | {'is_add': is_add, |
| 1581 | 'sw_if_index': sw_if_index, |
| 1582 | 'twice_nat': twice_nat}) |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 1583 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1584 | def nat44_interface_addr_dump(self): |
| 1585 | """Dump NAT44 addresses interfaces |
| 1586 | :return: Dictionary of NAT44 addresses interfaces |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 1587 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1588 | return self.api(self.papi.nat44_interface_addr_dump, {}) |
Matus Fabian | 8bf68e8 | 2017-01-12 04:24:35 -0800 | [diff] [blame] | 1589 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1590 | def nat_ipfix( |
Matus Fabian | eea28d7 | 2017-01-13 04:15:54 -0800 | [diff] [blame] | 1591 | self, |
| 1592 | domain_id=1, |
| 1593 | src_port=4739, |
| 1594 | enable=1): |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1595 | """Enable/disable NAT IPFIX logging |
Matus Fabian | eea28d7 | 2017-01-13 04:15:54 -0800 | [diff] [blame] | 1596 | |
| 1597 | :param domain_id: Observation domain ID (Default value = 1) |
| 1598 | :param src_port: Source port number (Default value = 4739) |
| 1599 | :param enable: 1 if enable, 0 if disable (Default value = 1) |
| 1600 | """ |
| 1601 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1602 | self.papi.nat_ipfix_enable_disable, |
Matus Fabian | eea28d7 | 2017-01-13 04:15:54 -0800 | [diff] [blame] | 1603 | {'domain_id': domain_id, |
| 1604 | 'src_port': src_port, |
| 1605 | 'enable': enable}) |
| 1606 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1607 | def nat44_user_session_dump( |
magalik | 23caa88 | 2017-02-08 23:25:45 -0800 | [diff] [blame] | 1608 | self, |
| 1609 | ip_address, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1610 | vrf_id): |
| 1611 | """Dump NAT44 user's sessions |
magalik | 23caa88 | 2017-02-08 23:25:45 -0800 | [diff] [blame] | 1612 | |
| 1613 | :param ip_address: ip adress of the user to be dumped |
| 1614 | :param cpu_index: cpu_index on which the user is |
| 1615 | :param vrf_id: VRF ID |
| 1616 | :return: Dictionary of S-NAT sessions |
| 1617 | """ |
| 1618 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1619 | self.papi.nat44_user_session_dump, |
magalik | 23caa88 | 2017-02-08 23:25:45 -0800 | [diff] [blame] | 1620 | {'ip_address': ip_address, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1621 | 'vrf_id': vrf_id}) |
magalik | 23caa88 | 2017-02-08 23:25:45 -0800 | [diff] [blame] | 1622 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1623 | def nat44_user_dump(self): |
| 1624 | """Dump NAT44 users |
magalik | 23caa88 | 2017-02-08 23:25:45 -0800 | [diff] [blame] | 1625 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1626 | :return: Dictionary of NAT44 users |
magalik | 23caa88 | 2017-02-08 23:25:45 -0800 | [diff] [blame] | 1627 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1628 | return self.api(self.papi.nat44_user_dump, {}) |
magalik | 23caa88 | 2017-02-08 23:25:45 -0800 | [diff] [blame] | 1629 | |
Matus Fabian | 704018c | 2017-09-04 02:17:18 -0700 | [diff] [blame] | 1630 | def nat44_add_del_lb_static_mapping( |
| 1631 | self, |
| 1632 | external_addr, |
| 1633 | external_port, |
| 1634 | protocol, |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1635 | twice_nat=0, |
Juraj Sloboda | 1e5c07d | 2018-04-10 13:51:54 +0200 | [diff] [blame] | 1636 | self_twice_nat=0, |
Matus Fabian | 240b5ef | 2018-01-11 04:09:17 -0800 | [diff] [blame] | 1637 | out2in_only=0, |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1638 | tag='', |
Matus Fabian | ea5b5be | 2018-09-03 05:02:23 -0700 | [diff] [blame] | 1639 | affinity=0, |
Matus Fabian | 704018c | 2017-09-04 02:17:18 -0700 | [diff] [blame] | 1640 | local_num=0, |
Ole Troan | 895b6e8 | 2017-10-20 13:28:20 +0200 | [diff] [blame] | 1641 | locals=[], |
Matus Fabian | 704018c | 2017-09-04 02:17:18 -0700 | [diff] [blame] | 1642 | is_add=1): |
| 1643 | """Add/delete NAT44 load balancing static mapping |
| 1644 | |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1645 | :param twice_nat: 1 if translate external host address and port |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1646 | :param tag: Opaque string tag |
Matus Fabian | ea5b5be | 2018-09-03 05:02:23 -0700 | [diff] [blame] | 1647 | :param affinity: if 0 disabled, otherwise client IP affinity timeout |
Matus Fabian | 704018c | 2017-09-04 02:17:18 -0700 | [diff] [blame] | 1648 | :param is_add - 1 if add, 0 if delete |
| 1649 | """ |
| 1650 | return self.api( |
| 1651 | self.papi.nat44_add_del_lb_static_mapping, |
| 1652 | {'is_add': is_add, |
| 1653 | 'external_addr': external_addr, |
| 1654 | 'external_port': external_port, |
| 1655 | 'protocol': protocol, |
Matus Fabian | b932d26 | 2017-12-18 05:38:24 -0800 | [diff] [blame] | 1656 | 'twice_nat': twice_nat, |
Juraj Sloboda | 1e5c07d | 2018-04-10 13:51:54 +0200 | [diff] [blame] | 1657 | 'self_twice_nat': self_twice_nat, |
Matus Fabian | 240b5ef | 2018-01-11 04:09:17 -0800 | [diff] [blame] | 1658 | 'out2in_only': out2in_only, |
Matus Fabian | 5f22499 | 2018-01-25 21:59:16 -0800 | [diff] [blame] | 1659 | 'tag': tag, |
Matus Fabian | ea5b5be | 2018-09-03 05:02:23 -0700 | [diff] [blame] | 1660 | 'affinity': affinity, |
Matus Fabian | 704018c | 2017-09-04 02:17:18 -0700 | [diff] [blame] | 1661 | 'local_num': local_num, |
| 1662 | 'locals': locals}) |
| 1663 | |
| 1664 | def nat44_lb_static_mapping_dump(self): |
| 1665 | """Dump NAT44 load balancing static mappings |
| 1666 | |
| 1667 | :return: Dictionary of NAT44 load balancing static mapping |
| 1668 | """ |
| 1669 | return self.api(self.papi.nat44_lb_static_mapping_dump, {}) |
| 1670 | |
Matus Fabian | 5ba86f7 | 2017-10-26 03:37:38 -0700 | [diff] [blame] | 1671 | def nat44_del_session( |
| 1672 | self, |
| 1673 | addr, |
| 1674 | port, |
| 1675 | protocol, |
| 1676 | vrf_id=0, |
Matus Fabian | 70a26ac | 2018-05-14 06:20:28 -0700 | [diff] [blame] | 1677 | is_in=1, |
| 1678 | ext_host_address=None, |
| 1679 | ext_host_port=0): |
Matus Fabian | 5ba86f7 | 2017-10-26 03:37:38 -0700 | [diff] [blame] | 1680 | """Delete NAT44 session |
| 1681 | |
| 1682 | :param addr: IPv4 address |
| 1683 | :param por: port number |
| 1684 | :param protocol: IP protocol number |
| 1685 | :param vrf_id: VRF ID |
| 1686 | :param is_in: 1 if inside network addres and port pari, 0 if outside |
Matus Fabian | 70a26ac | 2018-05-14 06:20:28 -0700 | [diff] [blame] | 1687 | :param ext_host_address: external host IPv4 address |
| 1688 | :param ext_host_port: external host port |
Matus Fabian | 5ba86f7 | 2017-10-26 03:37:38 -0700 | [diff] [blame] | 1689 | """ |
Matus Fabian | 70a26ac | 2018-05-14 06:20:28 -0700 | [diff] [blame] | 1690 | if ext_host_address is None: |
| 1691 | return self.api( |
| 1692 | self.papi.nat44_del_session, |
| 1693 | {'address': addr, |
| 1694 | 'port': port, |
| 1695 | 'protocol': protocol, |
| 1696 | 'vrf_id': vrf_id, |
| 1697 | 'is_in': is_in}) |
| 1698 | else: |
| 1699 | return self.api( |
| 1700 | self.papi.nat44_del_session, |
| 1701 | {'address': addr, |
| 1702 | 'port': port, |
| 1703 | 'protocol': protocol, |
| 1704 | 'vrf_id': vrf_id, |
| 1705 | 'is_in': is_in, |
| 1706 | 'ext_host_valid': 1, |
| 1707 | 'ext_host_address': ext_host_address, |
| 1708 | 'ext_host_port': ext_host_port}) |
Matus Fabian | 5ba86f7 | 2017-10-26 03:37:38 -0700 | [diff] [blame] | 1709 | |
Juraj Sloboda | 7b92979 | 2017-11-23 13:20:48 +0100 | [diff] [blame] | 1710 | def nat44_forwarding_enable_disable( |
| 1711 | self, |
| 1712 | enable): |
| 1713 | """Enable/disable forwarding for NAT44 |
| 1714 | |
| 1715 | :param enable: 1 for enable, 0 for disable |
| 1716 | """ |
| 1717 | return self.api( |
| 1718 | self.papi.nat44_forwarding_enable_disable, |
| 1719 | {'enable': enable}) |
| 1720 | |
Matus Fabian | efcd1e9 | 2017-08-15 06:59:19 -0700 | [diff] [blame] | 1721 | def nat_set_reass( |
| 1722 | self, |
| 1723 | timeout=2, |
| 1724 | max_reass=1024, |
| 1725 | max_frag=5, |
| 1726 | drop_frag=0, |
| 1727 | is_ip6=0): |
| 1728 | """Set NAT virtual fragmentation reassembly |
| 1729 | |
| 1730 | :param timeout: reassembly timeout (Default 2sec) |
| 1731 | :param max_reass: maximum concurrent reassemblies (Default 1024) |
| 1732 | :param max_frag: maximum fragmets per reassembly (Default 5) |
| 1733 | :param drop_frag: if 0 translate fragments, otherwise drop fragments |
| 1734 | :param is_ip6: 1 if IPv6, 0 if IPv4 |
| 1735 | """ |
| 1736 | return self.api( |
| 1737 | self.papi.nat_set_reass, |
| 1738 | {'timeout': timeout, |
| 1739 | 'max_reass': max_reass, |
| 1740 | 'max_frag': max_frag, |
| 1741 | 'drop_frag': drop_frag, |
| 1742 | 'is_ip6': is_ip6}) |
| 1743 | |
| 1744 | def nat_get_reass(self): |
| 1745 | """Get NAT virtual fragmentation reassembly configuration |
| 1746 | |
| 1747 | :return: NAT virtual fragmentation reassembly configuration |
| 1748 | """ |
| 1749 | return self.api(self.papi.nat_get_reass, {}) |
| 1750 | |
| 1751 | def nat_reass_dump(self): |
| 1752 | """Dump NAT virtual fragmentation reassemblies |
| 1753 | |
| 1754 | :return: Dictionary of NAT virtual fragmentation reassemblies |
| 1755 | """ |
| 1756 | return self.api(self.papi.nat_reass_dump, {}) |
| 1757 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1758 | def nat_det_add_del_map( |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1759 | self, |
| 1760 | in_addr, |
| 1761 | in_plen, |
| 1762 | out_addr, |
| 1763 | out_plen, |
| 1764 | is_add=1): |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1765 | """Add/delete deterministic NAT mapping |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1766 | |
| 1767 | :param is_add - 1 if add, 0 if delete |
| 1768 | :param in_addr - inside IP address |
| 1769 | :param in_plen - inside IP address prefix length |
| 1770 | :param out_addr - outside IP address |
| 1771 | :param out_plen - outside IP address prefix length |
| 1772 | """ |
| 1773 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1774 | self.papi.nat_det_add_del_map, |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1775 | {'is_add': is_add, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1776 | 'is_nat44': 1, |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1777 | 'in_addr': in_addr, |
| 1778 | 'in_plen': in_plen, |
| 1779 | 'out_addr': out_addr, |
| 1780 | 'out_plen': out_plen}) |
| 1781 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1782 | def nat_det_forward( |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1783 | self, |
| 1784 | in_addr): |
| 1785 | """Get outside address and port range from inside address |
| 1786 | |
| 1787 | :param in_addr - inside IP address |
| 1788 | """ |
| 1789 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1790 | self.papi.nat_det_forward, |
| 1791 | {'in_addr': in_addr, |
| 1792 | 'is_nat44': 1}) |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1793 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1794 | def nat_det_reverse( |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1795 | self, |
| 1796 | out_addr, |
| 1797 | out_port): |
| 1798 | """Get inside address from outside address and port |
| 1799 | |
| 1800 | :param out_addr - outside IP address |
| 1801 | :param out_port - outside port |
| 1802 | """ |
| 1803 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1804 | self.papi.nat_det_reverse, |
Matus Fabian | 066f034 | 2017-02-10 03:48:01 -0800 | [diff] [blame] | 1805 | {'out_addr': out_addr, |
| 1806 | 'out_port': out_port}) |
| 1807 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1808 | def nat_det_map_dump(self): |
| 1809 | """Dump deterministic NAT mappings |
Martin | 17a75cb | 2017-03-08 05:53:20 -0800 | [diff] [blame] | 1810 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1811 | :return: Dictionary of deterministic NAT mappings |
Martin | 17a75cb | 2017-03-08 05:53:20 -0800 | [diff] [blame] | 1812 | """ |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1813 | return self.api(self.papi.nat_det_map_dump, {}) |
Martin | 17a75cb | 2017-03-08 05:53:20 -0800 | [diff] [blame] | 1814 | |
Matus Fabian | 878c646 | 2018-08-23 00:33:35 -0700 | [diff] [blame] | 1815 | def nat_set_timeouts( |
Matus Fabian | 6a0946f | 2017-04-12 03:36:13 -0700 | [diff] [blame] | 1816 | self, |
| 1817 | udp=300, |
| 1818 | tcp_established=7440, |
| 1819 | tcp_transitory=240, |
| 1820 | icmp=60): |
Matus Fabian | 878c646 | 2018-08-23 00:33:35 -0700 | [diff] [blame] | 1821 | """Set values of timeouts for NAT sessions (in seconds) |
Matus Fabian | 6a0946f | 2017-04-12 03:36:13 -0700 | [diff] [blame] | 1822 | |
| 1823 | :param udp - UDP timeout (Default value = 300) |
| 1824 | :param tcp_established - TCP established timeout (Default value = 7440) |
| 1825 | :param tcp_transitory - TCP transitory timeout (Default value = 240) |
| 1826 | :param icmp - ICMP timeout (Default value = 60) |
| 1827 | """ |
| 1828 | return self.api( |
Matus Fabian | 878c646 | 2018-08-23 00:33:35 -0700 | [diff] [blame] | 1829 | self.papi.nat_set_timeouts, |
Matus Fabian | 6a0946f | 2017-04-12 03:36:13 -0700 | [diff] [blame] | 1830 | {'udp': udp, |
| 1831 | 'tcp_established': tcp_established, |
| 1832 | 'tcp_transitory': tcp_transitory, |
| 1833 | 'icmp': icmp}) |
| 1834 | |
Matus Fabian | 878c646 | 2018-08-23 00:33:35 -0700 | [diff] [blame] | 1835 | def nat_get_timeouts(self): |
| 1836 | """Get values of timeouts for NAT sessions |
Matus Fabian | 6a0946f | 2017-04-12 03:36:13 -0700 | [diff] [blame] | 1837 | |
Matus Fabian | 878c646 | 2018-08-23 00:33:35 -0700 | [diff] [blame] | 1838 | :return: Timeouts for NAT sessions (in seconds) |
Matus Fabian | 6a0946f | 2017-04-12 03:36:13 -0700 | [diff] [blame] | 1839 | """ |
Matus Fabian | 878c646 | 2018-08-23 00:33:35 -0700 | [diff] [blame] | 1840 | return self.api(self.papi.nat_get_timeouts, {}) |
Matus Fabian | 6a0946f | 2017-04-12 03:36:13 -0700 | [diff] [blame] | 1841 | |
Matus Fabian | 5d28c7a | 2018-09-04 03:55:45 -0700 | [diff] [blame] | 1842 | def nat_set_addr_and_port_alloc_alg( |
| 1843 | self, |
| 1844 | alg=0, |
| 1845 | psid_offset=0, |
| 1846 | psid_length=0, |
| 1847 | psid=0, |
| 1848 | start_port=0, |
| 1849 | end_port=0): |
| 1850 | """Set address and port assignment algorithm |
| 1851 | |
| 1852 | :param alg: algorithm: 0 - default, 1 - MAP-E, 2 - port range |
| 1853 | :param psid_offset: number of offset bits (valid only for MAP-E alg) |
| 1854 | :param psid_length: length of PSID (valid only for MAP-E alg) |
| 1855 | :param psid: Port Set Identifier value (valid only for MAP-E alg) |
| 1856 | :param start_port: beginning of the port range |
| 1857 | :param end_port: end of the port range |
| 1858 | """ |
| 1859 | return self.api( |
| 1860 | self.papi.nat_set_addr_and_port_alloc_alg, |
| 1861 | {'alg': alg, |
| 1862 | 'psid_offset': psid_offset, |
| 1863 | 'psid_length': psid_length, |
| 1864 | 'psid': psid, |
| 1865 | 'start_port': start_port, |
| 1866 | 'end_port': end_port}) |
| 1867 | |
| 1868 | def nat_get_addr_and_port_alloc_alg(self): |
| 1869 | """Get address and port assignment algorithm""" |
| 1870 | return self.api(self.papi.nat_get_addr_and_port_alloc_alg, {}) |
| 1871 | |
Matus Fabian | bb4e022 | 2018-09-13 02:36:25 -0700 | [diff] [blame] | 1872 | def nat_set_mss_clamping(self, enable=0, mss_value=1500): |
| 1873 | """Set TCP MSS rewriting configuration |
| 1874 | |
| 1875 | :param enable: disable(0)/enable(1) MSS rewriting feature |
| 1876 | :param mss_value: MSS value to be used for MSS rewriting |
| 1877 | """ |
| 1878 | return self.api( |
| 1879 | self.papi.nat_set_mss_clamping, |
| 1880 | {'enable': enable, 'mss_value': mss_value}) |
| 1881 | |
| 1882 | def nat_get_mss_clamping(self): |
| 1883 | """Get TCP MSS rewriting configuration""" |
| 1884 | return self.api(self.papi.nat_get_mss_clamping, {}) |
| 1885 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1886 | def nat_det_close_session_out( |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1887 | self, |
| 1888 | out_addr, |
| 1889 | out_port, |
| 1890 | ext_addr, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1891 | ext_port): |
| 1892 | """Close deterministic NAT session using outside address and port |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1893 | |
| 1894 | :param out_addr - outside IP address |
| 1895 | :param out_port - outside port |
| 1896 | :param ext_addr - external host IP address |
| 1897 | :param ext_port - external host port |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1898 | """ |
| 1899 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1900 | self.papi.nat_det_close_session_out, |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1901 | {'out_addr': out_addr, |
| 1902 | 'out_port': out_port, |
| 1903 | 'ext_addr': ext_addr, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1904 | 'ext_port': ext_port}) |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1905 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1906 | def nat_det_close_session_in( |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1907 | self, |
| 1908 | in_addr, |
| 1909 | in_port, |
| 1910 | ext_addr, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1911 | ext_port): |
| 1912 | """Close deterministic NAT session using inside address and port |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1913 | |
| 1914 | :param in_addr - inside IP address |
| 1915 | :param in_port - inside port |
| 1916 | :param ext_addr - external host IP address |
| 1917 | :param ext_port - external host port |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1918 | """ |
| 1919 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1920 | self.papi.nat_det_close_session_in, |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1921 | {'in_addr': in_addr, |
| 1922 | 'in_port': in_port, |
| 1923 | 'ext_addr': ext_addr, |
| 1924 | 'ext_port': ext_port, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1925 | 'is_nat44': 1}) |
Martin Gálik | 6bc8c64 | 2017-04-19 01:12:27 -0700 | [diff] [blame] | 1926 | |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1927 | def nat_det_session_dump( |
Martin Gálik | 9806eae | 2017-04-25 01:25:08 -0700 | [diff] [blame] | 1928 | self, |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1929 | user_addr): |
| 1930 | """Dump deterministic NAT sessions belonging to a user |
Martin Gálik | 9806eae | 2017-04-25 01:25:08 -0700 | [diff] [blame] | 1931 | |
| 1932 | :param user_addr - inside IP address of the user |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1933 | :return: Dictionary of deterministic NAT sessions |
Martin Gálik | 9806eae | 2017-04-25 01:25:08 -0700 | [diff] [blame] | 1934 | """ |
| 1935 | return self.api( |
Matus Fabian | 2ba92e3 | 2017-08-21 07:05:03 -0700 | [diff] [blame] | 1936 | self.papi.nat_det_session_dump, |
| 1937 | {'is_nat44': 1, |
Martin Gálik | 9806eae | 2017-04-25 01:25:08 -0700 | [diff] [blame] | 1938 | 'user_addr': user_addr}) |
| 1939 | |
Matus Fabian | 06596c5 | 2017-06-06 04:53:28 -0700 | [diff] [blame] | 1940 | def nat64_add_del_pool_addr_range( |
| 1941 | self, |
| 1942 | start_addr, |
| 1943 | end_addr, |
| 1944 | vrf_id=0xFFFFFFFF, |
| 1945 | is_add=1): |
| 1946 | """Add/del address range to NAT64 pool |
| 1947 | |
| 1948 | :param start_addr: First IP address |
| 1949 | :param end_addr: Last IP address |
| 1950 | :param vrf_id: VRF id for the address range |
| 1951 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 1952 | """ |
| 1953 | return self.api( |
| 1954 | self.papi.nat64_add_del_pool_addr_range, |
| 1955 | {'start_addr': start_addr, |
| 1956 | 'end_addr': end_addr, |
| 1957 | 'vrf_id': vrf_id, |
| 1958 | 'is_add': is_add}) |
| 1959 | |
| 1960 | def nat64_pool_addr_dump(self): |
| 1961 | """Dump NAT64 pool addresses |
| 1962 | :return: Dictionary of NAT64 pool addresses |
| 1963 | """ |
| 1964 | return self.api(self.papi.nat64_pool_addr_dump, {}) |
| 1965 | |
| 1966 | def nat64_add_del_interface( |
| 1967 | self, |
| 1968 | sw_if_index, |
| 1969 | is_inside=1, |
| 1970 | is_add=1): |
| 1971 | """Enable/disable NAT64 feature on the interface |
| 1972 | :param sw_if_index: Index of the interface |
| 1973 | :param is_inside: 1 if inside, 0 if outside (Default value = 1) |
| 1974 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 1975 | """ |
| 1976 | return self.api( |
| 1977 | self.papi.nat64_add_del_interface, |
| 1978 | {'sw_if_index': sw_if_index, |
| 1979 | 'is_inside': is_inside, |
| 1980 | 'is_add': is_add}) |
| 1981 | |
| 1982 | def nat64_interface_dump(self): |
| 1983 | """Dump interfaces with NAT64 feature |
| 1984 | :return: Dictionary of interfaces with NAT64 feature |
| 1985 | """ |
| 1986 | return self.api(self.papi.nat64_interface_dump, {}) |
| 1987 | |
| 1988 | def nat64_add_del_static_bib( |
| 1989 | self, |
| 1990 | in_ip, |
| 1991 | out_ip, |
| 1992 | in_port, |
| 1993 | out_port, |
| 1994 | protocol, |
| 1995 | vrf_id=0, |
| 1996 | is_add=1): |
| 1997 | """Add/delete S-NAT static BIB entry |
| 1998 | |
| 1999 | :param in_ip: Inside IPv6 address |
| 2000 | :param out_ip: Outside IPv4 address |
| 2001 | :param in_port: Inside port number |
| 2002 | :param out_port: Outside port number |
| 2003 | :param protocol: IP protocol |
| 2004 | :param vrf_id: VRF ID (Default value = 0) |
| 2005 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 2006 | """ |
| 2007 | return self.api( |
| 2008 | self.papi.nat64_add_del_static_bib, |
| 2009 | {'i_addr': in_ip, |
| 2010 | 'o_addr': out_ip, |
| 2011 | 'i_port': in_port, |
| 2012 | 'o_port': out_port, |
| 2013 | 'vrf_id': vrf_id, |
| 2014 | 'proto': protocol, |
| 2015 | 'is_add': is_add}) |
| 2016 | |
Matus Fabian | ab9a59c | 2017-08-16 05:37:36 -0700 | [diff] [blame] | 2017 | def nat64_bib_dump(self, protocol=255): |
Matus Fabian | 06596c5 | 2017-06-06 04:53:28 -0700 | [diff] [blame] | 2018 | """Dump NAT64 BIB |
| 2019 | |
Matus Fabian | ab9a59c | 2017-08-16 05:37:36 -0700 | [diff] [blame] | 2020 | :param protocol: IP protocol (Default value = 255, all BIBs) |
Matus Fabian | 06596c5 | 2017-06-06 04:53:28 -0700 | [diff] [blame] | 2021 | :returns: Dictionary of NAT64 BIB entries |
| 2022 | """ |
| 2023 | return self.api(self.papi.nat64_bib_dump, {'proto': protocol}) |
| 2024 | |
| 2025 | def nat64_set_timeouts(self, udp=300, icmp=60, tcp_trans=240, tcp_est=7440, |
| 2026 | tcp_incoming_syn=6): |
| 2027 | """Set values of timeouts for NAT64 (in seconds) |
| 2028 | |
Matus Fabian | 428dc91 | 2017-06-21 06:15:18 -0700 | [diff] [blame] | 2029 | :param udpi: UDP timeout (Default value = 300) |
| 2030 | :param icmp: ICMP timeout (Default value = 60) |
| 2031 | :param tcp_trans: TCP transitory timeout (Default value = 240) |
| 2032 | :param tcp_est: TCP established timeout (Default value = 7440) |
| 2033 | :param tcp_incoming_syn: TCP incoming SYN timeout (Default value = 6) |
Matus Fabian | 06596c5 | 2017-06-06 04:53:28 -0700 | [diff] [blame] | 2034 | """ |
| 2035 | return self.api( |
| 2036 | self.papi.nat64_set_timeouts, |
| 2037 | {'udp': udp, |
| 2038 | 'icmp': icmp, |
| 2039 | 'tcp_trans': tcp_trans, |
| 2040 | 'tcp_est': tcp_est, |
| 2041 | 'tcp_incoming_syn': tcp_incoming_syn}) |
| 2042 | |
| 2043 | def nat64_get_timeouts(self): |
| 2044 | """Get values of timeouts for NAT64 |
| 2045 | |
| 2046 | :return: Timeouts for NAT64 (in seconds) |
| 2047 | """ |
| 2048 | return self.api(self.papi.nat64_get_timeouts, {}) |
| 2049 | |
Matus Fabian | ab9a59c | 2017-08-16 05:37:36 -0700 | [diff] [blame] | 2050 | def nat64_st_dump(self, protocol=255): |
Matus Fabian | 06596c5 | 2017-06-06 04:53:28 -0700 | [diff] [blame] | 2051 | """Dump NAT64 session table |
| 2052 | |
Matus Fabian | ab9a59c | 2017-08-16 05:37:36 -0700 | [diff] [blame] | 2053 | :param protocol: IP protocol (Default value = 255, all STs) |
Matus Fabian | 06596c5 | 2017-06-06 04:53:28 -0700 | [diff] [blame] | 2054 | :returns: Dictionary of NAT64 sesstion table entries |
| 2055 | """ |
| 2056 | return self.api(self.papi.nat64_st_dump, {'proto': protocol}) |
| 2057 | |
Matus Fabian | 428dc91 | 2017-06-21 06:15:18 -0700 | [diff] [blame] | 2058 | def nat64_add_del_prefix(self, prefix, plen, vrf_id=0, is_add=1): |
| 2059 | """Add/del NAT64 prefix |
| 2060 | |
| 2061 | :param prefix: NAT64 prefix |
| 2062 | :param plen: NAT64 prefix length |
| 2063 | :param vrf_id: VRF id of tenant (Default 0) |
| 2064 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 2065 | """ |
| 2066 | return self.api( |
| 2067 | self.papi.nat64_add_del_prefix, |
| 2068 | {'prefix': prefix, |
| 2069 | 'prefix_len': plen, |
| 2070 | 'vrf_id': vrf_id, |
| 2071 | 'is_add': is_add}) |
| 2072 | |
| 2073 | def nat64_prefix_dump(self): |
| 2074 | """Dump NAT64 prefix |
| 2075 | |
| 2076 | :returns: Dictionary of NAT64 prefixes |
| 2077 | """ |
| 2078 | return self.api(self.papi.nat64_prefix_dump, {}) |
| 2079 | |
Matus Fabian | 0938dcf | 2017-11-08 01:59:38 -0800 | [diff] [blame] | 2080 | def nat64_add_interface_addr( |
| 2081 | self, |
| 2082 | sw_if_index, |
| 2083 | is_add=1): |
| 2084 | """Add/del NAT64 address from interface |
| 2085 | |
| 2086 | :param sw_if_index: Software index of the interface |
| 2087 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 2088 | """ |
| 2089 | return self.api(self.papi.nat64_add_del_interface_addr, |
| 2090 | {'is_add': is_add, 'sw_if_index': sw_if_index}) |
| 2091 | |
Matus Fabian | 8ebe625 | 2017-11-06 05:04:53 -0800 | [diff] [blame] | 2092 | def dslite_set_aftr_addr(self, ip6, ip4): |
| 2093 | """Set DS-Lite AFTR addresses |
| 2094 | |
| 2095 | :param ip4: IPv4 address |
| 2096 | :param ip6: IPv6 address |
| 2097 | """ |
| 2098 | return self.api( |
| 2099 | self.papi.dslite_set_aftr_addr, |
| 2100 | {'ip4_addr': ip4, |
| 2101 | 'ip6_addr': ip6}) |
| 2102 | |
Juraj Sloboda | c5c6a33 | 2018-01-09 16:08:32 +0100 | [diff] [blame] | 2103 | def dslite_set_b4_addr(self, ip6, ip4): |
| 2104 | """Set DS-Lite B4 IPv6 address |
| 2105 | |
| 2106 | :param ip4: IPv4 address |
| 2107 | :param ip6: IPv6 address |
| 2108 | """ |
| 2109 | return self.api( |
| 2110 | self.papi.dslite_set_b4_addr, |
| 2111 | {'ip4_addr': ip4, |
| 2112 | 'ip6_addr': ip6}) |
| 2113 | |
Matus Fabian | 8ebe625 | 2017-11-06 05:04:53 -0800 | [diff] [blame] | 2114 | def dslite_add_del_pool_addr_range( |
| 2115 | self, |
| 2116 | start_addr, |
| 2117 | end_addr, |
| 2118 | is_add=1): |
| 2119 | """Add/del address range to DS-Lite pool |
| 2120 | |
| 2121 | :param start_addr: First IP address |
| 2122 | :param end_addr: Last IP address |
| 2123 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 2124 | """ |
| 2125 | return self.api( |
| 2126 | self.papi.dslite_add_del_pool_addr_range, |
| 2127 | {'start_addr': start_addr, |
| 2128 | 'end_addr': end_addr, |
| 2129 | 'is_add': is_add}) |
| 2130 | |
Matus Fabian | f2a23cc | 2018-01-22 03:41:53 -0800 | [diff] [blame] | 2131 | def nat66_add_del_interface( |
| 2132 | self, |
| 2133 | sw_if_index, |
| 2134 | is_inside=1, |
| 2135 | is_add=1): |
| 2136 | """Enable/disable NAT66 feature on the interface |
| 2137 | :param sw_if_index: Index of the interface |
| 2138 | :param is_inside: 1 if inside, 0 if outside (Default value = 1) |
| 2139 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 2140 | """ |
| 2141 | return self.api( |
| 2142 | self.papi.nat66_add_del_interface, |
| 2143 | {'sw_if_index': sw_if_index, |
| 2144 | 'is_inside': is_inside, |
| 2145 | 'is_add': is_add}) |
| 2146 | |
| 2147 | def nat66_add_del_static_mapping( |
| 2148 | self, |
| 2149 | in_ip, |
| 2150 | out_ip, |
| 2151 | vrf_id=0, |
| 2152 | is_add=1): |
| 2153 | """Add/delete NAT66 static mapping |
| 2154 | |
| 2155 | :param in_ip: Inside IPv6 address |
| 2156 | :param out_ip: Outside IPv6 address |
| 2157 | :param vrf_id: VRF ID (Default value = 0) |
| 2158 | :param is_add: 1 if add, 0 if delete (Default value = 1) |
| 2159 | """ |
| 2160 | return self.api( |
| 2161 | self.papi.nat66_add_del_static_mapping, |
| 2162 | {'local_ip_address': in_ip, |
| 2163 | 'external_ip_address': out_ip, |
| 2164 | 'vrf_id': vrf_id, |
| 2165 | 'is_add': is_add}) |
| 2166 | |
| 2167 | def nat66_interface_dump(self): |
| 2168 | """Dump interfaces with NAT66 feature |
| 2169 | :return: Dictionary of interfaces with NAT66 feature |
| 2170 | """ |
| 2171 | return self.api(self.papi.nat66_interface_dump, {}) |
| 2172 | |
| 2173 | def nat66_static_mapping_dump(self): |
| 2174 | """Dump NAT66 static mappings |
| 2175 | :return: Dictionary of NAT66 static mappings |
| 2176 | """ |
| 2177 | return self.api(self.papi.nat66_static_mapping_dump, {}) |
| 2178 | |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 2179 | def control_ping(self): |
| 2180 | self.api(self.papi.control_ping) |
| 2181 | |
| 2182 | def bfd_udp_add(self, sw_if_index, desired_min_tx, required_min_rx, |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 2183 | detect_mult, local_addr, peer_addr, is_ipv6=0, |
| 2184 | bfd_key_id=None, conf_key_id=None): |
| 2185 | if bfd_key_id is None: |
| 2186 | return self.api(self.papi.bfd_udp_add, |
| 2187 | { |
| 2188 | 'sw_if_index': sw_if_index, |
| 2189 | 'desired_min_tx': desired_min_tx, |
| 2190 | 'required_min_rx': required_min_rx, |
| 2191 | 'local_addr': local_addr, |
| 2192 | 'peer_addr': peer_addr, |
| 2193 | 'is_ipv6': is_ipv6, |
| 2194 | 'detect_mult': detect_mult, |
| 2195 | }) |
| 2196 | else: |
| 2197 | return self.api(self.papi.bfd_udp_add, |
| 2198 | { |
| 2199 | 'sw_if_index': sw_if_index, |
| 2200 | 'desired_min_tx': desired_min_tx, |
| 2201 | 'required_min_rx': required_min_rx, |
| 2202 | 'local_addr': local_addr, |
| 2203 | 'peer_addr': peer_addr, |
| 2204 | 'is_ipv6': is_ipv6, |
| 2205 | 'detect_mult': detect_mult, |
| 2206 | 'is_authenticated': 1, |
| 2207 | 'bfd_key_id': bfd_key_id, |
| 2208 | 'conf_key_id': conf_key_id, |
| 2209 | }) |
| 2210 | |
Klement Sekera | a57a970 | 2017-02-02 06:58:07 +0100 | [diff] [blame] | 2211 | def bfd_udp_mod(self, sw_if_index, desired_min_tx, required_min_rx, |
| 2212 | detect_mult, local_addr, peer_addr, is_ipv6=0): |
| 2213 | return self.api(self.papi.bfd_udp_mod, |
| 2214 | { |
| 2215 | 'sw_if_index': sw_if_index, |
| 2216 | 'desired_min_tx': desired_min_tx, |
| 2217 | 'required_min_rx': required_min_rx, |
| 2218 | 'local_addr': local_addr, |
| 2219 | 'peer_addr': peer_addr, |
| 2220 | 'is_ipv6': is_ipv6, |
| 2221 | 'detect_mult': detect_mult, |
| 2222 | }) |
| 2223 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 2224 | def bfd_udp_auth_activate(self, sw_if_index, local_addr, peer_addr, |
| 2225 | is_ipv6=0, bfd_key_id=None, conf_key_id=None, |
| 2226 | is_delayed=False): |
| 2227 | return self.api(self.papi.bfd_udp_auth_activate, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 2228 | { |
| 2229 | 'sw_if_index': sw_if_index, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 2230 | 'local_addr': local_addr, |
| 2231 | 'peer_addr': peer_addr, |
| 2232 | 'is_ipv6': is_ipv6, |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 2233 | 'is_delayed': 1 if is_delayed else 0, |
| 2234 | 'bfd_key_id': bfd_key_id, |
| 2235 | 'conf_key_id': conf_key_id, |
| 2236 | }) |
| 2237 | |
| 2238 | def bfd_udp_auth_deactivate(self, sw_if_index, local_addr, peer_addr, |
| 2239 | is_ipv6=0, is_delayed=False): |
| 2240 | return self.api(self.papi.bfd_udp_auth_deactivate, |
| 2241 | { |
| 2242 | 'sw_if_index': sw_if_index, |
| 2243 | 'local_addr': local_addr, |
| 2244 | 'peer_addr': peer_addr, |
| 2245 | 'is_ipv6': is_ipv6, |
| 2246 | 'is_delayed': 1 if is_delayed else 0, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 2247 | }) |
| 2248 | |
| 2249 | def bfd_udp_del(self, sw_if_index, local_addr, peer_addr, is_ipv6=0): |
| 2250 | return self.api(self.papi.bfd_udp_del, |
| 2251 | { |
| 2252 | 'sw_if_index': sw_if_index, |
| 2253 | 'local_addr': local_addr, |
| 2254 | 'peer_addr': peer_addr, |
| 2255 | 'is_ipv6': is_ipv6, |
| 2256 | }) |
| 2257 | |
| 2258 | def bfd_udp_session_dump(self): |
| 2259 | return self.api(self.papi.bfd_udp_session_dump, {}) |
| 2260 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 2261 | def bfd_udp_session_set_flags(self, admin_up_down, sw_if_index, local_addr, |
| 2262 | peer_addr, is_ipv6=0): |
| 2263 | return self.api(self.papi.bfd_udp_session_set_flags, { |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 2264 | 'admin_up_down': admin_up_down, |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 2265 | 'sw_if_index': sw_if_index, |
| 2266 | 'local_addr': local_addr, |
| 2267 | 'peer_addr': peer_addr, |
| 2268 | 'is_ipv6': is_ipv6, |
Klement Sekera | 0e3c0de | 2016-09-29 14:43:44 +0200 | [diff] [blame] | 2269 | }) |
| 2270 | |
| 2271 | def want_bfd_events(self, enable_disable=1): |
| 2272 | return self.api(self.papi.want_bfd_events, { |
| 2273 | 'enable_disable': enable_disable, |
| 2274 | 'pid': os.getpid(), |
| 2275 | }) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2276 | |
Klement Sekera | b17dd96 | 2017-01-09 07:43:48 +0100 | [diff] [blame] | 2277 | def bfd_auth_set_key(self, conf_key_id, auth_type, key): |
| 2278 | return self.api(self.papi.bfd_auth_set_key, { |
| 2279 | 'conf_key_id': conf_key_id, |
| 2280 | 'auth_type': auth_type, |
| 2281 | 'key': key, |
| 2282 | 'key_len': len(key), |
| 2283 | }) |
| 2284 | |
| 2285 | def bfd_auth_del_key(self, conf_key_id): |
| 2286 | return self.api(self.papi.bfd_auth_del_key, { |
| 2287 | 'conf_key_id': conf_key_id, |
| 2288 | }) |
| 2289 | |
| 2290 | def bfd_auth_keys_dump(self): |
| 2291 | return self.api(self.papi.bfd_auth_keys_dump, {}) |
| 2292 | |
Klement Sekera | 239790f | 2017-02-16 10:53:53 +0100 | [diff] [blame] | 2293 | def bfd_udp_set_echo_source(self, sw_if_index): |
| 2294 | return self.api(self.papi.bfd_udp_set_echo_source, |
| 2295 | {'sw_if_index': sw_if_index}) |
| 2296 | |
Klement Sekera | 7388448 | 2017-02-23 09:26:30 +0100 | [diff] [blame] | 2297 | def bfd_udp_del_echo_source(self): |
| 2298 | return self.api(self.papi.bfd_udp_del_echo_source, {}) |
| 2299 | |
Matus Fabian | 2d3c7b9 | 2018-10-02 03:22:18 -0700 | [diff] [blame] | 2300 | def bfd_udp_get_echo_source(self): |
| 2301 | return self.api(self.papi.bfd_udp_get_echo_source, {}) |
| 2302 | |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2303 | def classify_add_del_table( |
| 2304 | self, |
| 2305 | is_add, |
| 2306 | mask, |
| 2307 | match_n_vectors=1, |
| 2308 | table_index=0xFFFFFFFF, |
| 2309 | nbuckets=2, |
| 2310 | memory_size=2097152, |
| 2311 | skip_n_vectors=0, |
| 2312 | next_table_index=0xFFFFFFFF, |
| 2313 | miss_next_index=0xFFFFFFFF, |
| 2314 | current_data_flag=0, |
| 2315 | current_data_offset=0): |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2316 | """ |
| 2317 | :param is_add: |
| 2318 | :param mask: |
Klement Sekera | da505f6 | 2017-01-04 12:58:53 +0100 | [diff] [blame] | 2319 | :param match_n_vectors: (Default value = 1) |
Matej Klotton | 8d8a1da | 2016-12-22 11:06:56 +0100 | [diff] [blame] | 2320 | :param table_index: (Default value = 0xFFFFFFFF) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2321 | :param nbuckets: (Default value = 2) |
| 2322 | :param memory_size: (Default value = 2097152) |
| 2323 | :param skip_n_vectors: (Default value = 0) |
| 2324 | :param next_table_index: (Default value = 0xFFFFFFFF) |
| 2325 | :param miss_next_index: (Default value = 0xFFFFFFFF) |
| 2326 | :param current_data_flag: (Default value = 0) |
| 2327 | :param current_data_offset: (Default value = 0) |
| 2328 | """ |
| 2329 | |
Juraj Sloboda | 7528245 | 2018-06-12 14:20:49 +0200 | [diff] [blame] | 2330 | mask_len = ((len(mask) - 1) / 16 + 1) * 16 |
| 2331 | mask = mask + '\0' * (mask_len - len(mask)) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2332 | return self.api( |
| 2333 | self.papi.classify_add_del_table, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 2334 | {'is_add': is_add, |
| 2335 | 'table_index': table_index, |
| 2336 | 'nbuckets': nbuckets, |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2337 | 'memory_size': memory_size, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 2338 | 'skip_n_vectors': skip_n_vectors, |
| 2339 | 'match_n_vectors': match_n_vectors, |
| 2340 | 'next_table_index': next_table_index, |
| 2341 | 'miss_next_index': miss_next_index, |
| 2342 | 'current_data_flag': current_data_flag, |
| 2343 | 'current_data_offset': current_data_offset, |
Juraj Sloboda | 7528245 | 2018-06-12 14:20:49 +0200 | [diff] [blame] | 2344 | 'mask_len': mask_len, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 2345 | 'mask': mask}) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2346 | |
| 2347 | def classify_add_del_session( |
| 2348 | self, |
| 2349 | is_add, |
| 2350 | table_index, |
| 2351 | match, |
| 2352 | opaque_index=0xFFFFFFFF, |
| 2353 | hit_next_index=0xFFFFFFFF, |
| 2354 | advance=0, |
| 2355 | action=0, |
| 2356 | metadata=0): |
| 2357 | """ |
| 2358 | :param is_add: |
| 2359 | :param table_index: |
| 2360 | :param match: |
| 2361 | :param opaque_index: (Default value = 0xFFFFFFFF) |
| 2362 | :param hit_next_index: (Default value = 0xFFFFFFFF) |
| 2363 | :param advance: (Default value = 0) |
| 2364 | :param action: (Default value = 0) |
| 2365 | :param metadata: (Default value = 0) |
| 2366 | """ |
| 2367 | |
Juraj Sloboda | 7528245 | 2018-06-12 14:20:49 +0200 | [diff] [blame] | 2368 | match_len = ((len(match) - 1) / 16 + 1) * 16 |
| 2369 | match = match + '\0' * (match_len - len(match)) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2370 | return self.api( |
| 2371 | self.papi.classify_add_del_session, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 2372 | {'is_add': is_add, |
| 2373 | 'table_index': table_index, |
| 2374 | 'hit_next_index': hit_next_index, |
| 2375 | 'opaque_index': opaque_index, |
| 2376 | 'advance': advance, |
| 2377 | 'action': action, |
| 2378 | 'metadata': metadata, |
Juraj Sloboda | 7528245 | 2018-06-12 14:20:49 +0200 | [diff] [blame] | 2379 | 'match_len': match_len, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 2380 | 'match': match}) |
Steve Shin | 7957d6e | 2016-12-19 09:24:50 -0800 | [diff] [blame] | 2381 | |
| 2382 | def input_acl_set_interface( |
| 2383 | self, |
| 2384 | is_add, |
| 2385 | sw_if_index, |
| 2386 | ip4_table_index=0xFFFFFFFF, |
| 2387 | ip6_table_index=0xFFFFFFFF, |
| 2388 | l2_table_index=0xFFFFFFFF): |
| 2389 | """ |
| 2390 | :param is_add: |
| 2391 | :param sw_if_index: |
| 2392 | :param ip4_table_index: (Default value = 0xFFFFFFFF) |
| 2393 | :param ip6_table_index: (Default value = 0xFFFFFFFF) |
| 2394 | :param l2_table_index: (Default value = 0xFFFFFFFF) |
| 2395 | """ |
| 2396 | |
| 2397 | return self.api( |
| 2398 | self.papi.input_acl_set_interface, |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 2399 | {'sw_if_index': sw_if_index, |
| 2400 | 'ip4_table_index': ip4_table_index, |
| 2401 | 'ip6_table_index': ip6_table_index, |
| 2402 | 'l2_table_index': l2_table_index, |
| 2403 | 'is_add': is_add}) |
| 2404 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 2405 | def output_acl_set_interface( |
| 2406 | self, |
| 2407 | is_add, |
| 2408 | sw_if_index, |
| 2409 | ip4_table_index=0xFFFFFFFF, |
| 2410 | ip6_table_index=0xFFFFFFFF, |
| 2411 | l2_table_index=0xFFFFFFFF): |
| 2412 | """ |
| 2413 | :param is_add: |
| 2414 | :param sw_if_index: |
| 2415 | :param ip4_table_index: (Default value = 0xFFFFFFFF) |
| 2416 | :param ip6_table_index: (Default value = 0xFFFFFFFF) |
| 2417 | :param l2_table_index: (Default value = 0xFFFFFFFF) |
| 2418 | """ |
| 2419 | |
| 2420 | return self.api( |
| 2421 | self.papi.output_acl_set_interface, |
| 2422 | {'sw_if_index': sw_if_index, |
| 2423 | 'ip4_table_index': ip4_table_index, |
| 2424 | 'ip6_table_index': ip6_table_index, |
| 2425 | 'l2_table_index': l2_table_index, |
| 2426 | 'is_add': is_add}) |
| 2427 | |
Klement Sekera | 77fabdb | 2017-01-02 07:46:14 +0100 | [diff] [blame] | 2428 | def set_ipfix_exporter( |
| 2429 | self, |
| 2430 | collector_address, |
| 2431 | src_address, |
| 2432 | path_mtu, |
| 2433 | template_interval, |
| 2434 | vrf_id=0, |
| 2435 | collector_port=4739, |
| 2436 | udp_checksum=0): |
| 2437 | return self.api( |
| 2438 | self.papi.set_ipfix_exporter, |
| 2439 | { |
| 2440 | 'collector_address': collector_address, |
| 2441 | 'collector_port': collector_port, |
| 2442 | 'src_address': src_address, |
| 2443 | 'vrf_id': vrf_id, |
| 2444 | 'path_mtu': path_mtu, |
| 2445 | 'template_interval': template_interval, |
| 2446 | 'udp_checksum': udp_checksum, |
| 2447 | }) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2448 | |
| 2449 | def dhcp_proxy_config(self, |
| 2450 | dhcp_server, |
| 2451 | dhcp_src_address, |
| 2452 | rx_table_id=0, |
| 2453 | server_table_id=0, |
| 2454 | is_add=1, |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 2455 | is_ipv6=0): |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2456 | return self.api( |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 2457 | self.papi.dhcp_proxy_config, |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2458 | { |
| 2459 | 'rx_vrf_id': rx_table_id, |
| 2460 | 'server_vrf_id': server_table_id, |
| 2461 | 'is_ipv6': is_ipv6, |
| 2462 | 'is_add': is_add, |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2463 | 'dhcp_server': dhcp_server, |
| 2464 | 'dhcp_src_address': dhcp_src_address, |
| 2465 | }) |
| 2466 | |
| 2467 | def dhcp_proxy_set_vss(self, |
| 2468 | table_id, |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 2469 | vss_type=255, |
| 2470 | vpn_ascii_id="", |
| 2471 | oui=0, |
| 2472 | vpn_index=0, |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2473 | is_add=1, |
| 2474 | is_ip6=0): |
| 2475 | return self.api( |
| 2476 | self.papi.dhcp_proxy_set_vss, |
| 2477 | { |
| 2478 | 'tbl_id': table_id, |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 2479 | 'vss_type': vss_type, |
| 2480 | 'vpn_ascii_id': vpn_ascii_id, |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2481 | 'oui': oui, |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 2482 | 'vpn_index': vpn_index, |
| 2483 | 'is_add': is_add, |
| 2484 | 'is_ipv6': is_ip6, |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2485 | }) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2486 | |
Neale Ranns | daff178 | 2018-05-16 04:12:18 -0700 | [diff] [blame] | 2487 | def dhcp_client_dump(self): |
| 2488 | return self.api(self.papi.dhcp_client_dump, {}) |
| 2489 | |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 2490 | def dhcp_client(self, |
| 2491 | sw_if_index, |
| 2492 | hostname, |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 2493 | client_id='', |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 2494 | is_add=1, |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 2495 | set_broadcast_flag=1, |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 2496 | want_dhcp_events=0): |
| 2497 | return self.api( |
| 2498 | self.papi.dhcp_client_config, |
| 2499 | { |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 2500 | 'is_add': is_add, |
Neale Ranns | daff178 | 2018-05-16 04:12:18 -0700 | [diff] [blame] | 2501 | 'client': { |
| 2502 | 'sw_if_index': sw_if_index, |
| 2503 | 'hostname': hostname, |
| 2504 | 'id': client_id, |
| 2505 | 'want_dhcp_event': want_dhcp_events, |
| 2506 | 'set_broadcast_flag': set_broadcast_flag, |
| 2507 | 'pid': os.getpid()} |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 2508 | }) |
| 2509 | |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2510 | def ip_mroute_add_del(self, |
| 2511 | src_address, |
| 2512 | grp_address, |
| 2513 | grp_address_length, |
| 2514 | e_flags, |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 2515 | next_hop_afi, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2516 | next_hop_sw_if_index, |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 2517 | next_hop_address, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2518 | i_flags, |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 2519 | bier_imp=0, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 2520 | rpf_id=0, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2521 | table_id=0, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2522 | is_add=1, |
| 2523 | is_ipv6=0, |
| 2524 | is_local=0): |
| 2525 | """ |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 2526 | IP Multicast Route add/del |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2527 | """ |
| 2528 | return self.api( |
| 2529 | self.papi.ip_mroute_add_del, |
| 2530 | {'next_hop_sw_if_index': next_hop_sw_if_index, |
| 2531 | 'entry_flags': e_flags, |
| 2532 | 'itf_flags': i_flags, |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 2533 | 'table_id': table_id, |
| 2534 | 'rpf_id': rpf_id, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2535 | 'is_add': is_add, |
| 2536 | 'is_ipv6': is_ipv6, |
| 2537 | 'is_local': is_local, |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 2538 | 'bier_imp': bier_imp, |
| 2539 | 'next_hop_afi': next_hop_afi, |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2540 | 'grp_address_length': grp_address_length, |
| 2541 | 'grp_address': grp_address, |
Neale Ranns | e821ab1 | 2017-06-01 07:45:05 -0700 | [diff] [blame] | 2542 | 'src_address': src_address, |
| 2543 | 'nh_address': next_hop_address}) |
Neale Ranns | 32e1c01 | 2016-11-22 17:07:28 +0000 | [diff] [blame] | 2544 | |
| 2545 | def mfib_signal_dump(self): |
| 2546 | return self.api(self.papi.mfib_signal_dump, {}) |
Neale Ranns | 5a8123b | 2017-01-26 01:18:23 -0800 | [diff] [blame] | 2547 | |
| 2548 | def ip_mfib_dump(self): |
| 2549 | return self.api(self.papi.ip_mfib_dump, {}) |
Filip Tehlar | 770e89e | 2017-01-31 10:39:16 +0100 | [diff] [blame] | 2550 | |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 2551 | def ip6_mfib_dump(self): |
| 2552 | return self.api(self.papi.ip6_mfib_dump, {}) |
| 2553 | |
Filip Tehlar | 770e89e | 2017-01-31 10:39:16 +0100 | [diff] [blame] | 2554 | def lisp_enable_disable(self, is_enabled): |
| 2555 | return self.api( |
| 2556 | self.papi.lisp_enable_disable, |
| 2557 | { |
| 2558 | 'is_en': is_enabled, |
| 2559 | }) |
| 2560 | |
| 2561 | def lisp_locator_set(self, |
| 2562 | ls_name, |
| 2563 | is_add=1): |
| 2564 | return self.api( |
| 2565 | self.papi.lisp_add_del_locator_set, |
| 2566 | { |
| 2567 | 'is_add': is_add, |
| 2568 | 'locator_set_name': ls_name |
| 2569 | }) |
| 2570 | |
| 2571 | def lisp_locator_set_dump(self): |
| 2572 | return self.api(self.papi.lisp_locator_set_dump, {}) |
| 2573 | |
| 2574 | def lisp_locator(self, |
| 2575 | ls_name, |
| 2576 | sw_if_index, |
| 2577 | priority=1, |
| 2578 | weight=1, |
| 2579 | is_add=1): |
| 2580 | return self.api( |
| 2581 | self.papi.lisp_add_del_locator, |
| 2582 | { |
| 2583 | 'is_add': is_add, |
| 2584 | 'locator_set_name': ls_name, |
| 2585 | 'sw_if_index': sw_if_index, |
| 2586 | 'priority': priority, |
| 2587 | 'weight': weight |
| 2588 | }) |
| 2589 | |
| 2590 | def lisp_locator_dump(self, is_index_set, ls_name=None, ls_index=0): |
| 2591 | return self.api( |
| 2592 | self.papi.lisp_locator_dump, |
| 2593 | { |
| 2594 | 'is_index_set': is_index_set, |
| 2595 | 'ls_name': ls_name, |
| 2596 | 'ls_index': ls_index, |
| 2597 | }) |
| 2598 | |
| 2599 | def lisp_local_mapping(self, |
| 2600 | ls_name, |
| 2601 | eid_type, |
| 2602 | eid, |
| 2603 | prefix_len, |
| 2604 | vni=0, |
| 2605 | key_id=0, |
| 2606 | key="", |
| 2607 | is_add=1): |
| 2608 | return self.api( |
| 2609 | self.papi.lisp_add_del_local_eid, |
| 2610 | { |
| 2611 | 'locator_set_name': ls_name, |
| 2612 | 'is_add': is_add, |
| 2613 | 'eid_type': eid_type, |
| 2614 | 'eid': eid, |
| 2615 | 'prefix_len': prefix_len, |
| 2616 | 'vni': vni, |
| 2617 | 'key_id': key_id, |
| 2618 | 'key': key |
| 2619 | }) |
| 2620 | |
| 2621 | def lisp_eid_table_dump(self, |
| 2622 | eid_set=0, |
| 2623 | prefix_length=0, |
| 2624 | vni=0, |
| 2625 | eid_type=0, |
| 2626 | eid=None, |
| 2627 | filter_opt=0): |
| 2628 | return self.api( |
| 2629 | self.papi.lisp_eid_table_dump, |
| 2630 | { |
| 2631 | 'eid_set': eid_set, |
| 2632 | 'prefix_length': prefix_length, |
| 2633 | 'vni': vni, |
| 2634 | 'eid_type': eid_type, |
| 2635 | 'eid': eid, |
| 2636 | 'filter': filter_opt, |
| 2637 | }) |
| 2638 | |
| 2639 | def lisp_remote_mapping(self, |
| 2640 | eid_type, |
| 2641 | eid, |
| 2642 | eid_prefix_len=0, |
| 2643 | vni=0, |
Ole Troan | 895b6e8 | 2017-10-20 13:28:20 +0200 | [diff] [blame] | 2644 | rlocs=[], |
Filip Tehlar | 770e89e | 2017-01-31 10:39:16 +0100 | [diff] [blame] | 2645 | rlocs_num=0, |
| 2646 | is_src_dst=0, |
| 2647 | is_add=1): |
| 2648 | return self.api( |
| 2649 | self.papi.lisp_add_del_remote_mapping, |
| 2650 | { |
| 2651 | 'is_add': is_add, |
| 2652 | 'eid_type': eid_type, |
| 2653 | 'eid': eid, |
| 2654 | 'eid_len': eid_prefix_len, |
| 2655 | 'rloc_num': rlocs_num, |
| 2656 | 'rlocs': rlocs, |
| 2657 | 'vni': vni, |
| 2658 | 'is_src_dst': is_src_dst, |
| 2659 | }) |
| 2660 | |
| 2661 | def lisp_adjacency(self, |
| 2662 | leid, |
| 2663 | reid, |
| 2664 | leid_len, |
| 2665 | reid_len, |
| 2666 | eid_type, |
| 2667 | is_add=1, |
| 2668 | vni=0): |
| 2669 | return self.api( |
| 2670 | self.papi.lisp_add_del_adjacency, |
| 2671 | { |
| 2672 | 'is_add': is_add, |
| 2673 | 'vni': vni, |
| 2674 | 'eid_type': eid_type, |
| 2675 | 'leid': leid, |
| 2676 | 'reid': reid, |
| 2677 | 'leid_len': leid_len, |
| 2678 | 'reid_len': reid_len, |
| 2679 | }) |
| 2680 | |
| 2681 | def lisp_adjacencies_get(self, vni=0): |
| 2682 | return self.api( |
| 2683 | self.papi.lisp_adjacencies_get, |
| 2684 | { |
| 2685 | 'vni': vni |
| 2686 | }) |
Neale Ranns | 8082380 | 2017-02-20 18:23:41 -0800 | [diff] [blame] | 2687 | |
| 2688 | def map_add_domain(self, |
| 2689 | ip6_prefix, |
| 2690 | ip6_prefix_len, |
| 2691 | ip6_src, |
| 2692 | ip6_src_prefix_len, |
| 2693 | ip4_prefix, |
| 2694 | ip4_prefix_len, |
| 2695 | ea_bits_len=0, |
| 2696 | psid_offset=0, |
| 2697 | psid_length=0, |
| 2698 | is_translation=0, |
Juraj Sloboda | cba6936 | 2017-12-19 02:09:32 +0100 | [diff] [blame] | 2699 | is_rfc6052=0, |
Neale Ranns | 8082380 | 2017-02-20 18:23:41 -0800 | [diff] [blame] | 2700 | mtu=1280): |
| 2701 | return self.api( |
| 2702 | self.papi.map_add_domain, |
| 2703 | { |
| 2704 | 'ip6_prefix': ip6_prefix, |
| 2705 | 'ip6_prefix_len': ip6_prefix_len, |
| 2706 | 'ip4_prefix': ip4_prefix, |
| 2707 | 'ip4_prefix_len': ip4_prefix_len, |
| 2708 | 'ip6_src': ip6_src, |
| 2709 | 'ip6_src_prefix_len': ip6_src_prefix_len, |
| 2710 | 'ea_bits_len': ea_bits_len, |
| 2711 | 'psid_offset': psid_offset, |
| 2712 | 'psid_length': psid_length, |
| 2713 | 'is_translation': is_translation, |
Juraj Sloboda | cba6936 | 2017-12-19 02:09:32 +0100 | [diff] [blame] | 2714 | 'is_rfc6052': is_rfc6052, |
Neale Ranns | 8082380 | 2017-02-20 18:23:41 -0800 | [diff] [blame] | 2715 | 'mtu': mtu |
| 2716 | }) |
Hongjun Ni | ef486b1 | 2017-04-12 19:21:16 +0800 | [diff] [blame] | 2717 | |
| 2718 | def gtpu_add_del_tunnel( |
| 2719 | self, |
| 2720 | src_addr, |
| 2721 | dst_addr, |
| 2722 | is_add=1, |
| 2723 | is_ipv6=0, |
| 2724 | mcast_sw_if_index=0xFFFFFFFF, |
| 2725 | encap_vrf_id=0, |
| 2726 | decap_next_index=0xFFFFFFFF, |
| 2727 | teid=0): |
| 2728 | """ |
| 2729 | |
| 2730 | :param is_add: (Default value = 1) |
| 2731 | :param is_ipv6: (Default value = 0) |
| 2732 | :param src_addr: |
| 2733 | :param dst_addr: |
| 2734 | :param mcast_sw_if_index: (Default value = 0xFFFFFFFF) |
| 2735 | :param encap_vrf_id: (Default value = 0) |
| 2736 | :param decap_next_index: (Default value = 0xFFFFFFFF) |
| 2737 | :param teid: (Default value = 0) |
| 2738 | |
| 2739 | """ |
| 2740 | return self.api(self.papi.gtpu_add_del_tunnel, |
| 2741 | {'is_add': is_add, |
| 2742 | 'is_ipv6': is_ipv6, |
| 2743 | 'src_address': src_addr, |
| 2744 | 'dst_address': dst_addr, |
| 2745 | 'mcast_sw_if_index': mcast_sw_if_index, |
| 2746 | 'encap_vrf_id': encap_vrf_id, |
| 2747 | 'decap_next_index': decap_next_index, |
| 2748 | 'teid': teid}) |
Hongjun Ni | 8a0a0ae | 2017-05-27 20:23:09 +0800 | [diff] [blame] | 2749 | |
| 2750 | def vxlan_gpe_add_del_tunnel( |
| 2751 | self, |
| 2752 | src_addr, |
| 2753 | dst_addr, |
| 2754 | mcast_sw_if_index=0xFFFFFFFF, |
| 2755 | is_add=1, |
| 2756 | is_ipv6=0, |
| 2757 | encap_vrf_id=0, |
| 2758 | decap_vrf_id=0, |
| 2759 | protocol=3, |
| 2760 | vni=0): |
| 2761 | """ |
| 2762 | |
| 2763 | :param local: |
| 2764 | :param remote: |
| 2765 | :param is_add: (Default value = 1) |
| 2766 | :param is_ipv6: (Default value = 0) |
| 2767 | :param encap_vrf_id: (Default value = 0) |
| 2768 | :param decap_vrf_id: (Default value = 0) |
| 2769 | :param mcast_sw_if_index: (Default value = 0xFFFFFFFF) |
| 2770 | :param protocol: (Default value = 3) |
| 2771 | :param vni: (Default value = 0) |
| 2772 | |
| 2773 | """ |
| 2774 | return self.api(self.papi.vxlan_gpe_add_del_tunnel, |
| 2775 | {'is_add': is_add, |
| 2776 | 'is_ipv6': is_ipv6, |
| 2777 | 'local': src_addr, |
| 2778 | 'remote': dst_addr, |
| 2779 | 'mcast_sw_if_index': mcast_sw_if_index, |
| 2780 | 'encap_vrf_id': encap_vrf_id, |
| 2781 | 'decap_vrf_id': decap_vrf_id, |
| 2782 | 'protocol': protocol, |
| 2783 | 'vni': vni}) |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 2784 | |
Neale Ranns | 79a05f5 | 2018-09-11 07:39:43 -0700 | [diff] [blame] | 2785 | def vxlan_gbp_tunnel_add_del( |
Mohsin Kazmi | 61b94c6 | 2018-08-20 18:32:39 +0200 | [diff] [blame] | 2786 | self, |
Neale Ranns | 79a05f5 | 2018-09-11 07:39:43 -0700 | [diff] [blame] | 2787 | src, |
| 2788 | dst, |
Mohsin Kazmi | 61b94c6 | 2018-08-20 18:32:39 +0200 | [diff] [blame] | 2789 | mcast_sw_if_index=0xFFFFFFFF, |
| 2790 | is_add=1, |
| 2791 | is_ipv6=0, |
Neale Ranns | 79a05f5 | 2018-09-11 07:39:43 -0700 | [diff] [blame] | 2792 | encap_table_id=0, |
Mohsin Kazmi | 61b94c6 | 2018-08-20 18:32:39 +0200 | [diff] [blame] | 2793 | vni=0, |
| 2794 | instance=0xFFFFFFFF): |
| 2795 | """ |
| 2796 | |
| 2797 | :param dst_addr: |
| 2798 | :param src_addr: |
| 2799 | :param is_add: (Default value = 1) |
| 2800 | :param is_ipv6: (Default value = 0) |
Neale Ranns | 79a05f5 | 2018-09-11 07:39:43 -0700 | [diff] [blame] | 2801 | :param encap_table_id: (Default value = 0) |
Mohsin Kazmi | 61b94c6 | 2018-08-20 18:32:39 +0200 | [diff] [blame] | 2802 | :param decap_next_index: (Default value = 0xFFFFFFFF) |
| 2803 | :param mcast_sw_if_index: (Default value = 0xFFFFFFFF) |
| 2804 | :param vni: (Default value = 0) |
| 2805 | :param instance: (Default value = 0xFFFFFFFF) |
| 2806 | |
| 2807 | """ |
Neale Ranns | 79a05f5 | 2018-09-11 07:39:43 -0700 | [diff] [blame] | 2808 | return self.api(self.papi.vxlan_gbp_tunnel_add_del, |
Mohsin Kazmi | 61b94c6 | 2018-08-20 18:32:39 +0200 | [diff] [blame] | 2809 | {'is_add': is_add, |
Neale Ranns | 79a05f5 | 2018-09-11 07:39:43 -0700 | [diff] [blame] | 2810 | 'tunnel': { |
| 2811 | 'src': src, |
| 2812 | 'dst': dst, |
| 2813 | 'mcast_sw_if_index': mcast_sw_if_index, |
| 2814 | 'encap_table_id': encap_table_id, |
Neale Ranns | 79a05f5 | 2018-09-11 07:39:43 -0700 | [diff] [blame] | 2815 | 'vni': vni, |
| 2816 | 'instance': instance}}) |
| 2817 | |
| 2818 | def vxlan_gbp_tunnel_dump(self, sw_if_index=0xffffffff): |
| 2819 | return self.api(self.papi.vxlan_gbp_tunnel_dump, |
| 2820 | {'sw_if_index': sw_if_index}) |
Mohsin Kazmi | 61b94c6 | 2018-08-20 18:32:39 +0200 | [diff] [blame] | 2821 | |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 2822 | def pppoe_add_del_session( |
| 2823 | self, |
| 2824 | client_ip, |
| 2825 | client_mac, |
| 2826 | session_id=0, |
| 2827 | is_add=1, |
| 2828 | is_ipv6=0, |
| 2829 | decap_vrf_id=0): |
| 2830 | """ |
| 2831 | |
| 2832 | :param is_add: (Default value = 1) |
| 2833 | :param is_ipv6: (Default value = 0) |
| 2834 | :param client_ip: |
| 2835 | :param session_id: (Default value = 0) |
| 2836 | :param client_mac: |
| 2837 | :param decap_vrf_id: (Default value = 0) |
| 2838 | |
| 2839 | """ |
| 2840 | return self.api(self.papi.pppoe_add_del_session, |
| 2841 | {'is_add': is_add, |
| 2842 | 'is_ipv6': is_ipv6, |
| 2843 | 'session_id': session_id, |
| 2844 | 'client_ip': client_ip, |
| 2845 | 'decap_vrf_id': decap_vrf_id, |
| 2846 | 'client_mac': client_mac}) |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2847 | |
Neale Ranns | 7c922dc | 2018-08-30 06:12:27 -0700 | [diff] [blame] | 2848 | def sr_mpls_policy_add(self, bsid, weight, type, segments): |
| 2849 | return self.api(self.papi.sr_mpls_policy_add, |
| 2850 | {'bsid': bsid, |
| 2851 | 'weight': weight, |
| 2852 | 'type': type, |
| 2853 | 'n_segments': len(segments), |
| 2854 | 'segments': segments}) |
| 2855 | |
| 2856 | def sr_mpls_policy_del(self, bsid): |
| 2857 | return self.api(self.papi.sr_mpls_policy_del, |
| 2858 | {'bsid': bsid}) |
| 2859 | |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2860 | def sr_localsid_add_del(self, |
Pablo Camarillo | 3337bd2 | 2018-06-19 15:49:02 +0200 | [diff] [blame] | 2861 | localsid, |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2862 | behavior, |
Pablo Camarillo | 3337bd2 | 2018-06-19 15:49:02 +0200 | [diff] [blame] | 2863 | nh_addr4, |
| 2864 | nh_addr6, |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2865 | is_del=0, |
| 2866 | end_psp=0, |
| 2867 | sw_if_index=0xFFFFFFFF, |
| 2868 | vlan_index=0, |
| 2869 | fib_table=0, |
| 2870 | ): |
| 2871 | """ Add/del IPv6 SR local-SID. |
| 2872 | |
Pablo Camarillo | 3337bd2 | 2018-06-19 15:49:02 +0200 | [diff] [blame] | 2873 | :param localsid: |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2874 | :param behavior: END=1; END.X=2; END.DX2=4; END.DX6=5; |
| 2875 | :param behavior: END.DX4=6; END.DT6=7; END.DT4=8 |
Pablo Camarillo | 3337bd2 | 2018-06-19 15:49:02 +0200 | [diff] [blame] | 2876 | :param nh_addr4: |
| 2877 | :param nh_addr6: |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2878 | :param is_del: (Default value = 0) |
| 2879 | :param end_psp: (Default value = 0) |
| 2880 | :param sw_if_index: (Default value = 0xFFFFFFFF) |
| 2881 | :param vlan_index: (Default value = 0) |
| 2882 | :param fib_table: (Default value = 0) |
| 2883 | """ |
| 2884 | return self.api( |
| 2885 | self.papi.sr_localsid_add_del, |
| 2886 | {'is_del': is_del, |
Pablo Camarillo | 3337bd2 | 2018-06-19 15:49:02 +0200 | [diff] [blame] | 2887 | 'localsid': localsid, |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2888 | 'end_psp': end_psp, |
| 2889 | 'behavior': behavior, |
| 2890 | 'sw_if_index': sw_if_index, |
| 2891 | 'vlan_index': vlan_index, |
| 2892 | 'fib_table': fib_table, |
Pablo Camarillo | 3337bd2 | 2018-06-19 15:49:02 +0200 | [diff] [blame] | 2893 | 'nh_addr4': nh_addr4, |
| 2894 | 'nh_addr6': nh_addr6 |
Kris Michielsen | 9107443 | 2017-06-22 13:00:20 +0200 | [diff] [blame] | 2895 | } |
| 2896 | ) |
| 2897 | |
| 2898 | def sr_policy_add( |
| 2899 | self, |
| 2900 | bsid_addr, |
| 2901 | weight=1, |
| 2902 | is_encap=1, |
| 2903 | type=0, |
| 2904 | fib_table=0, |
| 2905 | n_segments=0, |
| 2906 | segments=[]): |
| 2907 | """ |
| 2908 | :param bsid_addr: bindingSID of the SR Policy |
| 2909 | :param weight: weight of the sid list. optional. (default: 1) |
| 2910 | :param is_encap: (bool) whether SR policy should Encap or SRH insert \ |
| 2911 | (default: Encap) |
| 2912 | :param type: type/behavior of the SR policy. (default or spray) \ |
| 2913 | (default: default) |
| 2914 | :param fib_table: VRF where to install the FIB entry for the BSID \ |
| 2915 | (default: 0) |
| 2916 | :param n_segments: number of segments \ |
| 2917 | (default: 0) |
| 2918 | :param segments: a vector of IPv6 address composing the segment list \ |
| 2919 | (default: []) |
| 2920 | """ |
| 2921 | return self.api( |
| 2922 | self.papi.sr_policy_add, |
| 2923 | {'bsid_addr': bsid_addr, |
| 2924 | 'weight': weight, |
| 2925 | 'is_encap': is_encap, |
| 2926 | 'type': type, |
| 2927 | 'fib_table': fib_table, |
| 2928 | 'n_segments': n_segments, |
| 2929 | 'segments': segments |
| 2930 | } |
| 2931 | ) |
| 2932 | |
| 2933 | def sr_policy_del( |
| 2934 | self, |
| 2935 | bsid_addr, |
| 2936 | sr_policy_index=0): |
| 2937 | """ |
| 2938 | :param bsid: bindingSID of the SR Policy |
| 2939 | :param sr_policy_index: index of the sr policy (default: 0) |
| 2940 | """ |
| 2941 | return self.api( |
| 2942 | self.papi.sr_policy_del, |
| 2943 | {'bsid_addr': bsid_addr, |
| 2944 | 'sr_policy_index': sr_policy_index |
| 2945 | }) |
| 2946 | |
| 2947 | def sr_steering_add_del( |
| 2948 | self, |
| 2949 | is_del, |
| 2950 | bsid_addr, |
| 2951 | sr_policy_index, |
| 2952 | table_id, |
| 2953 | prefix_addr, |
| 2954 | mask_width, |
| 2955 | sw_if_index, |
| 2956 | traffic_type): |
| 2957 | """ |
| 2958 | Steer traffic L2 and L3 traffic through a given SR policy |
| 2959 | |
| 2960 | :param is_del: delete or add |
| 2961 | :param bsid_addr: bindingSID of the SR Policy (alt to sr_policy_index) |
| 2962 | :param sr_policy: is the index of the SR Policy (alt to bsid) |
| 2963 | :param table_id: is the VRF where to install the FIB entry for the BSID |
| 2964 | :param prefix_addr: is the IPv4/v6 address for L3 traffic type |
| 2965 | :param mask_width: is the mask for L3 traffic type |
| 2966 | :param sw_if_index: is the incoming interface for L2 traffic |
| 2967 | :param traffic_type: type of traffic (IPv4: 4, IPv6: 6, L2: 2) |
| 2968 | """ |
| 2969 | return self.api( |
| 2970 | self.papi.sr_steering_add_del, |
| 2971 | {'is_del': is_del, |
| 2972 | 'bsid_addr': bsid_addr, |
| 2973 | 'sr_policy_index': sr_policy_index, |
| 2974 | 'table_id': table_id, |
| 2975 | 'prefix_addr': prefix_addr, |
| 2976 | 'mask_width': mask_width, |
| 2977 | 'sw_if_index': sw_if_index, |
| 2978 | 'traffic_type': traffic_type |
| 2979 | }) |
Pavel Kotucek | 932f741 | 2017-09-07 14:44:52 +0200 | [diff] [blame] | 2980 | |
Andrew Yourtchenko | 51d2651 | 2017-09-14 18:26:36 +0200 | [diff] [blame] | 2981 | def acl_add_replace(self, acl_index, r, tag='', |
| 2982 | expected_retval=0): |
| 2983 | """Add/replace an ACL |
| 2984 | :param int acl_index: ACL index to replace, 2^32-1 to create new ACL. |
| 2985 | :param acl_rule r: ACL rules array. |
| 2986 | :param str tag: symbolic tag (description) for this ACL. |
| 2987 | :param int count: number of rules. |
| 2988 | """ |
| 2989 | return self.api(self.papi.acl_add_replace, |
| 2990 | {'acl_index': acl_index, |
| 2991 | 'r': r, |
| 2992 | 'count': len(r), |
| 2993 | 'tag': tag}, |
| 2994 | expected_retval=expected_retval) |
| 2995 | |
Andrew Yourtchenko | 987abe9 | 2017-09-27 13:50:31 +0200 | [diff] [blame] | 2996 | def acl_del(self, acl_index, expected_retval=0): |
| 2997 | """ |
| 2998 | |
| 2999 | :param acl_index: |
| 3000 | :return: |
| 3001 | """ |
| 3002 | return self.api(self.papi.acl_del, |
| 3003 | {'acl_index': acl_index}, |
| 3004 | expected_retval=expected_retval) |
| 3005 | |
Andrew Yourtchenko | 51d2651 | 2017-09-14 18:26:36 +0200 | [diff] [blame] | 3006 | def acl_interface_set_acl_list(self, sw_if_index, n_input, acls, |
| 3007 | expected_retval=0): |
| 3008 | return self.api(self.papi.acl_interface_set_acl_list, |
| 3009 | {'sw_if_index': sw_if_index, |
| 3010 | 'count': len(acls), |
| 3011 | 'n_input': n_input, |
| 3012 | 'acls': acls}, |
| 3013 | expected_retval=expected_retval) |
| 3014 | |
Andrew Yourtchenko | c43b3f9 | 2018-02-06 17:42:32 +0100 | [diff] [blame] | 3015 | def acl_interface_set_etype_whitelist(self, sw_if_index, |
| 3016 | n_input, whitelist, |
| 3017 | expected_retval=0): |
| 3018 | return self.api(self.papi.acl_interface_set_etype_whitelist, |
| 3019 | {'sw_if_index': sw_if_index, |
| 3020 | 'count': len(whitelist), |
| 3021 | 'n_input': n_input, |
| 3022 | 'whitelist': whitelist}, |
| 3023 | expected_retval=expected_retval) |
| 3024 | |
Pavel Kotucek | 8daa80a | 2017-09-25 09:44:05 +0200 | [diff] [blame] | 3025 | def acl_interface_add_del(self, |
| 3026 | sw_if_index, |
| 3027 | acl_index, |
| 3028 | is_add=1): |
| 3029 | """ Add/Delete ACL to/from interface |
| 3030 | |
| 3031 | :param sw_if_index: |
| 3032 | :param acl_index: |
| 3033 | :param is_add: (Default value = 1) |
| 3034 | """ |
| 3035 | |
| 3036 | return self.api(self.papi.acl_interface_add_del, |
| 3037 | {'is_add': is_add, |
| 3038 | 'is_input': 1, |
| 3039 | 'sw_if_index': sw_if_index, |
| 3040 | 'acl_index': acl_index}) |
| 3041 | |
Andrew Yourtchenko | 51d2651 | 2017-09-14 18:26:36 +0200 | [diff] [blame] | 3042 | def acl_dump(self, acl_index, expected_retval=0): |
| 3043 | return self.api(self.papi.acl_dump, |
| 3044 | {'acl_index': acl_index}, |
| 3045 | expected_retval=expected_retval) |
| 3046 | |
Andrew Yourtchenko | 0e89dfc | 2018-03-23 09:34:29 +0100 | [diff] [blame] | 3047 | def acl_interface_list_dump(self, sw_if_index=0xFFFFFFFF, |
| 3048 | expected_retval=0): |
| 3049 | return self.api(self.papi.acl_interface_list_dump, |
| 3050 | {'sw_if_index': sw_if_index}, |
| 3051 | expected_retval=expected_retval) |
| 3052 | |
Pavel Kotucek | c29940c | 2017-09-07 08:17:31 +0200 | [diff] [blame] | 3053 | def macip_acl_add(self, rules, tag=""): |
| 3054 | """ Add MACIP acl |
| 3055 | |
| 3056 | :param rules: list of rules for given acl |
| 3057 | :param tag: acl tag |
| 3058 | """ |
| 3059 | |
| 3060 | return self.api(self.papi.macip_acl_add, |
| 3061 | {'r': rules, |
| 3062 | 'count': len(rules), |
| 3063 | 'tag': tag}) |
| 3064 | |
Pavel Kotucek | 932f741 | 2017-09-07 14:44:52 +0200 | [diff] [blame] | 3065 | def macip_acl_add_replace(self, rules, acl_index=0xFFFFFFFF, tag=""): |
| 3066 | """ Add MACIP acl |
| 3067 | |
| 3068 | :param rules: list of rules for given acl |
| 3069 | :param tag: acl tag |
| 3070 | """ |
| 3071 | |
Pavel Kotucek | c29940c | 2017-09-07 08:17:31 +0200 | [diff] [blame] | 3072 | return self.api(self.papi.macip_acl_add_replace, |
| 3073 | {'acl_index': acl_index, |
| 3074 | 'r': rules, |
Pavel Kotucek | 932f741 | 2017-09-07 14:44:52 +0200 | [diff] [blame] | 3075 | 'count': len(rules), |
| 3076 | 'tag': tag}) |
| 3077 | |
| 3078 | def macip_acl_del(self, acl_index): |
| 3079 | """ |
| 3080 | |
| 3081 | :param acl_index: |
| 3082 | :return: |
| 3083 | """ |
| 3084 | return self.api(self.papi.macip_acl_del, |
| 3085 | {'acl_index': acl_index}) |
| 3086 | |
| 3087 | def macip_acl_interface_add_del(self, |
| 3088 | sw_if_index, |
| 3089 | acl_index, |
| 3090 | is_add=1): |
| 3091 | """ Add MACIP acl to interface |
| 3092 | |
| 3093 | :param sw_if_index: |
| 3094 | :param acl_index: |
| 3095 | :param is_add: (Default value = 1) |
| 3096 | """ |
| 3097 | |
| 3098 | return self.api(self.papi.macip_acl_interface_add_del, |
| 3099 | {'is_add': is_add, |
| 3100 | 'sw_if_index': sw_if_index, |
| 3101 | 'acl_index': acl_index}) |
| 3102 | |
| 3103 | def macip_acl_interface_get(self): |
| 3104 | """ Return interface acls dump |
| 3105 | """ |
| 3106 | return self.api( |
| 3107 | self.papi.macip_acl_interface_get, {}) |
| 3108 | |
| 3109 | def macip_acl_dump(self, acl_index=4294967295): |
| 3110 | """ Return MACIP acl dump |
| 3111 | """ |
| 3112 | |
| 3113 | return self.api( |
| 3114 | self.papi.macip_acl_dump, {'acl_index': acl_index}) |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 3115 | |
| 3116 | def policer_add_del(self, |
| 3117 | name, |
| 3118 | cir, |
| 3119 | eir, |
| 3120 | cb, |
| 3121 | eb, |
| 3122 | is_add=1, |
| 3123 | rate_type=0, |
| 3124 | round_type=0, |
| 3125 | ptype=0, |
| 3126 | color_aware=0, |
| 3127 | conform_action_type=1, |
| 3128 | conform_dscp=0, |
| 3129 | exceed_action_type=0, |
| 3130 | exceed_dscp=0, |
| 3131 | violate_action_type=0, |
| 3132 | violate_dscp=0): |
| 3133 | return self.api(self.papi.policer_add_del, |
| 3134 | {'name': name, |
| 3135 | 'cir': cir, |
| 3136 | 'eir': eir, |
| 3137 | 'cb': cb, |
| 3138 | 'eb': eb, |
| 3139 | 'is_add': is_add, |
| 3140 | 'rate_type': rate_type, |
| 3141 | 'round_type': round_type, |
| 3142 | 'type': ptype, |
| 3143 | 'color_aware': color_aware, |
| 3144 | 'conform_action_type': conform_action_type, |
| 3145 | 'conform_dscp': conform_dscp, |
| 3146 | 'exceed_action_type': exceed_action_type, |
| 3147 | 'exceed_dscp': exceed_dscp, |
| 3148 | 'violate_action_type': violate_action_type, |
| 3149 | 'violate_dscp': violate_dscp}) |
| 3150 | |
| 3151 | def ip_punt_police(self, |
| 3152 | policer_index, |
| 3153 | is_ip6=0, |
| 3154 | is_add=1): |
| 3155 | return self.api(self.papi.ip_punt_police, |
| 3156 | {'policer_index': policer_index, |
| 3157 | 'is_add': is_add, |
| 3158 | 'is_ip6': is_ip6}) |
| 3159 | |
| 3160 | def ip_punt_redirect(self, |
| 3161 | rx_sw_if_index, |
| 3162 | tx_sw_if_index, |
| 3163 | nh, |
| 3164 | is_ip6=0, |
| 3165 | is_add=1): |
| 3166 | return self.api(self.papi.ip_punt_redirect, |
| 3167 | {'rx_sw_if_index': rx_sw_if_index, |
| 3168 | 'tx_sw_if_index': tx_sw_if_index, |
| 3169 | 'nh': nh, |
| 3170 | 'is_add': is_add, |
| 3171 | 'is_ip6': is_ip6}) |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 3172 | |
| 3173 | def bier_table_add_del(self, |
| 3174 | bti, |
| 3175 | mpls_label, |
| 3176 | is_add=1): |
| 3177 | """ BIER Table add/del """ |
| 3178 | return self.api( |
| 3179 | self.papi.bier_table_add_del, |
| 3180 | {'bt_tbl_id': {"bt_set": bti.set_id, |
| 3181 | "bt_sub_domain": bti.sub_domain_id, |
| 3182 | "bt_hdr_len_id": bti.hdr_len_id}, |
| 3183 | 'bt_label': mpls_label, |
| 3184 | 'bt_is_add': is_add}) |
| 3185 | |
| 3186 | def bier_table_dump(self): |
| 3187 | return self.api(self.papi.bier_table_dump, {}) |
| 3188 | |
| 3189 | def bier_route_add_del(self, |
| 3190 | bti, |
| 3191 | bp, |
Neale Ranns | 9128637 | 2017-12-05 13:24:04 -0800 | [diff] [blame] | 3192 | paths, |
Neale Ranns | ef90ed0 | 2018-09-13 08:45:12 -0700 | [diff] [blame] | 3193 | is_add=1, |
| 3194 | is_replace=0): |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 3195 | """ BIER Route add/del """ |
| 3196 | return self.api( |
| 3197 | self.papi.bier_route_add_del, |
| 3198 | {'br_tbl_id': {"bt_set": bti.set_id, |
| 3199 | "bt_sub_domain": bti.sub_domain_id, |
| 3200 | "bt_hdr_len_id": bti.hdr_len_id}, |
| 3201 | 'br_bp': bp, |
Neale Ranns | 31ed744 | 2018-02-23 05:29:09 -0800 | [diff] [blame] | 3202 | 'br_n_paths': len(paths), |
| 3203 | 'br_paths': paths, |
Neale Ranns | ef90ed0 | 2018-09-13 08:45:12 -0700 | [diff] [blame] | 3204 | 'br_is_add': is_add, |
| 3205 | 'br_is_replace': is_replace}) |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 3206 | |
| 3207 | def bier_route_dump(self, bti): |
| 3208 | return self.api( |
| 3209 | self.papi.bier_route_dump, |
| 3210 | {'br_tbl_id': {"bt_set": bti.set_id, |
| 3211 | "bt_sub_domain": bti.sub_domain_id, |
| 3212 | "bt_hdr_len_id": bti.hdr_len_id}}) |
| 3213 | |
| 3214 | def bier_imp_add(self, |
| 3215 | bti, |
| 3216 | src, |
| 3217 | ibytes, |
| 3218 | is_add=1): |
| 3219 | """ BIER Imposition Add """ |
| 3220 | return self.api( |
| 3221 | self.papi.bier_imp_add, |
| 3222 | {'bi_tbl_id': {"bt_set": bti.set_id, |
| 3223 | "bt_sub_domain": bti.sub_domain_id, |
| 3224 | "bt_hdr_len_id": bti.hdr_len_id}, |
| 3225 | 'bi_src': src, |
| 3226 | 'bi_n_bytes': len(ibytes), |
| 3227 | 'bi_bytes': ibytes}) |
| 3228 | |
| 3229 | def bier_imp_del(self, bi_index): |
| 3230 | """ BIER Imposition del """ |
| 3231 | return self.api( |
| 3232 | self.papi.bier_imp_del, |
| 3233 | {'bi_index': bi_index}) |
| 3234 | |
| 3235 | def bier_imp_dump(self): |
| 3236 | return self.api(self.papi.bier_imp_dump, {}) |
| 3237 | |
| 3238 | def bier_disp_table_add_del(self, |
| 3239 | bdti, |
| 3240 | is_add=1): |
| 3241 | """ BIER Disposition Table add/del """ |
| 3242 | return self.api( |
| 3243 | self.papi.bier_disp_table_add_del, |
| 3244 | {'bdt_tbl_id': bdti, |
| 3245 | 'bdt_is_add': is_add}) |
| 3246 | |
| 3247 | def bier_disp_table_dump(self): |
| 3248 | return self.api(self.papi.bier_disp_table_dump, {}) |
| 3249 | |
| 3250 | def bier_disp_entry_add_del(self, |
| 3251 | bdti, |
| 3252 | bp, |
| 3253 | payload_proto, |
Neale Ranns | f051072 | 2018-01-31 11:35:41 -0800 | [diff] [blame] | 3254 | next_hop_afi, |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 3255 | next_hop, |
| 3256 | next_hop_tbl_id=0, |
| 3257 | next_hop_rpf_id=~0, |
| 3258 | next_hop_is_ip4=1, |
| 3259 | is_add=1): |
| 3260 | """ BIER Route add/del """ |
Neale Ranns | 31ed744 | 2018-02-23 05:29:09 -0800 | [diff] [blame] | 3261 | lstack = [] |
| 3262 | while (len(lstack) < 16): |
| 3263 | lstack.append({}) |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 3264 | return self.api( |
| 3265 | self.papi.bier_disp_entry_add_del, |
| 3266 | {'bde_tbl_id': bdti, |
| 3267 | 'bde_bp': bp, |
| 3268 | 'bde_payload_proto': payload_proto, |
| 3269 | 'bde_n_paths': 1, |
| 3270 | 'bde_paths': [{'next_hop': next_hop, |
| 3271 | 'table_id': next_hop_tbl_id, |
Neale Ranns | f051072 | 2018-01-31 11:35:41 -0800 | [diff] [blame] | 3272 | 'afi': next_hop_afi, |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 3273 | 'rpf_id': next_hop_rpf_id, |
| 3274 | 'n_labels': 0, |
Neale Ranns | 31ed744 | 2018-02-23 05:29:09 -0800 | [diff] [blame] | 3275 | 'label_stack': lstack}], |
Neale Ranns | d792d9c | 2017-10-21 10:53:20 -0700 | [diff] [blame] | 3276 | 'bde_is_add': is_add}) |
| 3277 | |
| 3278 | def bier_disp_entry_dump(self, bdti): |
| 3279 | return self.api( |
| 3280 | self.papi.bier_disp_entry_dump, |
| 3281 | {'bde_tbl_id': bdti}) |
Gabriel Ganne | 8527f12 | 2017-10-02 11:41:24 +0200 | [diff] [blame] | 3282 | |
| 3283 | def add_node_next(self, node_name, next_name): |
| 3284 | """ Set the next node for a given node request |
| 3285 | |
| 3286 | :param node_name: |
| 3287 | :param next_name: |
| 3288 | """ |
| 3289 | return self.api(self.papi.add_node_next, |
| 3290 | {'node_name': node_name, |
| 3291 | 'next_name': next_name}) |
Florin Coras | 3ea6ce2 | 2017-12-11 09:09:05 -0800 | [diff] [blame] | 3292 | |
| 3293 | def session_enable_disable(self, is_enabled): |
| 3294 | return self.api( |
| 3295 | self.papi.session_enable_disable, |
| 3296 | {'is_enable': is_enabled}) |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3297 | |
| 3298 | def ipsec_spd_add_del(self, spd_id, is_add=1): |
| 3299 | """ SPD add/del - Wrapper to add or del ipsec SPD |
| 3300 | Sample CLI : 'ipsec spd add 1' |
| 3301 | |
| 3302 | :param spd_id - SPD ID to be created in the vpp . mandatory |
| 3303 | :param is_add - create (1) or delete(0) SPD (Default 1 - add) . |
| 3304 | optional |
| 3305 | :returns: reply from the API |
| 3306 | """ |
| 3307 | return self.api( |
| 3308 | self.papi.ipsec_spd_add_del, { |
| 3309 | 'spd_id': spd_id, 'is_add': is_add}) |
| 3310 | |
| 3311 | def ipsec_interface_add_del_spd(self, spd_id, sw_if_index, is_add=1): |
| 3312 | """ IPSEC interface SPD add/del - \ |
| 3313 | Wrapper to associate/disassociate SPD to interface in VPP |
| 3314 | Sample CLI : 'set interface ipsec spd GigabitEthernet0/6/0 1' |
| 3315 | |
| 3316 | :param spd_id - SPD ID to associate with the interface . mandatory |
| 3317 | :param sw_if_index - Interface Index which needs to ipsec \ |
| 3318 | association mandatory |
| 3319 | :param is_add - add(1) or del(0) association with interface \ |
| 3320 | (Default 1 - add) . optional |
| 3321 | :returns: reply from the API |
| 3322 | """ |
| 3323 | return self.api( |
Klement Sekera | 4b089f2 | 2018-04-17 18:04:57 +0200 | [diff] [blame] | 3324 | self.papi.ipsec_interface_add_del_spd, |
| 3325 | {'spd_id': spd_id, 'sw_if_index': sw_if_index, 'is_add': is_add}) |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3326 | |
| 3327 | def ipsec_sad_add_del_entry(self, |
| 3328 | sad_id, |
| 3329 | spi, |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3330 | integrity_algorithm, |
| 3331 | integrity_key, |
| 3332 | crypto_algorithm, |
| 3333 | crypto_key, |
| 3334 | protocol, |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3335 | tunnel_src_address='', |
| 3336 | tunnel_dst_address='', |
Ole Troan | e0d2bd6 | 2018-06-22 22:36:46 +0200 | [diff] [blame] | 3337 | is_tunnel=1, |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 3338 | is_tunnel_ipv6=0, |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3339 | is_add=1, |
Klement Sekera | 4b089f2 | 2018-04-17 18:04:57 +0200 | [diff] [blame] | 3340 | udp_encap=0): |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3341 | """ IPSEC SA add/del |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3342 | :param sad_id: security association ID |
| 3343 | :param spi: security param index of the SA in decimal |
| 3344 | :param integrity_algorithm: |
| 3345 | :param integrity_key: |
| 3346 | :param crypto_algorithm: |
| 3347 | :param crypto_key: |
| 3348 | :param protocol: AH(0) or ESP(1) protocol |
| 3349 | :param tunnel_src_address: tunnel mode outer src address |
| 3350 | :param tunnel_dst_address: tunnel mode outer dst address |
| 3351 | :param is_add: |
| 3352 | :param is_tunnel: |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3353 | :** reference /vpp/src/vnet/ipsec/ipsec.h file for enum values of |
| 3354 | crypto and ipsec algorithms |
| 3355 | """ |
| 3356 | return self.api( |
| 3357 | self.papi.ipsec_sad_add_del_entry, |
| 3358 | {'sad_id': sad_id, |
| 3359 | 'spi': spi, |
| 3360 | 'tunnel_src_address': tunnel_src_address, |
| 3361 | 'tunnel_dst_address': tunnel_dst_address, |
| 3362 | 'protocol': protocol, |
| 3363 | 'integrity_algorithm': integrity_algorithm, |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3364 | 'integrity_key_length': len(integrity_key), |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3365 | 'integrity_key': integrity_key, |
| 3366 | 'crypto_algorithm': crypto_algorithm, |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3367 | 'crypto_key_length': len(crypto_key) if crypto_key is not None |
| 3368 | else 0, |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3369 | 'crypto_key': crypto_key, |
| 3370 | 'is_add': is_add, |
Klement Sekera | 4b089f2 | 2018-04-17 18:04:57 +0200 | [diff] [blame] | 3371 | 'is_tunnel': is_tunnel, |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 3372 | 'is_tunnel_ipv6': is_tunnel_ipv6, |
Klement Sekera | 4b089f2 | 2018-04-17 18:04:57 +0200 | [diff] [blame] | 3373 | 'udp_encap': udp_encap}) |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3374 | |
| 3375 | def ipsec_spd_add_del_entry(self, |
| 3376 | spd_id, |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3377 | sa_id, |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3378 | local_address_start, |
| 3379 | local_address_stop, |
| 3380 | remote_address_start, |
| 3381 | remote_address_stop, |
| 3382 | local_port_start=0, |
| 3383 | local_port_stop=65535, |
| 3384 | remote_port_start=0, |
| 3385 | remote_port_stop=65535, |
| 3386 | protocol=0, |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3387 | policy=0, |
| 3388 | priority=100, |
| 3389 | is_outbound=1, |
| 3390 | is_add=1, |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 3391 | is_ipv6=0, |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3392 | is_ip_any=0): |
| 3393 | """ IPSEC policy SPD add/del - |
| 3394 | Wrapper to configure ipsec SPD policy entries in VPP |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3395 | :param spd_id: SPD ID for the policy |
| 3396 | :param local_address_start: local-ip-range start address |
| 3397 | :param local_address_stop : local-ip-range stop address |
| 3398 | :param remote_address_start: remote-ip-range start address |
| 3399 | :param remote_address_stop : remote-ip-range stop address |
| 3400 | :param local_port_start: (Default value = 0) |
| 3401 | :param local_port_stop: (Default value = 65535) |
| 3402 | :param remote_port_start: (Default value = 0) |
| 3403 | :param remote_port_stop: (Default value = 65535) |
| 3404 | :param protocol: Any(0), AH(51) & ESP(50) protocol (Default value = 0) |
| 3405 | :param sa_id: Security Association ID for mapping it to SPD |
| 3406 | :param policy: bypass(0), discard(1), resolve(2) or protect(3) action |
| 3407 | (Default value = 0) |
| 3408 | :param priority: value for the spd action (Default value = 100) |
| 3409 | :param is_outbound: flag for inbound(0) or outbound(1) |
| 3410 | (Default value = 1) |
| 3411 | :param is_add: (Default value = 1) |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3412 | """ |
| 3413 | return self.api( |
| 3414 | self.papi.ipsec_spd_add_del_entry, |
| 3415 | {'spd_id': spd_id, |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3416 | 'sa_id': sa_id, |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3417 | 'local_address_start': local_address_start, |
| 3418 | 'local_address_stop': local_address_stop, |
| 3419 | 'remote_address_start': remote_address_start, |
| 3420 | 'remote_address_stop': remote_address_stop, |
| 3421 | 'local_port_start': local_port_start, |
| 3422 | 'local_port_stop': local_port_stop, |
| 3423 | 'remote_port_start': remote_port_start, |
| 3424 | 'remote_port_stop': remote_port_stop, |
| 3425 | 'is_add': is_add, |
| 3426 | 'protocol': protocol, |
| 3427 | 'policy': policy, |
| 3428 | 'priority': priority, |
| 3429 | 'is_outbound': is_outbound, |
Klement Sekera | 611864f | 2018-09-26 11:19:00 +0200 | [diff] [blame] | 3430 | 'is_ipv6': is_ipv6, |
“mystarrocks” | 23f0c45 | 2017-12-11 07:11:51 -0800 | [diff] [blame] | 3431 | 'is_ip_any': is_ip_any}) |
Florin Coras | b795bd0 | 2017-12-14 11:30:48 -0800 | [diff] [blame] | 3432 | |
Klement Sekera | 31da2e3 | 2018-06-24 22:49:55 +0200 | [diff] [blame] | 3433 | def ipsec_tunnel_if_add_del(self, local_ip, remote_ip, local_spi, |
| 3434 | remote_spi, crypto_alg, local_crypto_key, |
| 3435 | remote_crypto_key, integ_alg, local_integ_key, |
| 3436 | remote_integ_key, is_add=1, esn=0, |
| 3437 | anti_replay=1, renumber=0, show_instance=0): |
| 3438 | return self.api( |
| 3439 | self.papi.ipsec_tunnel_if_add_del, |
| 3440 | {'local_ip': local_ip, 'remote_ip': remote_ip, |
| 3441 | 'local_spi': local_spi, 'remote_spi': remote_spi, |
| 3442 | 'crypto_alg': crypto_alg, |
| 3443 | 'local_crypto_key_len': len(local_crypto_key), |
| 3444 | 'local_crypto_key': local_crypto_key, |
| 3445 | 'remote_crypto_key_len': len(remote_crypto_key), |
| 3446 | 'remote_crypto_key': remote_crypto_key, 'integ_alg': integ_alg, |
| 3447 | 'local_integ_key_len': len(local_integ_key), |
| 3448 | 'local_integ_key': local_integ_key, |
| 3449 | 'remote_integ_key_len': len(remote_integ_key), |
| 3450 | 'remote_integ_key': remote_integ_key, 'is_add': is_add, |
| 3451 | 'esn': esn, 'anti_replay': anti_replay, 'renumber': renumber, |
| 3452 | 'show_instance': show_instance |
| 3453 | }) |
| 3454 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 3455 | def ipsec_select_backend(self, protocol, index): |
| 3456 | return self.api(self.papi.ipsec_select_backend, |
| 3457 | {'protocol': protocol, 'index': index}) |
| 3458 | |
| 3459 | def ipsec_backend_dump(self): |
| 3460 | return self.api(self.papi.ipsec_backend_dump, {}) |
| 3461 | |
Florin Coras | b795bd0 | 2017-12-14 11:30:48 -0800 | [diff] [blame] | 3462 | def app_namespace_add(self, |
| 3463 | namespace_id, |
| 3464 | ip4_fib_id=0, |
| 3465 | ip6_fib_id=0, |
| 3466 | sw_if_index=0xFFFFFFFF, |
| 3467 | secret=0): |
| 3468 | return self.api( |
| 3469 | self.papi.app_namespace_add_del, |
| 3470 | {'secret': secret, |
| 3471 | 'sw_if_index': sw_if_index, |
| 3472 | 'ip4_fib_id': ip4_fib_id, |
| 3473 | 'ip6_fib_id': ip6_fib_id, |
| 3474 | 'namespace_id': namespace_id, |
| 3475 | 'namespace_id_len': len(namespace_id)}) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 3476 | |
| 3477 | def punt_socket_register(self, l4_port, pathname, header_version=1, |
| 3478 | is_ip4=1, l4_protocol=0x11): |
| 3479 | """ Punt to socket """ |
| 3480 | return self.api(self.papi.punt_socket_register, |
| 3481 | {'is_ip4': is_ip4, |
| 3482 | 'l4_protocol': l4_protocol, |
| 3483 | 'l4_port': l4_port, |
| 3484 | 'pathname': pathname, |
| 3485 | 'header_version': header_version}) |
| 3486 | |
| 3487 | def ip_reassembly_set(self, timeout_ms, max_reassemblies, |
| 3488 | expire_walk_interval_ms, is_ip6=0): |
| 3489 | """ Set IP reassembly parameters """ |
| 3490 | return self.api(self.papi.ip_reassembly_set, |
| 3491 | {'is_ip6': is_ip6, |
| 3492 | 'timeout_ms': timeout_ms, |
| 3493 | 'expire_walk_interval_ms': expire_walk_interval_ms, |
| 3494 | 'max_reassemblies': max_reassemblies}) |
| 3495 | |
| 3496 | def ip_reassembly_get(self, is_ip6=0): |
| 3497 | """ Get IP reassembly parameters """ |
| 3498 | return self.api(self.papi.ip_reassembly_get, {'is_ip6': is_ip6}) |
Neale Ranns | bc27d1b | 2018-02-05 01:13:38 -0800 | [diff] [blame] | 3499 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 3500 | def ip_reassembly_enable_disable(self, sw_if_index, enable_ip4=False, |
| 3501 | enable_ip6=False): |
| 3502 | """ Enable/disable IP reassembly """ |
| 3503 | return self.api(self.papi.ip_reassembly_enable_disable, |
| 3504 | {'sw_if_index': sw_if_index, |
| 3505 | 'enable_ip4': 1 if enable_ip4 else 0, |
| 3506 | 'enable_ip6': 1 if enable_ip6 else 0, |
| 3507 | }) |
| 3508 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3509 | def gbp_endpoint_add(self, sw_if_index, ips, mac, epg, flags, |
| 3510 | tun_src, tun_dst): |
Neale Ranns | c0a9314 | 2018-09-05 15:42:26 -0700 | [diff] [blame] | 3511 | """ GBP endpoint Add """ |
| 3512 | return self.api(self.papi.gbp_endpoint_add, |
| 3513 | {'endpoint': { |
| 3514 | 'sw_if_index': sw_if_index, |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3515 | 'flags': 0, |
Neale Ranns | c0a9314 | 2018-09-05 15:42:26 -0700 | [diff] [blame] | 3516 | 'ips': ips, |
| 3517 | 'n_ips': len(ips), |
| 3518 | 'mac': mac, |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3519 | 'epg_id': epg, |
| 3520 | 'flags': flags, |
| 3521 | 'tun': { |
| 3522 | 'src': tun_src, |
| 3523 | 'dst': tun_dst, |
| 3524 | }}}) |
Neale Ranns | c0a9314 | 2018-09-05 15:42:26 -0700 | [diff] [blame] | 3525 | |
| 3526 | def gbp_endpoint_del(self, handle): |
| 3527 | """ GBP endpoint Del """ |
| 3528 | return self.api(self.papi.gbp_endpoint_del, |
| 3529 | {'handle': handle}) |
Neale Ranns | bc27d1b | 2018-02-05 01:13:38 -0800 | [diff] [blame] | 3530 | |
| 3531 | def gbp_endpoint_dump(self): |
| 3532 | """ GBP endpoint Dump """ |
| 3533 | return self.api(self.papi.gbp_endpoint_dump, {}) |
| 3534 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3535 | def gbp_endpoint_group_add(self, epg, bd, |
| 3536 | rd, uplink_sw_if_index): |
| 3537 | """ GBP endpoint group Add """ |
| 3538 | return self.api(self.papi.gbp_endpoint_group_add, |
| 3539 | {'epg': |
| 3540 | { |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 3541 | 'uplink_sw_if_index': uplink_sw_if_index, |
| 3542 | 'bd_id': bd, |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3543 | 'rd_id': rd, |
| 3544 | 'epg_id': epg |
| 3545 | }}) |
| 3546 | |
| 3547 | def gbp_endpoint_group_del(self, epg): |
| 3548 | """ GBP endpoint group Del """ |
| 3549 | return self.api(self.papi.gbp_endpoint_group_del, |
| 3550 | {'epg_id': epg}) |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 3551 | |
| 3552 | def gbp_endpoint_group_dump(self): |
| 3553 | """ GBP endpoint group Dump """ |
| 3554 | return self.api(self.papi.gbp_endpoint_group_dump, {}) |
| 3555 | |
Neale Ranns | c29c0af | 2018-11-07 04:21:12 -0800 | [diff] [blame] | 3556 | def gbp_bridge_domain_add(self, bd_id, flags, |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3557 | bvi_sw_if_index, |
| 3558 | uu_fwd_sw_if_index): |
| 3559 | """ GBP bridge-domain Add """ |
| 3560 | return self.api(self.papi.gbp_bridge_domain_add, |
| 3561 | {'bd': |
| 3562 | { |
Neale Ranns | c29c0af | 2018-11-07 04:21:12 -0800 | [diff] [blame] | 3563 | 'flags': flags, |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3564 | 'bvi_sw_if_index': bvi_sw_if_index, |
| 3565 | 'uu_fwd_sw_if_index': uu_fwd_sw_if_index, |
| 3566 | 'bd_id': bd_id |
| 3567 | }}) |
| 3568 | |
| 3569 | def gbp_bridge_domain_del(self, bd_id): |
| 3570 | """ GBP bridge-domain Del """ |
| 3571 | return self.api(self.papi.gbp_bridge_domain_del, |
| 3572 | {'bd_id': bd_id}) |
| 3573 | |
| 3574 | def gbp_bridge_domain_dump(self): |
| 3575 | """ GBP Bridge Domain Dump """ |
| 3576 | return self.api(self.papi.gbp_bridge_domain_dump, {}) |
| 3577 | |
| 3578 | def gbp_route_domain_add(self, rd_id, |
| 3579 | ip4_table_id, |
| 3580 | ip6_table_id, |
| 3581 | ip4_uu_sw_if_index, |
| 3582 | ip6_uu_sw_if_index): |
| 3583 | """ GBP route-domain Add """ |
| 3584 | return self.api(self.papi.gbp_route_domain_add, |
| 3585 | {'rd': |
| 3586 | { |
| 3587 | 'ip4_table_id': ip4_table_id, |
| 3588 | 'ip6_table_id': ip6_table_id, |
| 3589 | 'ip4_uu_sw_if_index': ip4_uu_sw_if_index, |
| 3590 | 'ip6_uu_sw_if_index': ip6_uu_sw_if_index, |
| 3591 | 'rd_id': rd_id |
| 3592 | }}) |
| 3593 | |
| 3594 | def gbp_route_domain_del(self, rd_id): |
| 3595 | """ GBP route-domain Del """ |
| 3596 | return self.api(self.papi.gbp_route_domain_del, |
| 3597 | {'rd_id': rd_id}) |
| 3598 | |
| 3599 | def gbp_route_domain_dump(self): |
| 3600 | """ GBP Route Domain Dump """ |
| 3601 | return self.api(self.papi.gbp_route_domain_dump, {}) |
| 3602 | |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 3603 | def gbp_recirc_add_del(self, is_add, sw_if_index, epg, is_ext): |
| 3604 | """ GBP recirc Add/Del """ |
| 3605 | return self.api(self.papi.gbp_recirc_add_del, |
| 3606 | {'is_add': is_add, |
| 3607 | 'recirc': { |
| 3608 | 'is_ext': is_ext, |
| 3609 | 'sw_if_index': sw_if_index, |
| 3610 | 'epg_id': epg}}) |
| 3611 | |
| 3612 | def gbp_recirc_dump(self): |
| 3613 | """ GBP recirc Dump """ |
| 3614 | return self.api(self.papi.gbp_recirc_dump, {}) |
| 3615 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3616 | def gbp_subnet_add_del(self, is_add, rd_id, |
| 3617 | prefix, type, |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 3618 | sw_if_index=0xffffffff, |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3619 | epg_id=0xffff): |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 3620 | """ GBP Subnet Add/Del """ |
| 3621 | return self.api(self.papi.gbp_subnet_add_del, |
| 3622 | {'is_add': is_add, |
| 3623 | 'subnet': { |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3624 | 'type': type, |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 3625 | 'sw_if_index': sw_if_index, |
| 3626 | 'epg_id': epg_id, |
Neale Ranns | c0a9314 | 2018-09-05 15:42:26 -0700 | [diff] [blame] | 3627 | 'prefix': prefix, |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3628 | 'rd_id': rd_id}}) |
Neale Ranns | 25b0494 | 2018-04-04 09:34:50 -0700 | [diff] [blame] | 3629 | |
| 3630 | def gbp_subnet_dump(self): |
| 3631 | """ GBP Subnet Dump """ |
| 3632 | return self.api(self.papi.gbp_subnet_dump, {}) |
| 3633 | |
Neale Ranns | bc27d1b | 2018-02-05 01:13:38 -0800 | [diff] [blame] | 3634 | def gbp_contract_add_del(self, is_add, src_epg, dst_epg, acl_index): |
| 3635 | """ GBP contract Add/Del """ |
| 3636 | return self.api(self.papi.gbp_contract_add_del, |
| 3637 | {'is_add': is_add, |
| 3638 | 'contract': { |
| 3639 | 'acl_index': acl_index, |
| 3640 | 'src_epg': src_epg, |
| 3641 | 'dst_epg': dst_epg}}) |
| 3642 | |
| 3643 | def gbp_contract_dump(self): |
| 3644 | """ GBP contract Dump """ |
| 3645 | return self.api(self.papi.gbp_contract_dump, {}) |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 3646 | |
Neale Ranns | 93cc3ee | 2018-10-10 07:22:51 -0700 | [diff] [blame] | 3647 | def gbp_endpoint_learn_set_inactive_threshold(self, threshold): |
| 3648 | """ GBP set inactive threshold """ |
| 3649 | return self.api(self.papi.gbp_endpoint_learn_set_inactive_threshold, |
| 3650 | {'threshold': threshold}) |
| 3651 | |
| 3652 | def gbp_vxlan_tunnel_add(self, vni, bd_rd_id, mode): |
| 3653 | """ GBP VXLAN tunnel add """ |
| 3654 | return self.api(self.papi.gbp_vxlan_tunnel_add, |
| 3655 | { |
| 3656 | 'tunnel': { |
| 3657 | 'vni': vni, |
| 3658 | 'mode': mode, |
| 3659 | 'bd_rd_id': bd_rd_id |
| 3660 | } |
| 3661 | }) |
| 3662 | |
| 3663 | def gbp_vxlan_tunnel_del(self, vni): |
| 3664 | """ GBP VXLAN tunnel del """ |
| 3665 | return self.api(self.papi.gbp_vxlan_tunnel_del, |
| 3666 | { |
| 3667 | 'vni': vni, |
| 3668 | }) |
| 3669 | |
| 3670 | def gbp_vxlan_tunnel_dump(self): |
| 3671 | """ GBP VXLAN tunnel add/del """ |
| 3672 | return self.api(self.papi.gbp_vxlan_tunnel_dump, {}) |
| 3673 | |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 3674 | def ipip_6rd_add_tunnel(self, ip6_table_id, ip6_prefix, ip6_prefix_len, |
| 3675 | ip4_table_id, ip4_prefix, ip4_prefix_len, ip4_src, |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 3676 | security_check): |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 3677 | """ 6RD tunnel Add """ |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 3678 | return self.api(self.papi.ipip_6rd_add_tunnel, |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 3679 | {'ip4_table_id': ip4_table_id, |
| 3680 | 'ip6_table_id': ip6_table_id, |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 3681 | 'ip6_prefix': ip6_prefix, |
| 3682 | 'ip6_prefix_len': ip6_prefix_len, |
| 3683 | 'ip4_prefix': ip4_prefix, |
| 3684 | 'ip4_prefix_len': ip4_prefix_len, |
| 3685 | 'ip4_src': ip4_src, |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 3686 | 'security_check': security_check}) |
| 3687 | |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 3688 | def ipip_6rd_del_tunnel(self, sw_if_index): |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 3689 | """ 6RD tunnel Delete """ |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 3690 | return self.api(self.papi.ipip_6rd_del_tunnel, |
| 3691 | {'sw_if_index': sw_if_index}) |
| 3692 | |
| 3693 | def ipip_add_tunnel(self, src_address, dst_address, is_ipv6=1, |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 3694 | instance=0xFFFFFFFF, table_id=0, tc_tos=0): |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 3695 | """ IPIP tunnel Add/Del """ |
| 3696 | return self.api(self.papi.ipip_add_tunnel, |
| 3697 | {'is_ipv6': is_ipv6, |
| 3698 | 'instance': instance, |
| 3699 | 'src_address': src_address, |
| 3700 | 'dst_address': dst_address, |
Neale Ranns | 6150211 | 2018-08-22 00:21:14 -0700 | [diff] [blame] | 3701 | 'table_id': table_id, |
Ole Troan | d57f636 | 2018-05-24 13:21:43 +0200 | [diff] [blame] | 3702 | 'tc_tos': tc_tos}) |
Ole Troan | 298c695 | 2018-03-08 12:30:43 +0100 | [diff] [blame] | 3703 | |
| 3704 | def ipip_del_tunnel(self, sw_if_index): |
| 3705 | """ IPIP tunnel Delete """ |
| 3706 | return self.api(self.papi.ipip_del_tunnel, |
Ole Troan | 6ee4051 | 2018-02-12 18:14:39 +0100 | [diff] [blame] | 3707 | {'sw_if_index': sw_if_index}) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 3708 | |
| 3709 | def qos_egress_map_update(self, id, outputs): |
| 3710 | """ QOS egress map update """ |
| 3711 | return self.api(self.papi.qos_egress_map_update, |
| 3712 | {'map_id': id, |
| 3713 | 'rows': outputs}) |
| 3714 | |
| 3715 | def qos_egress_map_delete(self, id): |
| 3716 | """ QOS egress map delete """ |
| 3717 | return self.api(self.papi.qos_egress_map_delete, |
| 3718 | {'map_id': id}) |
| 3719 | |
| 3720 | def qos_mark_enable_disable(self, sw_if_index, |
| 3721 | output_source, |
| 3722 | map_id, |
| 3723 | enable): |
| 3724 | """ QOS Mark Enable/Disable """ |
| 3725 | return self.api(self.papi.qos_mark_enable_disable, |
| 3726 | {'map_id': map_id, |
| 3727 | 'sw_if_index': sw_if_index, |
| 3728 | 'output_source': output_source, |
| 3729 | 'enable': enable}) |
| 3730 | |
| 3731 | def qos_record_enable_disable(self, sw_if_index, input_source, enable): |
| 3732 | """ IP QoS recording Enble/Disable """ |
| 3733 | return self.api(self.papi.qos_record_enable_disable, |
| 3734 | {'sw_if_index': sw_if_index, |
| 3735 | 'input_source': input_source, |
| 3736 | 'enable': enable}) |
Jakub Grajciar | 7b867a8 | 2017-12-08 16:28:42 +0100 | [diff] [blame] | 3737 | |
Neale Ranns | 947ea62 | 2018-06-07 23:48:20 -0700 | [diff] [blame] | 3738 | def igmp_enable_disable(self, sw_if_index, enable, host): |
| 3739 | """ Enable/disable IGMP on a given interface """ |
| 3740 | return self.api(self.papi.igmp_enable_disable, |
| 3741 | {'enable': enable, |
| 3742 | 'mode': host, |
| 3743 | 'sw_if_index': sw_if_index}) |
| 3744 | |
Jakub Grajciar | 97748ca | 2018-10-04 11:05:35 +0200 | [diff] [blame] | 3745 | def igmp_proxy_device_add_del(self, vrf_id, sw_if_index, add): |
| 3746 | """ Add/del IGMP proxy device """ |
| 3747 | return self.api(self.papi.igmp_proxy_device_add_del, |
| 3748 | {'vrf_id': vrf_id, 'sw_if_index': sw_if_index, |
| 3749 | 'add': add}) |
| 3750 | |
| 3751 | def igmp_proxy_device_add_del_interface(self, vrf_id, sw_if_index, add): |
| 3752 | """ Add/del interface to/from IGMP proxy device """ |
| 3753 | return self.api(self.papi.igmp_proxy_device_add_del_interface, |
| 3754 | {'vrf_id': vrf_id, 'sw_if_index': sw_if_index, |
| 3755 | 'add': add}) |
| 3756 | |
Neale Ranns | 947ea62 | 2018-06-07 23:48:20 -0700 | [diff] [blame] | 3757 | def igmp_listen(self, filter, sw_if_index, saddrs, gaddr): |
Jakub Grajciar | 7b867a8 | 2017-12-08 16:28:42 +0100 | [diff] [blame] | 3758 | """ Listen for new (S,G) on specified interface |
| 3759 | |
| 3760 | :param enable: add/del |
| 3761 | :param sw_if_index: interface sw index |
| 3762 | :param saddr: source ip4 addr |
| 3763 | :param gaddr: group ip4 addr |
| 3764 | """ |
| 3765 | return self.api(self.papi.igmp_listen, |
Neale Ranns | 947ea62 | 2018-06-07 23:48:20 -0700 | [diff] [blame] | 3766 | { |
| 3767 | 'group': |
| 3768 | { |
| 3769 | 'filter': filter, |
| 3770 | 'sw_if_index': sw_if_index, |
| 3771 | 'n_srcs': len(saddrs), |
| 3772 | 'saddrs': saddrs, |
| 3773 | 'gaddr': |
| 3774 | { |
| 3775 | 'address': gaddr |
| 3776 | } |
| 3777 | } |
| 3778 | }) |
Jakub Grajciar | 7b867a8 | 2017-12-08 16:28:42 +0100 | [diff] [blame] | 3779 | |
| 3780 | def igmp_dump(self, sw_if_index=None): |
| 3781 | """ Dump all (S,G) interface configurations """ |
| 3782 | if sw_if_index is None: |
Neale Ranns | 947ea62 | 2018-06-07 23:48:20 -0700 | [diff] [blame] | 3783 | sw_if_index = 0xffffffff |
| 3784 | return self.api(self.papi.igmp_dump, |
| 3785 | {'sw_if_index': sw_if_index}) |
Jakub Grajciar | 7b867a8 | 2017-12-08 16:28:42 +0100 | [diff] [blame] | 3786 | |
| 3787 | def igmp_clear_interface(self, sw_if_index): |
| 3788 | """ Remove all (S,G)s from specified interface |
| 3789 | doesn't send IGMP report! |
| 3790 | """ |
| 3791 | return self.api( |
| 3792 | self.papi.igmp_clear_interface, { |
| 3793 | 'sw_if_index': sw_if_index}) |
| 3794 | |
| 3795 | def want_igmp_events(self, enable=1): |
| 3796 | return self.api(self.papi.want_igmp_events, {'enable': enable, |
| 3797 | 'pid': os.getpid()}) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 3798 | |
| 3799 | def bond_create( |
| 3800 | self, |
| 3801 | mode, |
| 3802 | lb, |
| 3803 | use_custom_mac, |
| 3804 | mac_address=''): |
| 3805 | """ |
| 3806 | :param mode: mode |
| 3807 | :param lb: load balance |
| 3808 | :param use_custom_mac: use custom mac |
| 3809 | :param mac_address: mac address |
| 3810 | """ |
| 3811 | return self.api( |
| 3812 | self.papi.bond_create, |
| 3813 | {'mode': mode, |
| 3814 | 'lb': lb, |
| 3815 | 'use_custom_mac': use_custom_mac, |
| 3816 | 'mac_address': mac_address |
| 3817 | }) |
| 3818 | |
| 3819 | def bond_delete( |
| 3820 | self, |
| 3821 | sw_if_index): |
| 3822 | """ |
| 3823 | :param sw_if_index: interface the operation is applied to |
| 3824 | """ |
| 3825 | return self.api(self.papi.bond_delete, |
| 3826 | {'sw_if_index': sw_if_index}) |
| 3827 | |
| 3828 | def bond_enslave( |
| 3829 | self, |
| 3830 | sw_if_index, |
| 3831 | bond_sw_if_index, |
| 3832 | is_passive, |
| 3833 | is_long_timeout): |
| 3834 | """ |
| 3835 | :param sw_if_index: slave sw_if_index |
| 3836 | :param bond_sw_if_index: bond sw_if_index |
| 3837 | :param is_passive: is passive lacp speaker |
| 3838 | :param is_long_time: 90 seconds timeout instead of 3 seconds timeout |
| 3839 | """ |
| 3840 | return self.api( |
| 3841 | self.papi.bond_enslave, |
| 3842 | {'sw_if_index': sw_if_index, |
| 3843 | 'bond_sw_if_index': bond_sw_if_index, |
| 3844 | 'is_passive': is_passive, |
| 3845 | 'is_long_timeout': is_long_timeout |
| 3846 | }) |
| 3847 | |
| 3848 | def bond_detach_slave( |
| 3849 | self, |
| 3850 | sw_if_index): |
| 3851 | """ |
| 3852 | :param sw_if_index: slave interface the operation is applied to |
| 3853 | """ |
| 3854 | return self.api(self.papi.bond_detach_slave, |
| 3855 | {'sw_if_index': sw_if_index}) |
| 3856 | |
| 3857 | def sw_interface_slave_dump( |
| 3858 | self, |
| 3859 | sw_if_index): |
| 3860 | """ |
| 3861 | :param sw_if_index: bond sw_if_index |
| 3862 | """ |
| 3863 | return self.api(self.papi.sw_interface_slave_dump, |
| 3864 | {'sw_if_index': sw_if_index}) |
| 3865 | |
| 3866 | def sw_interface_bond_dump( |
| 3867 | self): |
| 3868 | """ |
| 3869 | |
| 3870 | """ |
| 3871 | return self.api(self.papi.sw_interface_bond_dump, |
| 3872 | {}) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 3873 | |
| 3874 | def create_vhost_user_if( |
| 3875 | self, |
| 3876 | is_server, |
| 3877 | sock_filename, |
| 3878 | renumber, |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 3879 | disable_mrg_rxbuf, |
| 3880 | disable_indirect_desc, |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 3881 | custom_dev_instance, |
| 3882 | use_custom_mac, |
| 3883 | mac_address, |
| 3884 | tag=''): |
| 3885 | """ |
| 3886 | :param is_server: is server |
| 3887 | :param sock_filename: socket name |
| 3888 | :param renumber: renumber |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 3889 | :param disable_mrg_rxbuf: disable mergable rx buffers |
| 3890 | :param disable_indirect_desc: disable indirect descriptors |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 3891 | :param custom_dev_instance: custom dev instance |
| 3892 | :param use_custom_mac: use custom mac |
| 3893 | :param mac_address: mac address |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 3894 | :param tag: tag (default '') |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 3895 | """ |
| 3896 | return self.api( |
| 3897 | self.papi.create_vhost_user_if, |
| 3898 | {'is_server': is_server, |
| 3899 | 'sock_filename': sock_filename, |
| 3900 | 'renumber': renumber, |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 3901 | 'disable_mrg_rxbuf': disable_mrg_rxbuf, |
| 3902 | 'disable_indirect_desc': disable_indirect_desc, |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 3903 | 'custom_dev_instance': custom_dev_instance, |
| 3904 | 'use_custom_mac': use_custom_mac, |
| 3905 | 'mac_address': mac_address, |
| 3906 | 'tag': tag |
| 3907 | }) |
| 3908 | |
| 3909 | def delete_vhost_user_if( |
| 3910 | self, |
| 3911 | sw_if_index): |
| 3912 | """ |
| 3913 | :param sw_if_index: interface the operation is applied to |
| 3914 | """ |
| 3915 | return self.api(self.papi.delete_vhost_user_if, |
| 3916 | {'sw_if_index': sw_if_index, }) |
| 3917 | |
| 3918 | def sw_interface_vhost_user_dump( |
| 3919 | self): |
| 3920 | """ |
| 3921 | |
| 3922 | """ |
| 3923 | return self.api(self.papi.sw_interface_vhost_user_dump, |
| 3924 | {}) |
Andrew Yourtchenko | 669d07d | 2017-11-17 14:38:18 +0100 | [diff] [blame] | 3925 | |
| 3926 | def abf_policy_add_del(self, is_add, policy): |
| 3927 | return self.api( |
| 3928 | self.papi.abf_policy_add_del, |
| 3929 | {'is_add': is_add, |
| 3930 | 'policy': policy}) |
| 3931 | |
| 3932 | def abf_itf_attach_add_del(self, is_add, attach): |
| 3933 | return self.api( |
| 3934 | self.papi.abf_itf_attach_add_del, |
| 3935 | {'is_add': is_add, |
| 3936 | 'attach': attach}) |
| 3937 | |
| 3938 | def abf_policy_dump(self): |
| 3939 | return self.api( |
| 3940 | self.papi.abf_policy_dump, {}) |
| 3941 | |
| 3942 | def abf_itf_attach_dump(self): |
| 3943 | return self.api( |
| 3944 | self.papi.abf_itf_attach_dump, {}) |
Neale Ranns | 17ff3c1 | 2018-07-04 10:24:24 -0700 | [diff] [blame] | 3945 | |
| 3946 | def pipe_create(self, is_specified, user_instance): |
| 3947 | return self.api(self.papi.pipe_create, |
| 3948 | {'is_specified': is_specified, |
| 3949 | 'user_instance': user_instance}) |
| 3950 | |
| 3951 | def pipe_delete(self, parent_sw_if_index): |
| 3952 | return self.api(self.papi.pipe_delete, |
| 3953 | {'parent_sw_if_index': parent_sw_if_index}) |
| 3954 | |
| 3955 | def pipe_dump(self): |
| 3956 | return self.api(self.papi.pipe_dump, {}) |
Jakub Grajciar | b1be2a0 | 2018-09-19 13:36:16 +0200 | [diff] [blame] | 3957 | |
| 3958 | def memif_create( |
| 3959 | self, |
| 3960 | role, |
| 3961 | mode, |
| 3962 | rx_queues=None, |
| 3963 | tx_queues=None, |
| 3964 | _id=None, |
| 3965 | socket_id=None, |
| 3966 | secret=None, |
| 3967 | ring_size=None, |
| 3968 | buffer_size=None, |
| 3969 | hw_addr=None): |
| 3970 | return self.api(self.papi.memif_create, |
| 3971 | {'role': role, |
| 3972 | 'mode': mode, |
| 3973 | 'rx_queues': rx_queues, |
| 3974 | 'tx_queues': tx_queues, |
| 3975 | 'id': _id, |
| 3976 | 'socket_id': socket_id, |
| 3977 | 'secret': secret, |
| 3978 | 'ring_size': ring_size, |
| 3979 | 'buffer_size': buffer_size, |
| 3980 | 'hw_addr': hw_addr}) |
| 3981 | |
| 3982 | def memif_delete(self, sw_if_index): |
| 3983 | return self.api(self.papi.memif_delete, {'sw_if_index': sw_if_index}) |
| 3984 | |
| 3985 | def memif_dump(self): |
| 3986 | return self.api(self.papi.memif_dump, {}) |
| 3987 | |
| 3988 | def memif_socket_filename_add_del( |
| 3989 | self, is_add, socket_id, socket_filename): |
| 3990 | return self.api( |
| 3991 | self.papi.memif_socket_filename_add_del, |
| 3992 | {'is_add': is_add, |
| 3993 | 'socket_id': socket_id, |
| 3994 | 'socket_filename': socket_filename}) |
| 3995 | |
| 3996 | def memif_socket_filename_dump(self): |
| 3997 | return self.api(self.papi.memif_socket_filename_dump, {}) |
Neale Ranns | d1e68ab | 2018-10-01 01:42:13 -0700 | [diff] [blame] | 3998 | |
| 3999 | def svs_table_add_del(self, af, table_id, is_add=1): |
| 4000 | return self.api(self.papi.svs_table_add_del, |
| 4001 | { |
| 4002 | 'table_id': table_id, |
| 4003 | 'is_add': is_add, |
| 4004 | 'af': af, |
| 4005 | }) |
| 4006 | |
| 4007 | def svs_route_add_del(self, table_id, prefix, src_table_id, is_add=1): |
| 4008 | return self.api(self.papi.svs_route_add_del, |
| 4009 | { |
| 4010 | 'table_id': table_id, |
| 4011 | 'source_table_id': src_table_id, |
| 4012 | 'prefix': prefix, |
| 4013 | 'is_add': is_add, |
| 4014 | }) |
| 4015 | |
| 4016 | def svs_enable_disable(self, af, table_id, sw_if_index, is_enable=1): |
| 4017 | return self.api(self.papi.svs_enable_disable, |
| 4018 | { |
| 4019 | 'af': af, |
| 4020 | 'table_id': table_id, |
| 4021 | 'sw_if_index': sw_if_index, |
| 4022 | 'is_enable': is_enable, |
| 4023 | }) |
| 4024 | |
| 4025 | def svs_dump(self): |
| 4026 | return self.api(self.papi.svs_dump, {}) |