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