tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

pr_initializenetaddr.rst (2115B)


      1 PR_InitializeNetAddr
      2 ====================
      3 
      4 Initializes or reinitializes a network address. The storage for the
      5 network address structure is allocated by, and remains the
      6 responsibility of, the calling client.
      7 
      8 
      9 Syntax
     10 ------
     11 
     12 .. code::
     13 
     14   #include <prnetdb.h>
     15 
     16   PRStatus PR_InitializeNetAddr(
     17     PRNetAddrValue val,
     18     PRUint16 port,
     19     PRNetAddr *addr);
     20 
     21 
     22 Parameters
     23 ~~~~~~~~~~
     24 
     25 The function has the following parameters:
     26 
     27 ``val``
     28   The value to be assigned to the IP Address portion of the network
     29   address. This must be ``PR_IpAddrNull``, ``PR_IpAddrAny``, or
     30   ``PR_IpAddrLoopback``.
     31 ``port``
     32   The port number to be assigned in the network address structure. The
     33   value is specified in host byte order.
     34 ``addr``
     35   A pointer to the :ref:`PRNetAddr` structure to be manipulated.
     36 
     37 
     38 Returns
     39 ~~~~~~~
     40 
     41 The function returns one of the following values:
     42 
     43 -  If successful, ``PR_SUCCESS``.
     44 -  If unsuccessful, ``PR_FAILURE``. This may occur, for example, if the
     45   value of val is not within the ranges defined by ``PRNetAddrValue``.
     46   You can retrieve the reason for the failure by calling
     47   :ref:`PR_GetError`.
     48 
     49 
     50 Description
     51 -----------
     52 
     53 :ref:`PR_InitializeNetAddr` allows the assignment of special network
     54 address values and the port number, while also setting the state that
     55 indicates the version of the address being used.
     56 
     57 The special network address values are identified by the enum
     58 ``PRNetAddrValue``:
     59 
     60 .. code::
     61 
     62   typedef enum PRNetAddrValue{
     63     PR_IpAddrNull,
     64     PR_IpAddrAny,
     65     PR_IpAddrLoopback
     66   } PRNetAddrValue;
     67 
     68 The enum has the following enumerators:
     69 
     70 ``PR_IpAddrNull``
     71   Do not overwrite the IP address. This allows the caller to change the
     72   network address' port number assignment without affecting the host
     73   address.
     74 ``PR_IpAddrAny``
     75   Assign logical ``PR_INADDR_ANY`` to IP address. This wildcard value
     76   is typically used to establish a socket on which to listen for
     77   incoming connection requests.
     78 ``PR_IpAddrLoopback``
     79   Assign logical ``PR_INADDR_LOOPBACK``. A client can use this value to
     80   connect to itself without knowing the host's network address.