:orphan: .. index:: pair: group; Control network channel using a gateway .. _doxid-group__ts__tapi__route__gw: Control network channel using a gateway ======================================= .. toctree:: :hidden: struct_tapi_route_gateway.rst Overview ~~~~~~~~ Macros and functions for gateway configuration to be used in tests. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block // typedefs typedef struct :ref:`tapi_route_gateway` :ref:`tapi_route_gateway`; // structs struct :ref:`tapi_route_gateway`; // global functions :ref:`te_errno` :ref:`tapi_add_dynamic_arp`(const char* ta_src, const char* ifname_src, const char* ta_dest, const char* ifname_dest, const struct sockaddr* addr_dest, const struct sockaddr* link_addr_dest); :ref:`te_errno` :ref:`tapi_add_static_arp`(const char* ta_src, const char* ifname_src, const char* ta_dest, const char* ifname_dest, const struct sockaddr* addr_dest, const struct sockaddr* link_addr_dest); :ref:`te_errno` :ref:`tapi_update_arp`(const char* ta_src, const char* ifname_src, const char* ta_dest, const char* ifname_dest, const struct sockaddr* addr_dest, const void* link_addr_dest, bool is_static); :ref:`te_errno` :ref:`tapi_remove_arp`(const char* ta, const char* if_name, const struct sockaddr* net_addr); :ref:`te_errno` :ref:`tapi_route_gateway_init`(:ref:`tapi_route_gateway`* gw, const char* iut_ta, const char* tst_ta, const char* gw_ta, const struct if_nameindex* iut_if, const struct if_nameindex* tst_if, const struct if_nameindex* gw_iut_if, const struct if_nameindex* gw_tst_if, const struct sockaddr* iut_addr, const struct sockaddr* tst_addr, const struct sockaddr* gw_iut_addr, const struct sockaddr* gw_tst_addr, const struct sockaddr* alien_link_addr); :ref:`te_errno` :ref:`tapi_route_gateway_configure`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_set_forwarding`(:ref:`tapi_route_gateway`* gw, bool enabled); :ref:`te_errno` :ref:`tapi_route_gateway_break_gw_iut`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_repair_gw_iut`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_break_gw_tst`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_repair_gw_tst`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_break_iut_gw`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_repair_iut_gw`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_break_tst_gw`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_repair_tst_gw`(:ref:`tapi_route_gateway`* gw); :ref:`te_errno` :ref:`tapi_route_gateway_down_up_ifaces`(:ref:`tapi_route_gateway`* gw); // macros #define :ref:`TAPI_DECLARE_ROUTE_GATEWAY_PARAMS` #define :ref:`TAPI_GET_ROUTE_GATEWAY_PARAMS` #define :ref:`TAPI_INIT_ROUTE_GATEWAY`(gw_) .. _details-group__ts__tapi__route__gw: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Macros and functions for gateway configuration to be used in tests. "Gateway" here is the third host which forwards packets between two testing hosts not connected directly. The header must be included from test sources only. It is allowed to use the macros only from **main()** function of the test. Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved. Typedefs -------- .. index:: pair: typedef; tapi_route_gateway .. _doxid-group__ts__tapi__route__gw_1ga72389b7f8064b60a5f89d86567af0736: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef struct :ref:`tapi_route_gateway` tapi_route_gateway Structure describing gateway connecting IUT and Tester hosts. Global Functions ---------------- .. index:: pair: function; tapi_add_dynamic_arp .. _doxid-group__ts__tapi__route__gw_1ga8f36f3f02b9c4a1103e58636dbd7d441: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_add_dynamic_arp(const char* ta_src, const char* ifname_src, const char* ta_dest, const char* ifname_dest, const struct sockaddr* addr_dest, const struct sockaddr* link_addr_dest) Add dynamic entry to neighbour table. Netlink does not allow to make address resolution at a reasonable time if it does not know where to send the request. Therefore the dst MAC address is required. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta_src - Source TA. * - ifname_src - Source interface name. * - ta_dest - Destination TA. * - ifname_dest - Destination interface name. * - addr_dest - Destination address. * - link_addr_dest - New destination MAC or ``NULL``. If ``NULL`` link address of ``ta_dest`` interface will be used. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_add_static_arp .. _doxid-group__ts__tapi__route__gw_1ga9b5f9d7613cb96a61bf1bc10dbf39c70: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_add_static_arp(const char* ta_src, const char* ifname_src, const char* ta_dest, const char* ifname_dest, const struct sockaddr* addr_dest, const struct sockaddr* link_addr_dest) Add static entry to neighbour table with fake or actual MAC address. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta_src - Source TA. * - ifname_src - Source interface name. * - ta_dest - Destination TA. * - ifname_dest - Destination interface name. * - addr_dest - Destination address. * - link_addr_dest - New destination MAC or ``NULL``. If ``NULL`` link address of ``ta_dest`` interface will be used. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_update_arp .. _doxid-group__ts__tapi__route__gw_1gace09d5c00a4344902a9daa4125bb0c0d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_update_arp(const char* ta_src, const char* ifname_src, const char* ta_dest, const char* ifname_dest, const struct sockaddr* addr_dest, const void* link_addr_dest, bool is_static) Update entry in the neighbour table. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta_src - Source TA. * - ifname_src - Source interface name. * - ta_dest - Destination TA. * - ifname_dest - Destination interface name. * - addr_dest - Destination address. * - link_addr_dest - New destination MAC or ``NULL``. * - is_static - If the new ARP row should be static. .. rubric:: Returns: Status code. .. rubric:: See also: :ref:`tapi_add_static_arp `, tapi_add_dynmaic_arp .. index:: pair: function; tapi_remove_arp .. _doxid-group__ts__tapi__route__gw_1ga934fdde1d4e2ff71e13ef331ff3f6a5d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_remove_arp(const char* ta, const char* if_name, const struct sockaddr* net_addr) Remove existing ARP table entry, wait for a while, check that it did not reappear automatically. If it did, try to remove it again a few times before giving up. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ta - Test Agent name. * - if_name - Interface name. * - net_addr - IP address. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_init .. _doxid-group__ts__tapi__route__gw_1ga426f99cafa42a0c0a1aa0ac37fdd769c: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_init(:ref:`tapi_route_gateway`* gw, const char* iut_ta, const char* tst_ta, const char* gw_ta, const struct if_nameindex* iut_if, const struct if_nameindex* tst_if, const struct if_nameindex* gw_iut_if, const struct if_nameindex* gw_tst_if, const struct sockaddr* iut_addr, const struct sockaddr* tst_addr, const struct sockaddr* gw_iut_addr, const struct sockaddr* gw_tst_addr, const struct sockaddr* alien_link_addr) Initialize gateway structure. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Pointer to gateway structure. * - iut_ta - TA on IUT. * - tst_ta - TA on Tester. * - gw_ta - TA on gateway. * - iut_if - Network interface on IUT. * - tst_if - Network interface on Tester. * - gw_iut_if - Network interface on gateway connected to IUT. * - gw_tst_if - Network interface on gateway connected to Tester. * - iut_addr - Network address on IUT. * - tst_addr - Network address on Tester. * - gw_iut_addr - Network address on ``gw_iut_if``. * - gw_tst_addr - Network address on ``gw_tst_if``. * - alien_link_addr - Alien ethernet address. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_configure .. _doxid-group__ts__tapi__route__gw_1ga777597392d0e6b782559c646b1b601ae: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_configure(:ref:`tapi_route_gateway`* gw) Configure connection via gateway. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_set_forwarding .. _doxid-group__ts__tapi__route__gw_1gab81c21c7e5d19ce3d15e388d47924fc7: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_set_forwarding(:ref:`tapi_route_gateway`* gw, bool enabled) Enable or disable IPv4 or IPv6 forwarding on gateway. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_break_gw_iut .. _doxid-group__ts__tapi__route__gw_1ga2a0ec27813846514f565805f44539a30: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_break_gw_iut(:ref:`tapi_route_gateway`* gw) Break connection from gateway to IUT. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_repair_gw_iut .. _doxid-group__ts__tapi__route__gw_1ga85e6d5265adf3479f7fca727deab7b8a: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_repair_gw_iut(:ref:`tapi_route_gateway`* gw) Repair connection from gateway to IUT. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_break_gw_tst .. _doxid-group__ts__tapi__route__gw_1ga0f87a7796970d8b8033cc910456d9488: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_break_gw_tst(:ref:`tapi_route_gateway`* gw) Break connection from gateway to Tester. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_repair_gw_tst .. _doxid-group__ts__tapi__route__gw_1ga2df28ba9498f94670450f4e7234e7a85: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_repair_gw_tst(:ref:`tapi_route_gateway`* gw) Repair connection from gateway to Tester. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_break_iut_gw .. _doxid-group__ts__tapi__route__gw_1ga5f863da0a72cfbf616941a87d70677a3: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_break_iut_gw(:ref:`tapi_route_gateway`* gw) Break connection from IUT to gateway. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_repair_iut_gw .. _doxid-group__ts__tapi__route__gw_1gaa0b1ff414b349a0788573e217ed54ae2: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_repair_iut_gw(:ref:`tapi_route_gateway`* gw) Repair connection from IUT to gateway. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_break_tst_gw .. _doxid-group__ts__tapi__route__gw_1ga3a7ef4de8a787d4246574b889728d879: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_break_tst_gw(:ref:`tapi_route_gateway`* gw) Break connection from Tester to gateway. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_repair_tst_gw .. _doxid-group__ts__tapi__route__gw_1ga7a815dfc1cfefb74d5b7785b1a286f79: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_repair_tst_gw(:ref:`tapi_route_gateway`* gw) Repair connection from Tester to gateway. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. .. index:: pair: function; tapi_route_gateway_down_up_ifaces .. _doxid-group__ts__tapi__route__gw_1ga66b979cd6aaa3d30f85fba519420f4a1: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` tapi_route_gateway_down_up_ifaces(:ref:`tapi_route_gateway`* gw) Down up all interfaces that were in gateway connection. Caller should take care about wait for the interfaces to be raised. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw - Gateway description. .. rubric:: Returns: Status code. Macros ------ .. index:: pair: define; TAPI_DECLARE_ROUTE_GATEWAY_PARAMS .. _doxid-group__ts__tapi__route__gw_1ga655c279497dfe6361afea956208322d1: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define TAPI_DECLARE_ROUTE_GATEWAY_PARAMS Declare test parameters related to gateway configuration. .. index:: pair: define; TAPI_GET_ROUTE_GATEWAY_PARAMS .. _doxid-group__ts__tapi__route__gw_1gabc691bd46400de872c36207cdb4dab8e: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define TAPI_GET_ROUTE_GATEWAY_PARAMS Get test parameters related to gateway configuration. .. index:: pair: define; TAPI_INIT_ROUTE_GATEWAY .. _doxid-group__ts__tapi__route__gw_1ga7d53b9dd2dcd8f1ec2c3c3a370fc447f: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define TAPI_INIT_ROUTE_GATEWAY(gw_) Initialize gateway structure. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - gw\_ - Gateway structure.