summaryrefslogtreecommitdiffstats
path: root/docs/nspr/reference/prhostent.rst
blob: daf2d89d402234d4b3e1e3525888c20be4fe85e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
PRHostEnt
=========

A structure that defines a list of network addresses. This structure is
output from :ref:`PR_GetHostByName` and :ref:`PR_GetHostByAddr` and passed to
:ref:`PR_EnumerateHostEnt`. Clients should avoid directly accessing any of
the structure's fields.


Syntax
------

.. code::

   #include <prnetdb.h>

   typedef struct PRHostEnt {
     char *h_name;
     char **h_aliases;
   #if defined(_WIN32)
     PRInt16 h_addrtype;
     PRInt16 h_length;
   #else
     PRInt32 h_addrtype;
     PRInt32 h_length;
   #endif
     char **h_addr_list;
   } PRHostEnt;


Fields
~~~~~~

The structure has the following fields:

``h_name``
   Pointer to the official name of host.
``h_aliases``
   Pointer to a pointer to list of aliases. The list is terminated with
   a ``NULL`` entry.
``h_addrtype``
   Host address type. For valid NSPR usage, this field must have a value
   indicating either an IPv4 or an IPv6 address.
``h_length``
   Length of internal representation of the address in bytes. All of the
   addresses in the list are of the same type and therefore of the same
   length.
``h_addr_list``
   Pointer to a pointer to a list of addresses from name server (in
   network byte order). The list is terminated with a ``NULL`` entry.


Description
-----------

This structure is used by many of the network address functions. All
addresses are passed in host order and returned in network order
(suitable for use in system calls).

Use the network address functions to manipulate the :ref:`PRHostEnt`
structure. To make the transition to IP version 6 easier, it's best to
treat :ref:`PRHostEnt` as an opaque structure.

Note
----

``WINSOCK.H`` defines ``h_addrtype`` and ``h_length`` as a 16-bit field,
whereas other platforms treat it as a 32-bit field. The ``#ifdef`` in
the structure allows direct assignment of the :ref:`PRHostEnt` structure.