:orphan: .. index:: pair: group; Sockaddr .. _doxid-group__te__tools__te__sockaddr: Sockaddr ======== .. toctree:: :hidden: struct_te_sockaddr_subnet.rst Overview ~~~~~~~~ Definition of API for working with struct sockaddr. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block // typedefs typedef struct :ref:`te_sockaddr_subnet` :ref:`te_sockaddr_subnet`; // structs struct :ref:`te_sockaddr_subnet`; // global functions static bool :ref:`te_sockaddr_is_af_supported`(int af); void :ref:`te_sockaddr_clear_port`(struct sockaddr* addr); uint16_t* :ref:`te_sockaddr_get_port_ptr`(const struct sockaddr* addr); static uint16_t :ref:`te_sockaddr_get_port`(const struct sockaddr* addr); void :ref:`te_sockaddr_set_port`(struct sockaddr* addr, uint16_t port); void* :ref:`te_sockaddr_get_netaddr`(const struct sockaddr* addr); const char* :ref:`te_sockaddr_get_ipstr`(const struct sockaddr* addr); char* :ref:`te_ip2str`(const struct sockaddr* addr); :ref:`te_errno` :ref:`te_ip_addr2te_str`(:ref:`te_string`* str, const void* ip_addr, int af); :ref:`te_errno` :ref:`te_mac_addr2te_str`(:ref:`te_string`* str, const uint8_t* mac_addr); int :ref:`te_sockaddr_set_netaddr`(struct sockaddr* addr, const void* net_addr); void :ref:`te_sockaddr_set_wildcard`(struct sockaddr* addr); void :ref:`te_sockaddr_set_loopback`(struct sockaddr* addr); void :ref:`te_sockaddr_set_multicast`(struct sockaddr* addr); bool :ref:`te_sockaddr_is_wildcard`(const struct sockaddr* addr); bool :ref:`te_sockaddr_is_multicast`(const struct sockaddr* addr); size_t :ref:`te_sockaddr_get_size_by_af`(int af); size_t :ref:`te_sockaddr_get_size`(const struct sockaddr* addr); :ref:`te_errno` :ref:`te_sockaddr_mask_by_prefix`(struct sockaddr* mask, socklen_t masklen, int af, unsigned int prefix); :ref:`te_errno` :ref:`te_sockaddr_cleanup_to_prefix`(struct sockaddr* addr, unsigned int prefix); int :ref:`te_sockaddrcmp`(const struct sockaddr* a1, socklen_t a1len, const struct sockaddr* a2, socklen_t a2len); int :ref:`te_sockaddrcmp_no_ports`(const struct sockaddr* a1, socklen_t a1len, const struct sockaddr* a2, socklen_t a2len); int :ref:`te_sockaddrncmp`(const struct sockaddr* a1, socklen_t a1len, const struct sockaddr* a2, socklen_t a2len); :ref:`te_errno` :ref:`te_sockaddr2str_buf`(const struct sockaddr* sa, char* buf, size_t len); const char* :ref:`te_sockaddr2str`(const struct sockaddr* sa); :ref:`te_errno` :ref:`te_sockaddr_h2str_buf`(const struct sockaddr* sa, char* buf, size_t len); :ref:`te_errno` :ref:`te_sockaddr_h2str`(const struct sockaddr* sa, char** string); :ref:`te_errno` :ref:`te_sockaddr_str2h`(const char* string, struct sockaddr* sa); size_t :ref:`te_netaddr_get_size`(int af); size_t :ref:`te_netaddr_get_bitsize`(int af); :ref:`te_errno` :ref:`te_netaddr2te_str`(const struct sockaddr* sa, :ref:`te_string`* str); void :ref:`te_mreq_set_mr_multiaddr`(int af, void* mreq, const void* addr); void :ref:`te_mreq_set_mr_interface`(int af, void* mreq, const void* addr); void :ref:`te_mreq_set_mr_ifindex`(int af, void* mreq, int ifindex); :ref:`te_errno` :ref:`te_sockaddr_netaddr_from_string`(const char* addr_str, struct sockaddr* addr); const char* :ref:`te_sockaddr_netaddr_to_string`(int af, const void* net_addr); :ref:`te_errno` :ref:`te_sockaddr_ip4_to_ip6_mapped`(struct sockaddr* addr); // macros #define :ref:`MASK2PREFIX`(mask, prefix) #define :ref:`PREFIX2MASK`(prefix) #define :ref:`TE_SOCKADDR_STR_LEN` .. _details-group__te__tools__te__sockaddr: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Definition of API for working with struct sockaddr. Typedefs -------- .. index:: pair: typedef; te_sockaddr_subnet .. _doxid-group__te__tools__te__sockaddr_1gae8577a0b8562c2784da6f86e41aeb83f: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef struct :ref:`te_sockaddr_subnet` te_sockaddr_subnet An address with a network prefix. Global Functions ---------------- .. index:: pair: function; te_sockaddr_is_af_supported .. _doxid-group__te__tools__te__sockaddr_1gafccc334c7c5cb30390da79072ccb7da2: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool te_sockaddr_is_af_supported(int af) Is address family is supported by this TAPI? .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family .. index:: pair: function; te_sockaddr_clear_port .. _doxid-group__te__tools__te__sockaddr_1gac3ba1bee7127a580702512ee4a640319: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_sockaddr_clear_port(struct sockaddr* addr) Set "port" part of corresponding struct sockaddr to zero (wildcard) The function is not very safe because it does not get the length of the structure assuming that there is enough space for a structure defined from the value of "sa_family" field. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. index:: pair: function; te_sockaddr_get_port_ptr .. _doxid-group__te__tools__te__sockaddr_1ga8f658760beb604c3df272face97e5fe7: .. ref-code-block:: cpp :class: doxyrest-title-code-block uint16_t* te_sockaddr_get_port_ptr(const struct sockaddr* addr) Get pointer to "port" part of corresponding struct sockaddr. The function is not very safe because it does not get the length of the structure assuming that there is enough space for a structure defined from the value of "sa_family" field. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. rubric:: Returns: Pointer to "port" part .. index:: pair: function; te_sockaddr_get_port .. _doxid-group__te__tools__te__sockaddr_1gaf215c023ae16f6b9cd079e4381e9b16c: .. ref-code-block:: cpp :class: doxyrest-title-code-block static uint16_t te_sockaddr_get_port(const struct sockaddr* addr) Get "port" part of corresponding struct sockaddr. The function is not very safe because it does not get the length of the structure assuming that there is enough space for a structure defined from the value of "sa_family" field. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. rubric:: Returns: Port number in network byte order .. index:: pair: function; te_sockaddr_set_port .. _doxid-group__te__tools__te__sockaddr_1gab8530d597a3807fc8d2a9f8d54bfa14f: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_sockaddr_set_port(struct sockaddr* addr, uint16_t port) Update "port" part of corresponding struct sockaddr. The function is not very safe because it does not get the length of the structure assuming that there is enough space for a structure defined from the value of "sa_family" field. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure * - port - A new port value (port should be in network byte order) .. index:: pair: function; te_sockaddr_get_netaddr .. _doxid-group__te__tools__te__sockaddr_1gaa5aeccf08d54f5cc9e0fed0d5ae78039: .. ref-code-block:: cpp :class: doxyrest-title-code-block void* te_sockaddr_get_netaddr(const struct sockaddr* addr) Returns pointer to network address part of sockaddr structure according to 'sa_family' field of the structure. If ``addr`` is ``NULL``, this function simply returns ``NULL``. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. rubric:: Returns: Pointer to corresponding network address or ``NULL``. .. index:: pair: function; te_sockaddr_get_ipstr .. _doxid-group__te__tools__te__sockaddr_1gab5761fd76194d6780451dfe2ccaa697e: .. ref-code-block:: cpp :class: doxyrest-title-code-block const char* te_sockaddr_get_ipstr(const struct sockaddr* addr) Returns pointer to the IP 4/6 address in human representation (without port). non-rentarable non-thread-safe does not perform any checks .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - address to be converted .. rubric:: Returns: address string .. rubric:: See also: :ref:`te_ip2str `, :ref:`te_sockaddr2str ` .. index:: pair: function; te_ip2str .. _doxid-group__te__tools__te__sockaddr_1ga7d4fa4f170f9788f30bf0528140b36a6: .. ref-code-block:: cpp :class: doxyrest-title-code-block char* te_ip2str(const struct sockaddr* addr) Convert IPv4 and IPv6 addresses from binary to text form. Return value should be freed with free(3) when it is no longer needed. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - IP address. .. rubric:: Returns: String representation of IP address, or ``NULL`` in case of error. .. rubric:: See also: :ref:`te_sockaddr_get_ipstr `, :ref:`te_sockaddr2str ` .. index:: pair: function; te_ip_addr2te_str .. _doxid-group__te__tools__te__sockaddr_1gaee37c86508802e3d99546831c07ebd28: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_ip_addr2te_str(:ref:`te_string`* str, const void* ip_addr, int af) Append IPv4 or IPv6 address to TE string. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - str - Pointer to TE string * - ip_addr - Pointer to in_addr or in6_addr * - af - ``AF_INET`` or ``AF_INET6`` .. rubric:: Returns: Status code. .. index:: pair: function; te_mac_addr2te_str .. _doxid-group__te__tools__te__sockaddr_1ga006c48bab198d83fa046ad24b88e3e2e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_mac_addr2te_str(:ref:`te_string`* str, const uint8_t* mac_addr) Append MAC address to TE string. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - str - Pointer to the TE string * - mac_addr - Pointer to the MAC address .. rubric:: Returns: Status code (always 0). .. index:: pair: function; te_sockaddr_set_netaddr .. _doxid-group__te__tools__te__sockaddr_1ga5293f4a38b2d94dcb094a52143221fb9: .. ref-code-block:: cpp :class: doxyrest-title-code-block int te_sockaddr_set_netaddr(struct sockaddr* addr, const void* net_addr) Update network address part of sockaddr structure according to 'sa_family' field of the structure .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure * - net_addr - Pointer to the network address to be set * - 0 - on success * - -1 - on failure .. rubric:: Returns: Result of the operation .. index:: pair: function; te_sockaddr_set_wildcard .. _doxid-group__te__tools__te__sockaddr_1gac8e4e0ad170e02e9e72e7ff54561541c: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_sockaddr_set_wildcard(struct sockaddr* addr) Set "network address" part of corresponding struct sockaddr to wildcard The function is not very safe because it does not get the length of the structure assuming that there is enough space for a structure defined from the value of "sa_family" field. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. index:: pair: function; te_sockaddr_set_loopback .. _doxid-group__te__tools__te__sockaddr_1gac05bb3d11b17a6c85ea4de9d40ef05ee: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_sockaddr_set_loopback(struct sockaddr* addr) Set "network address" part of corresponding struct sockaddr to loopback The function is not very safe because it does not get the length of the structure assuming that there is enough space for a structure defined from the value of "sa_family" field. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. index:: pair: function; te_sockaddr_set_multicast .. _doxid-group__te__tools__te__sockaddr_1ga240497e2062373b9240daef5ebecc9d4: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_sockaddr_set_multicast(struct sockaddr* addr) Set "network address" part of corresponding struct sockaddr to randomly chosen multicast address. The function is not very safe because it does not get the length of the structure assuming that there is enough space for an address. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. index:: pair: function; te_sockaddr_is_wildcard .. _doxid-group__te__tools__te__sockaddr_1gaba8a91a0c8d18e1b9f74a219ca672006: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool te_sockaddr_is_wildcard(const struct sockaddr* addr) Check if "network address" part of corresponding struct sockaddr is wildcard The function is not very safe because it does not get the length of the structure assuming that there is enough space for a structure defined from the value of "sa_family" field. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. rubric:: Returns: Is "network address" part wildcard? .. index:: pair: function; te_sockaddr_is_multicast .. _doxid-group__te__tools__te__sockaddr_1ga0c31156f023165c7d858adf13f67115b: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool te_sockaddr_is_multicast(const struct sockaddr* addr) Check if "network address" part of corresponding struct sockaddr is multicast address .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address struture .. rubric:: Returns: ``true/false`` - multicast/other address .. index:: pair: function; te_sockaddr_get_size_by_af .. _doxid-group__te__tools__te__sockaddr_1gaeb1c81c51450a4046a05ff552ccb5ef5: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t te_sockaddr_get_size_by_af(int af) Returns the size of a particular sockaddr structure according to its family. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family .. rubric:: Returns: Address size .. index:: pair: function; te_sockaddr_get_size .. _doxid-group__te__tools__te__sockaddr_1gac134be91e3c9929164d23aa0a4d9d47c: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t te_sockaddr_get_size(const struct sockaddr* addr) Returns the size of a particular sockaddr structure according to 'sa_family' field of the structure .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Generic address structure .. rubric:: Returns: Address size .. index:: pair: function; te_sockaddr_mask_by_prefix .. _doxid-group__te__tools__te__sockaddr_1ga70e97939f269a996c3ab32810130e534: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr_mask_by_prefix(struct sockaddr* mask, socklen_t masklen, int af, unsigned int prefix) Create mask in 'struct sockaddr' by prefix length. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - mask - Location for mask * - masklen - Size of the memory for mask * - af - Address family * - prefix - Prefix length .. rubric:: Returns: Status code. .. index:: pair: function; te_sockaddr_cleanup_to_prefix .. _doxid-group__te__tools__te__sockaddr_1ga058b78f66c1d93902e374ce8f81f3a9e: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr_cleanup_to_prefix(struct sockaddr* addr, unsigned int prefix) Clean up network address part to be prefix of specified length. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - address * - prefix - prefix length .. rubric:: Returns: Status code. .. index:: pair: function; te_sockaddrcmp .. _doxid-group__te__tools__te__sockaddr_1ga1e7748975a25f43659a231248d0fd5af: .. ref-code-block:: cpp :class: doxyrest-title-code-block int te_sockaddrcmp(const struct sockaddr* a1, socklen_t a1len, const struct sockaddr* a2, socklen_t a2len) Compare 'struct sockaddr'. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - a1 - the first address * - a1len - the first address length * - a2 - the second address * - a2len - the second address length * - 0 - equal * - -1 - not equal * - -2 - comparison of addresses of unsupported family .. index:: pair: function; te_sockaddrcmp_no_ports .. _doxid-group__te__tools__te__sockaddr_1ga9b34ce5feaa06190e1efd4a21ad79041: .. ref-code-block:: cpp :class: doxyrest-title-code-block int te_sockaddrcmp_no_ports(const struct sockaddr* a1, socklen_t a1len, const struct sockaddr* a2, socklen_t a2len) Compare 'struct sockaddr', not taking ports into account. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - a1 - the first address * - a1len - the first address length * - a2 - the second address * - a2len - the second address length * - 0 - equal * - -1 - not equal * - -2 - comparison of addresses of unsupported family .. index:: pair: function; te_sockaddrncmp .. _doxid-group__te__tools__te__sockaddr_1ga19e343853638210f34bc3ece30a402bf: .. ref-code-block:: cpp :class: doxyrest-title-code-block int te_sockaddrncmp(const struct sockaddr* a1, socklen_t a1len, const struct sockaddr* a2, socklen_t a2len) Compare the content of two 'struct sockaddr' structures till minimum of two lengths a1len and a2len. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - a1 - the first address * - a1len - the first address length * - a2 - the second address * - a2len - the second address length * - 0 - equal * - -1 - not equal * - -2 - comparison of addresses of unsupported family .. index:: pair: function; te_sockaddr2str_buf .. _doxid-group__te__tools__te__sockaddr_1gac321fc489fa88a50540a95fa9cd2a405: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr2str_buf(const struct sockaddr* sa, char* buf, size_t len) Convert 'struct sockaddr' to string (it prints not only address but also port and other fields). .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - sa - Pointer to 'struct sockaddr'. * - buf - Where to save string. * - len - Length of the buffer. .. rubric:: Returns: Status code. .. index:: pair: function; te_sockaddr2str .. _doxid-group__te__tools__te__sockaddr_1ga0f06a5989a3879f125a473b9aeb3478b: .. ref-code-block:: cpp :class: doxyrest-title-code-block const char* te_sockaddr2str(const struct sockaddr* sa) Convert 'struct sockaddr' to string (it prints not only address but also port and other fields). Static buffer is used for return value. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - sa - - pointer to 'struct sockaddr' .. rubric:: Returns: null-terminated string .. rubric:: See also: :ref:`te_sockaddr_get_ipstr `, :ref:`te_ip2str ` .. index:: pair: function; te_sockaddr_h2str_buf .. _doxid-group__te__tools__te__sockaddr_1ga55aaa60c7db1e330022166f9ea0a470f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr_h2str_buf(const struct sockaddr* sa, char* buf, size_t len) Convert sockaddr to string, save result in a provided buffer. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - sa - Pointer to struct sockaddr. * - buf - Where to save a string representation. * - len - Number of bytes available for a string. .. rubric:: Returns: Status code. .. index:: pair: function; te_sockaddr_h2str .. _doxid-group__te__tools__te__sockaddr_1ga1d2626904036ba86c7c3506189654305: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr_h2str(const struct sockaddr* sa, char** string) Convert a **sockaddr** to a string or return an error. Free allocated memory on **string** .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - sa - source **sockaddr** * - string - result of conversion * - 0 - successful * - TE_EAFNOSUPPORT - family is not supported * - value - of **errno** **inet_ntop** was fail .. rubric:: Returns: status code .. index:: pair: function; te_sockaddr_str2h .. _doxid-group__te__tools__te__sockaddr_1ga3efffd74e7c953ad4676f37025e9ef41: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr_str2h(const char* string, struct sockaddr* sa) Convert a string to a **sockaddr** or return an error. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - string - source string * - sa - result **sockaddr** * - 0 - successful * - TE_EAFNOSUPPORT - family is not supported * - TE_EINVAL - ``string`` doesn't contain a valid network address .. rubric:: Returns: status code .. index:: pair: function; te_netaddr_get_size .. _doxid-group__te__tools__te__sockaddr_1ga31ee0e90f903826328af9757d065b0ef: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t te_netaddr_get_size(int af) Returns the size of network address from a particular family (in bytes). .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family .. rubric:: Returns: Number of bytes used under network address .. index:: pair: function; te_netaddr_get_bitsize .. _doxid-group__te__tools__te__sockaddr_1ga49bb6b428319fe667799646360cb8a85: .. ref-code-block:: cpp :class: doxyrest-title-code-block size_t te_netaddr_get_bitsize(int af) Returns the size of network address from a particular family (in bits). .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family .. rubric:: Returns: Number of bits required to store network address. .. index:: pair: function; te_netaddr2te_str .. _doxid-group__te__tools__te__sockaddr_1ga461de3fc3d1ba34abe2dd780fbeb6c55: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_netaddr2te_str(const struct sockaddr* sa, :ref:`te_string`* str) Append IPv4, IPv6 or MAC address to TE string. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - sa[in] - pointer to struct sockaddr * - str[out] - pointer to TE string .. rubric:: Returns: Status code. .. index:: pair: function; te_mreq_set_mr_multiaddr .. _doxid-group__te__tools__te__sockaddr_1ga7d2598969f0a7741145ff822b6452062: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_mreq_set_mr_multiaddr(int af, void* mreq, const void* addr) Set multicast address part of XXX_mreq(n) structure .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family * - mreq - Generic mreq structure * - addr - Multicast address .. index:: pair: function; te_mreq_set_mr_interface .. _doxid-group__te__tools__te__sockaddr_1ga2a80c554caa7db59ab577e112f2d9ebf: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_mreq_set_mr_interface(int af, void* mreq, const void* addr) Set interface part of XXX_mreq(n) structure .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family * - mreq - Generic mreq structure * - addr - Interface address .. index:: pair: function; te_mreq_set_mr_ifindex .. _doxid-group__te__tools__te__sockaddr_1ga2dae6e3f5d8108b532c86a45689dc8db: .. ref-code-block:: cpp :class: doxyrest-title-code-block void te_mreq_set_mr_ifindex(int af, void* mreq, int ifindex) Set interface index part of XXX_mreq(n) structure .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family * - mreq - Generic mreq structure * - ifindex - Interface index .. index:: pair: function; te_sockaddr_netaddr_from_string .. _doxid-group__te__tools__te__sockaddr_1ga9796946f056f1732b0b4afad1336655f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr_netaddr_from_string(const char* addr_str, struct sockaddr* addr) Convert network address from string and put it in provided sockaddr structure. Set address family appropriately. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr_str - Address in string format * - addr - Location for the address (should be sufficient for sockadddr structure which corresponds to provided address in string format, e.g. struct te_sockaddr_storage) .. rubric:: Returns: Status code. .. index:: pair: function; te_sockaddr_netaddr_to_string .. _doxid-group__te__tools__te__sockaddr_1ga3b8153ae56b2e39a053c55eb51eb7cfa: .. ref-code-block:: cpp :class: doxyrest-title-code-block const char* te_sockaddr_netaddr_to_string(int af, const void* net_addr) Convert network address to its string representation. It returns statically allocated string using :ref:`te_sockaddr_get_ipstr() ` .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - af - Address family * - net_addr - Network address in form acceptable to :ref:`te_sockaddr_set_netaddr() ` .. rubric:: Returns: Network address string representation, or ``NULL`` in case of error .. index:: pair: function; te_sockaddr_ip4_to_ip6_mapped .. _doxid-group__te__tools__te__sockaddr_1ga528ca48cb12457079971bfbff628ed40: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`te_errno` te_sockaddr_ip4_to_ip6_mapped(struct sockaddr* addr) Convert IPv4 address to IPv4-mapped IPv6 one. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - addr - Sockaddr structure containing address. It must be large enough to hold IPv6 address. .. rubric:: Returns: Status code. Macros ------ .. index:: pair: define; MASK2PREFIX .. _doxid-group__te__tools__te__sockaddr_1ga6aa44e66d772cacd6b3b538fd0291a08: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define MASK2PREFIX(mask, prefix) Fast conversion of IPv4 the network mask to prefix .. index:: pair: define; PREFIX2MASK .. _doxid-group__te__tools__te__sockaddr_1ga891e80c7ef818ba7454269adb711e70a: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define PREFIX2MASK(prefix) Fast conversion of the IPv4 prefix to network mask .. index:: pair: define; TE_SOCKADDR_STR_LEN .. _doxid-group__te__tools__te__sockaddr_1ga349d77a4c44c25519e74e3485bfd9d1e: .. ref-code-block:: cpp :class: doxyrest-title-code-block #define TE_SOCKADDR_STR_LEN Number of bytes which should be enough for string representation of sockaddr structure