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