Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef prnetdb_h___ |
michael@0 | 7 | #define prnetdb_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include "prtypes.h" |
michael@0 | 10 | #include "prio.h" |
michael@0 | 11 | |
michael@0 | 12 | PR_BEGIN_EXTERN_C |
michael@0 | 13 | |
michael@0 | 14 | |
michael@0 | 15 | /* |
michael@0 | 16 | ********************************************************************* |
michael@0 | 17 | * Translate an Internet address to/from a character string |
michael@0 | 18 | ********************************************************************* |
michael@0 | 19 | */ |
michael@0 | 20 | NSPR_API(PRStatus) PR_StringToNetAddr( |
michael@0 | 21 | const char *string, PRNetAddr *addr); |
michael@0 | 22 | |
michael@0 | 23 | NSPR_API(PRStatus) PR_NetAddrToString( |
michael@0 | 24 | const PRNetAddr *addr, char *string, PRUint32 size); |
michael@0 | 25 | |
michael@0 | 26 | /* |
michael@0 | 27 | ** Structures returned by network data base library. All addresses are |
michael@0 | 28 | ** supplied in host order, and returned in network order (suitable for |
michael@0 | 29 | ** use in system calls). |
michael@0 | 30 | */ |
michael@0 | 31 | /* |
michael@0 | 32 | ** Beware that WINSOCK.H defines h_addrtype and h_length as short. |
michael@0 | 33 | ** Client code does direct struct copies of hostent to PRHostEnt and |
michael@0 | 34 | ** hence the ifdef. |
michael@0 | 35 | */ |
michael@0 | 36 | typedef struct PRHostEnt { |
michael@0 | 37 | char *h_name; /* official name of host */ |
michael@0 | 38 | char **h_aliases; /* alias list */ |
michael@0 | 39 | #ifdef WIN32 |
michael@0 | 40 | PRInt16 h_addrtype; /* host address type */ |
michael@0 | 41 | PRInt16 h_length; /* length of address */ |
michael@0 | 42 | #else |
michael@0 | 43 | PRInt32 h_addrtype; /* host address type */ |
michael@0 | 44 | PRInt32 h_length; /* length of address */ |
michael@0 | 45 | #endif |
michael@0 | 46 | char **h_addr_list; /* list of addresses from name server */ |
michael@0 | 47 | } PRHostEnt; |
michael@0 | 48 | |
michael@0 | 49 | /* A safe size to use that will mostly work... */ |
michael@0 | 50 | #if (defined(AIX) && defined(_THREAD_SAFE)) || defined(OSF1) |
michael@0 | 51 | #define PR_NETDB_BUF_SIZE sizeof(struct protoent_data) |
michael@0 | 52 | #else |
michael@0 | 53 | #define PR_NETDB_BUF_SIZE 1024 |
michael@0 | 54 | #endif |
michael@0 | 55 | |
michael@0 | 56 | /*********************************************************************** |
michael@0 | 57 | ** FUNCTION: |
michael@0 | 58 | ** DESCRIPTION: PR_GetHostByName() |
michael@0 | 59 | ** Lookup a host by name. |
michael@0 | 60 | ** |
michael@0 | 61 | ** INPUTS: |
michael@0 | 62 | ** char *hostname Character string defining the host name of interest |
michael@0 | 63 | ** char *buf A scratch buffer for the runtime to return result. |
michael@0 | 64 | ** This buffer is allocated by the caller. |
michael@0 | 65 | ** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to |
michael@0 | 66 | ** use is PR_NETDB_BUF_SIZE. |
michael@0 | 67 | ** OUTPUTS: |
michael@0 | 68 | ** PRHostEnt *hostentry |
michael@0 | 69 | ** This structure is filled in by the runtime if |
michael@0 | 70 | ** the function returns PR_SUCCESS. This structure |
michael@0 | 71 | ** is allocated by the caller. |
michael@0 | 72 | ** RETURN: |
michael@0 | 73 | ** PRStatus PR_SUCCESS if the lookup succeeds. If it fails |
michael@0 | 74 | ** the result will be PR_FAILURE and the reason |
michael@0 | 75 | ** for the failure can be retrieved by PR_GetError(). |
michael@0 | 76 | ***********************************************************************/ |
michael@0 | 77 | NSPR_API(PRStatus) PR_GetHostByName( |
michael@0 | 78 | const char *hostname, char *buf, PRIntn bufsize, PRHostEnt *hostentry); |
michael@0 | 79 | |
michael@0 | 80 | /*********************************************************************** |
michael@0 | 81 | ** FUNCTION: |
michael@0 | 82 | ** DESCRIPTION: PR_GetIPNodeByName() |
michael@0 | 83 | ** Lookup a host by name. Equivalent to getipnodebyname(AI_DEFAULT) |
michael@0 | 84 | ** of RFC 2553. |
michael@0 | 85 | ** |
michael@0 | 86 | ** INPUTS: |
michael@0 | 87 | ** char *hostname Character string defining the host name of interest |
michael@0 | 88 | ** PRUint16 af Address family (either PR_AF_INET or PR_AF_INET6) |
michael@0 | 89 | ** PRIntn flags Specifies the types of addresses that are searched |
michael@0 | 90 | ** for and the types of addresses that are returned. |
michael@0 | 91 | ** The only supported flag is PR_AI_DEFAULT. |
michael@0 | 92 | ** char *buf A scratch buffer for the runtime to return result. |
michael@0 | 93 | ** This buffer is allocated by the caller. |
michael@0 | 94 | ** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to |
michael@0 | 95 | ** use is PR_NETDB_BUF_SIZE. |
michael@0 | 96 | ** OUTPUTS: |
michael@0 | 97 | ** PRHostEnt *hostentry |
michael@0 | 98 | ** This structure is filled in by the runtime if |
michael@0 | 99 | ** the function returns PR_SUCCESS. This structure |
michael@0 | 100 | ** is allocated by the caller. |
michael@0 | 101 | ** RETURN: |
michael@0 | 102 | ** PRStatus PR_SUCCESS if the lookup succeeds. If it fails |
michael@0 | 103 | ** the result will be PR_FAILURE and the reason |
michael@0 | 104 | ** for the failure can be retrieved by PR_GetError(). |
michael@0 | 105 | ***********************************************************************/ |
michael@0 | 106 | |
michael@0 | 107 | |
michael@0 | 108 | #define PR_AI_ALL 0x08 |
michael@0 | 109 | #define PR_AI_V4MAPPED 0x10 |
michael@0 | 110 | #define PR_AI_ADDRCONFIG 0x20 |
michael@0 | 111 | #define PR_AI_NOCANONNAME 0x8000 |
michael@0 | 112 | #define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG) |
michael@0 | 113 | |
michael@0 | 114 | NSPR_API(PRStatus) PR_GetIPNodeByName( |
michael@0 | 115 | const char *hostname, |
michael@0 | 116 | PRUint16 af, |
michael@0 | 117 | PRIntn flags, |
michael@0 | 118 | char *buf, |
michael@0 | 119 | PRIntn bufsize, |
michael@0 | 120 | PRHostEnt *hostentry); |
michael@0 | 121 | |
michael@0 | 122 | /*********************************************************************** |
michael@0 | 123 | ** FUNCTION: |
michael@0 | 124 | ** DESCRIPTION: PR_GetHostByAddr() |
michael@0 | 125 | ** Lookup a host entry by its network address. |
michael@0 | 126 | ** |
michael@0 | 127 | ** INPUTS: |
michael@0 | 128 | ** char *hostaddr IP address of host in question |
michael@0 | 129 | ** char *buf A scratch buffer for the runtime to return result. |
michael@0 | 130 | ** This buffer is allocated by the caller. |
michael@0 | 131 | ** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to |
michael@0 | 132 | ** use is PR_NETDB_BUF_SIZE. |
michael@0 | 133 | ** OUTPUTS: |
michael@0 | 134 | ** PRHostEnt *hostentry |
michael@0 | 135 | ** This structure is filled in by the runtime if |
michael@0 | 136 | ** the function returns PR_SUCCESS. This structure |
michael@0 | 137 | ** is allocated by the caller. |
michael@0 | 138 | ** RETURN: |
michael@0 | 139 | ** PRStatus PR_SUCCESS if the lookup succeeds. If it fails |
michael@0 | 140 | ** the result will be PR_FAILURE and the reason |
michael@0 | 141 | ** for the failure can be retrieved by PR_GetError(). |
michael@0 | 142 | ***********************************************************************/ |
michael@0 | 143 | NSPR_API(PRStatus) PR_GetHostByAddr( |
michael@0 | 144 | const PRNetAddr *hostaddr, char *buf, PRIntn bufsize, PRHostEnt *hostentry); |
michael@0 | 145 | |
michael@0 | 146 | /*********************************************************************** |
michael@0 | 147 | ** FUNCTION: PR_EnumerateHostEnt() |
michael@0 | 148 | ** DESCRIPTION: |
michael@0 | 149 | ** A stateless enumerator over a PRHostEnt structure acquired from |
michael@0 | 150 | ** PR_GetHostByName() PR_GetHostByAddr() to evaluate the possible |
michael@0 | 151 | ** network addresses. |
michael@0 | 152 | ** |
michael@0 | 153 | ** INPUTS: |
michael@0 | 154 | ** PRIntn enumIndex Index of the enumeration. The enumeration starts |
michael@0 | 155 | ** and ends with a value of zero. |
michael@0 | 156 | ** |
michael@0 | 157 | ** PRHostEnt *hostEnt A pointer to a host entry struct that was |
michael@0 | 158 | ** previously returned by PR_GetHostByName() or |
michael@0 | 159 | ** PR_GetHostByAddr(). |
michael@0 | 160 | ** |
michael@0 | 161 | ** PRUint16 port The port number to be assigned as part of the |
michael@0 | 162 | ** PRNetAddr. |
michael@0 | 163 | ** |
michael@0 | 164 | ** OUTPUTS: |
michael@0 | 165 | ** PRNetAddr *address A pointer to an address structure that will be |
michael@0 | 166 | ** filled in by the call to the enumeration if the |
michael@0 | 167 | ** result of the call is greater than zero. |
michael@0 | 168 | ** |
michael@0 | 169 | ** RETURN: |
michael@0 | 170 | ** PRIntn The value that should be used for the next call |
michael@0 | 171 | ** of the enumerator ('enumIndex'). The enumeration |
michael@0 | 172 | ** is ended if this value is returned zero. |
michael@0 | 173 | ** If a value of -1 is returned, the enumeration |
michael@0 | 174 | ** has failed. The reason for the failure can be |
michael@0 | 175 | ** retrieved by calling PR_GetError(). |
michael@0 | 176 | ***********************************************************************/ |
michael@0 | 177 | NSPR_API(PRIntn) PR_EnumerateHostEnt( |
michael@0 | 178 | PRIntn enumIndex, const PRHostEnt *hostEnt, PRUint16 port, PRNetAddr *address); |
michael@0 | 179 | |
michael@0 | 180 | /*********************************************************************** |
michael@0 | 181 | ** FUNCTION: PR_InitializeNetAddr(), |
michael@0 | 182 | ** DESCRIPTION: |
michael@0 | 183 | ** Initialize the fields of a PRNetAddr, assigning well known values as |
michael@0 | 184 | ** appropriate. |
michael@0 | 185 | ** |
michael@0 | 186 | ** INPUTS |
michael@0 | 187 | ** PRNetAddrValue val The value to be assigned to the IP Address portion |
michael@0 | 188 | ** of the network address. This can only specify the |
michael@0 | 189 | ** special well known values that are equivalent to |
michael@0 | 190 | ** INADDR_ANY and INADDR_LOOPBACK. |
michael@0 | 191 | ** |
michael@0 | 192 | ** PRUint16 port The port number to be assigned in the structure. |
michael@0 | 193 | ** |
michael@0 | 194 | ** OUTPUTS: |
michael@0 | 195 | ** PRNetAddr *addr The address to be manipulated. |
michael@0 | 196 | ** |
michael@0 | 197 | ** RETURN: |
michael@0 | 198 | ** PRStatus To indicate success or failure. If the latter, the |
michael@0 | 199 | ** reason for the failure can be retrieved by calling |
michael@0 | 200 | ** PR_GetError(); |
michael@0 | 201 | ***********************************************************************/ |
michael@0 | 202 | typedef enum PRNetAddrValue |
michael@0 | 203 | { |
michael@0 | 204 | PR_IpAddrNull, /* do NOT overwrite the IP address */ |
michael@0 | 205 | PR_IpAddrAny, /* assign logical INADDR_ANY to IP address */ |
michael@0 | 206 | PR_IpAddrLoopback, /* assign logical INADDR_LOOPBACK */ |
michael@0 | 207 | PR_IpAddrV4Mapped /* IPv4 mapped address */ |
michael@0 | 208 | } PRNetAddrValue; |
michael@0 | 209 | |
michael@0 | 210 | NSPR_API(PRStatus) PR_InitializeNetAddr( |
michael@0 | 211 | PRNetAddrValue val, PRUint16 port, PRNetAddr *addr); |
michael@0 | 212 | |
michael@0 | 213 | /*********************************************************************** |
michael@0 | 214 | ** FUNCTION: PR_SetNetAddr(), |
michael@0 | 215 | ** DESCRIPTION: |
michael@0 | 216 | ** Set the fields of a PRNetAddr, assigning well known values as |
michael@0 | 217 | ** appropriate. This function is similar to PR_InitializeNetAddr |
michael@0 | 218 | ** but differs in that the address family is specified. |
michael@0 | 219 | ** |
michael@0 | 220 | ** INPUTS |
michael@0 | 221 | ** PRNetAddrValue val The value to be assigned to the IP Address portion |
michael@0 | 222 | ** of the network address. This can only specify the |
michael@0 | 223 | ** special well known values that are equivalent to |
michael@0 | 224 | ** INADDR_ANY and INADDR_LOOPBACK. |
michael@0 | 225 | ** |
michael@0 | 226 | ** PRUint16 af The address family (either PR_AF_INET or PR_AF_INET6) |
michael@0 | 227 | ** |
michael@0 | 228 | ** PRUint16 port The port number to be assigned in the structure. |
michael@0 | 229 | ** |
michael@0 | 230 | ** OUTPUTS: |
michael@0 | 231 | ** PRNetAddr *addr The address to be manipulated. |
michael@0 | 232 | ** |
michael@0 | 233 | ** RETURN: |
michael@0 | 234 | ** PRStatus To indicate success or failure. If the latter, the |
michael@0 | 235 | ** reason for the failure can be retrieved by calling |
michael@0 | 236 | ** PR_GetError(); |
michael@0 | 237 | ***********************************************************************/ |
michael@0 | 238 | NSPR_API(PRStatus) PR_SetNetAddr( |
michael@0 | 239 | PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr *addr); |
michael@0 | 240 | |
michael@0 | 241 | /*********************************************************************** |
michael@0 | 242 | ** FUNCTION: |
michael@0 | 243 | ** DESCRIPTION: PR_IsNetAddrType() |
michael@0 | 244 | ** Determine if the network address is of the specified type. |
michael@0 | 245 | ** |
michael@0 | 246 | ** INPUTS: |
michael@0 | 247 | ** const PRNetAddr *addr A network address. |
michael@0 | 248 | ** PRNetAddrValue The type of network address |
michael@0 | 249 | ** |
michael@0 | 250 | ** RETURN: |
michael@0 | 251 | ** PRBool PR_TRUE if the network address is of the |
michael@0 | 252 | ** specified type, else PR_FALSE. |
michael@0 | 253 | ***********************************************************************/ |
michael@0 | 254 | NSPR_API(PRBool) PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val); |
michael@0 | 255 | |
michael@0 | 256 | /*********************************************************************** |
michael@0 | 257 | ** FUNCTION: |
michael@0 | 258 | ** DESCRIPTION: PR_ConvertIPv4AddrToIPv6() |
michael@0 | 259 | ** Convert an IPv4 addr to an (IPv4-mapped) IPv6 addr |
michael@0 | 260 | ** |
michael@0 | 261 | ** INPUTS: |
michael@0 | 262 | ** PRUint32 v4addr IPv4 address |
michael@0 | 263 | ** |
michael@0 | 264 | ** OUTPUTS: |
michael@0 | 265 | ** PRIPv6Addr *v6addr The converted IPv6 address |
michael@0 | 266 | ** |
michael@0 | 267 | ** RETURN: |
michael@0 | 268 | ** void |
michael@0 | 269 | ** |
michael@0 | 270 | ***********************************************************************/ |
michael@0 | 271 | NSPR_API(void) PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr *v6addr); |
michael@0 | 272 | |
michael@0 | 273 | /*********************************************************************** |
michael@0 | 274 | ** MACRO: |
michael@0 | 275 | ** DESCRIPTION: PR_NetAddrFamily() |
michael@0 | 276 | ** Get the 'family' field of a PRNetAddr union. |
michael@0 | 277 | ** |
michael@0 | 278 | ** INPUTS: |
michael@0 | 279 | ** const PRNetAddr *addr A network address. |
michael@0 | 280 | ** |
michael@0 | 281 | ** RETURN: |
michael@0 | 282 | ** PRUint16 The 'family' field of 'addr'. |
michael@0 | 283 | ***********************************************************************/ |
michael@0 | 284 | #define PR_NetAddrFamily(addr) ((addr)->raw.family) |
michael@0 | 285 | |
michael@0 | 286 | /*********************************************************************** |
michael@0 | 287 | ** MACRO: |
michael@0 | 288 | ** DESCRIPTION: PR_NetAddrInetPort() |
michael@0 | 289 | ** Get the 'port' field of a PRNetAddr union. |
michael@0 | 290 | ** |
michael@0 | 291 | ** INPUTS: |
michael@0 | 292 | ** const PRNetAddr *addr A network address. |
michael@0 | 293 | ** |
michael@0 | 294 | ** RETURN: |
michael@0 | 295 | ** PRUint16 The 'port' field of 'addr'. |
michael@0 | 296 | ***********************************************************************/ |
michael@0 | 297 | #define PR_NetAddrInetPort(addr) \ |
michael@0 | 298 | ((addr)->raw.family == PR_AF_INET6 ? (addr)->ipv6.port : (addr)->inet.port) |
michael@0 | 299 | |
michael@0 | 300 | /*********************************************************************** |
michael@0 | 301 | ** FUNCTION: |
michael@0 | 302 | ** DESCRIPTION: PR_GetProtoByName() |
michael@0 | 303 | ** Lookup a protocol entry based on protocol's name |
michael@0 | 304 | ** |
michael@0 | 305 | ** INPUTS: |
michael@0 | 306 | ** char *protocolname Character string of the protocol's name. |
michael@0 | 307 | ** char *buf A scratch buffer for the runtime to return result. |
michael@0 | 308 | ** This buffer is allocated by the caller. |
michael@0 | 309 | ** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to |
michael@0 | 310 | ** use is PR_NETDB_BUF_SIZE. |
michael@0 | 311 | ** OUTPUTS: |
michael@0 | 312 | ** PRHostEnt *PRProtoEnt |
michael@0 | 313 | ** This structure is filled in by the runtime if |
michael@0 | 314 | ** the function returns PR_SUCCESS. This structure |
michael@0 | 315 | ** is allocated by the caller. |
michael@0 | 316 | ** RETURN: |
michael@0 | 317 | ** PRStatus PR_SUCCESS if the lookup succeeds. If it fails |
michael@0 | 318 | ** the result will be PR_FAILURE and the reason |
michael@0 | 319 | ** for the failure can be retrieved by PR_GetError(). |
michael@0 | 320 | ***********************************************************************/ |
michael@0 | 321 | |
michael@0 | 322 | typedef struct PRProtoEnt { |
michael@0 | 323 | char *p_name; /* official protocol name */ |
michael@0 | 324 | char **p_aliases; /* alias list */ |
michael@0 | 325 | #ifdef WIN32 |
michael@0 | 326 | PRInt16 p_num; /* protocol # */ |
michael@0 | 327 | #else |
michael@0 | 328 | PRInt32 p_num; /* protocol # */ |
michael@0 | 329 | #endif |
michael@0 | 330 | } PRProtoEnt; |
michael@0 | 331 | |
michael@0 | 332 | NSPR_API(PRStatus) PR_GetProtoByName( |
michael@0 | 333 | const char* protocolname, char* buffer, PRInt32 bufsize, PRProtoEnt* result); |
michael@0 | 334 | |
michael@0 | 335 | /*********************************************************************** |
michael@0 | 336 | ** FUNCTION: |
michael@0 | 337 | ** DESCRIPTION: PR_GetProtoByNumber() |
michael@0 | 338 | ** Lookup a protocol entry based on protocol's number |
michael@0 | 339 | ** |
michael@0 | 340 | ** INPUTS: |
michael@0 | 341 | ** PRInt32 protocolnumber |
michael@0 | 342 | ** Number assigned to the protocol. |
michael@0 | 343 | ** char *buf A scratch buffer for the runtime to return result. |
michael@0 | 344 | ** This buffer is allocated by the caller. |
michael@0 | 345 | ** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to |
michael@0 | 346 | ** use is PR_NETDB_BUF_SIZE. |
michael@0 | 347 | ** OUTPUTS: |
michael@0 | 348 | ** PRHostEnt *PRProtoEnt |
michael@0 | 349 | ** This structure is filled in by the runtime if |
michael@0 | 350 | ** the function returns PR_SUCCESS. This structure |
michael@0 | 351 | ** is allocated by the caller. |
michael@0 | 352 | ** RETURN: |
michael@0 | 353 | ** PRStatus PR_SUCCESS if the lookup succeeds. If it fails |
michael@0 | 354 | ** the result will be PR_FAILURE and the reason |
michael@0 | 355 | ** for the failure can be retrieved by PR_GetError(). |
michael@0 | 356 | ***********************************************************************/ |
michael@0 | 357 | NSPR_API(PRStatus) PR_GetProtoByNumber( |
michael@0 | 358 | PRInt32 protocolnumber, char* buffer, PRInt32 bufsize, PRProtoEnt* result); |
michael@0 | 359 | |
michael@0 | 360 | /*********************************************************************** |
michael@0 | 361 | ** FUNCTION: |
michael@0 | 362 | ** DESCRIPTION: PR_GetAddrInfoByName() |
michael@0 | 363 | ** Look up a host by name. Equivalent to getaddrinfo(host, NULL, ...) of |
michael@0 | 364 | ** RFC 3493. |
michael@0 | 365 | ** |
michael@0 | 366 | ** INPUTS: |
michael@0 | 367 | ** char *hostname Character string defining the host name of interest |
michael@0 | 368 | ** PRUint16 af May be PR_AF_UNSPEC or PR_AF_INET. |
michael@0 | 369 | ** PRIntn flags May be either PR_AI_ADDRCONFIG or |
michael@0 | 370 | ** PR_AI_ADDRCONFIG | PR_AI_NOCANONNAME. Include |
michael@0 | 371 | ** PR_AI_NOCANONNAME to suppress the determination of |
michael@0 | 372 | ** the canonical name corresponding to hostname. |
michael@0 | 373 | ** RETURN: |
michael@0 | 374 | ** PRAddrInfo* Handle to a data structure containing the results |
michael@0 | 375 | ** of the host lookup. Use PR_EnumerateAddrInfo to |
michael@0 | 376 | ** inspect the PRNetAddr values stored in this object. |
michael@0 | 377 | ** When no longer needed, this handle must be destroyed |
michael@0 | 378 | ** with a call to PR_FreeAddrInfo. If a lookup error |
michael@0 | 379 | ** occurs, then NULL will be returned. |
michael@0 | 380 | ***********************************************************************/ |
michael@0 | 381 | typedef struct PRAddrInfo PRAddrInfo; |
michael@0 | 382 | |
michael@0 | 383 | NSPR_API(PRAddrInfo*) PR_GetAddrInfoByName( |
michael@0 | 384 | const char *hostname, PRUint16 af, PRIntn flags); |
michael@0 | 385 | |
michael@0 | 386 | /*********************************************************************** |
michael@0 | 387 | ** FUNCTION: |
michael@0 | 388 | ** DESCRIPTION: PR_FreeAddrInfo() |
michael@0 | 389 | ** Destroy the PRAddrInfo handle allocated by PR_GetAddrInfoByName(). |
michael@0 | 390 | ** |
michael@0 | 391 | ** INPUTS: |
michael@0 | 392 | ** PRAddrInfo *addrInfo |
michael@0 | 393 | ** The handle resulting from a successful call to |
michael@0 | 394 | ** PR_GetAddrInfoByName(). |
michael@0 | 395 | ** RETURN: |
michael@0 | 396 | ** void |
michael@0 | 397 | ***********************************************************************/ |
michael@0 | 398 | NSPR_API(void) PR_FreeAddrInfo(PRAddrInfo *addrInfo); |
michael@0 | 399 | |
michael@0 | 400 | /*********************************************************************** |
michael@0 | 401 | ** FUNCTION: |
michael@0 | 402 | ** DESCRIPTION: PR_EnumerateAddrInfo() |
michael@0 | 403 | ** A stateless enumerator over a PRAddrInfo handle acquired from |
michael@0 | 404 | ** PR_GetAddrInfoByName() to inspect the possible network addresses. |
michael@0 | 405 | ** |
michael@0 | 406 | ** INPUTS: |
michael@0 | 407 | ** void *enumPtr Index pointer of the enumeration. The enumeration |
michael@0 | 408 | ** starts and ends with a value of NULL. |
michael@0 | 409 | ** const PRAddrInfo *addrInfo |
michael@0 | 410 | ** The PRAddrInfo handle returned by a successful |
michael@0 | 411 | ** call to PR_GetAddrInfoByName(). |
michael@0 | 412 | ** PRUint16 port The port number to be assigned as part of the |
michael@0 | 413 | ** PRNetAddr. |
michael@0 | 414 | ** OUTPUTS: |
michael@0 | 415 | ** PRNetAddr *result A pointer to an address structure that will be |
michael@0 | 416 | ** filled in by the call to the enumeration if the |
michael@0 | 417 | ** result of the call is not NULL. |
michael@0 | 418 | ** RETURN: |
michael@0 | 419 | ** void* The value that should be used for the next call |
michael@0 | 420 | ** of the enumerator ('enumPtr'). The enumeration |
michael@0 | 421 | ** is ended if this value is NULL. |
michael@0 | 422 | ***********************************************************************/ |
michael@0 | 423 | NSPR_API(void *) PR_EnumerateAddrInfo( |
michael@0 | 424 | void *enumPtr, const PRAddrInfo *addrInfo, PRUint16 port, PRNetAddr *result); |
michael@0 | 425 | |
michael@0 | 426 | /*********************************************************************** |
michael@0 | 427 | ** FUNCTION: |
michael@0 | 428 | ** DESCRIPTION: PR_GetCanonNameFromAddrInfo() |
michael@0 | 429 | ** Extracts the canonical name of the hostname passed to |
michael@0 | 430 | ** PR_GetAddrInfoByName(). |
michael@0 | 431 | ** |
michael@0 | 432 | ** INPUTS: |
michael@0 | 433 | ** const PRAddrInfo *addrInfo |
michael@0 | 434 | ** The PRAddrInfo handle returned by a successful |
michael@0 | 435 | ** call to PR_GetAddrInfoByName(). |
michael@0 | 436 | ** RETURN: |
michael@0 | 437 | ** const char * A const pointer to the canonical hostname stored |
michael@0 | 438 | ** in the given PRAddrInfo handle. This pointer is |
michael@0 | 439 | ** invalidated once the PRAddrInfo handle is destroyed |
michael@0 | 440 | ** by a call to PR_FreeAddrInfo(). |
michael@0 | 441 | ***********************************************************************/ |
michael@0 | 442 | NSPR_API(const char *) PR_GetCanonNameFromAddrInfo( |
michael@0 | 443 | const PRAddrInfo *addrInfo); |
michael@0 | 444 | |
michael@0 | 445 | /*********************************************************************** |
michael@0 | 446 | ** FUNCTIONS: PR_ntohs, PR_ntohl, PR_ntohll, PR_htons, PR_htonl, PR_htonll |
michael@0 | 447 | ** |
michael@0 | 448 | ** DESCRIPTION: API entries for the common byte ordering routines. |
michael@0 | 449 | ** |
michael@0 | 450 | ** PR_ntohs 16 bit conversion from network to host |
michael@0 | 451 | ** PR_ntohl 32 bit conversion from network to host |
michael@0 | 452 | ** PR_ntohll 64 bit conversion from network to host |
michael@0 | 453 | ** PR_htons 16 bit conversion from host to network |
michael@0 | 454 | ** PR_htonl 32 bit conversion from host to network |
michael@0 | 455 | ** PR_ntonll 64 bit conversion from host to network |
michael@0 | 456 | ** |
michael@0 | 457 | ***********************************************************************/ |
michael@0 | 458 | NSPR_API(PRUint16) PR_ntohs(PRUint16); |
michael@0 | 459 | NSPR_API(PRUint32) PR_ntohl(PRUint32); |
michael@0 | 460 | NSPR_API(PRUint64) PR_ntohll(PRUint64); |
michael@0 | 461 | NSPR_API(PRUint16) PR_htons(PRUint16); |
michael@0 | 462 | NSPR_API(PRUint32) PR_htonl(PRUint32); |
michael@0 | 463 | NSPR_API(PRUint64) PR_htonll(PRUint64); |
michael@0 | 464 | |
michael@0 | 465 | PR_END_EXTERN_C |
michael@0 | 466 | |
michael@0 | 467 | #endif /* prnetdb_h___ */ |