7 #include "config_portability.h"
10 * This package defines some utilities for determining and converting DNS
11 * machine names and IP addresses.
20 #define MAX_IP_IMAGE 15
21 /* Maximum text length of an IP address, i.e. strlen("255.255.255.255") */
25 * Common typedefs for all portability
27 typedef uint32_t IPAddress;
29 #define NO_SOCKET ((Socket)-1)
32 * returns the address of the host connected to #sd#. Returns 0 on error.
39 * Returns the DNS name of the host connected to #sd#, or descriptive text if
40 * #sd# is not an inter-host connection: returns NULL in case of error
41 * The value returned needs to be freed.
44 PeerName_r(Socket sd);
47 * returns the port number on the other side of socket sd. -1 is returned
51 PeerNamePort(Socket sd);
55 * Converts #addr# into a printable string and returns the result. You
56 * are responsible to free the returned string: can return NULL (out of
60 IPAddressImage_r(IPAddress addr);
64 * Converts #addr# to a fully-qualified machine name and returns the result.
65 * You are responsible to free the returned string: can return NULL
66 * (out of memory or error).
69 IPAddressMachine_r(IPAddress addr);
72 * Converts #machineOrAddress#, which may be either a DNS name or an IP address
73 * image, into a list of addresses. Copies the list into the #atMost#-long
74 * array #addressList#. Returns the number of addresses copied, or zero on
75 * error. #atMost# may be zero, in which case the function simply returns one
76 * or zero depending on whether or not #machineOrAddress# is a valid machine
77 * name or IP address image.
80 IPAddressValues(const char *machineOrAddress,
81 IPAddress *addressList,
83 #define IPAddressValue(machineOrAddress,address) \
84 IPAddressValues(machineOrAddress,address,1)
85 #define IsValidIP(machineOrAddress) IPAddressValues(machineOrAddress,NULL,0)
89 * Returns the fully-qualified name of the host machine, or NULL if the name
90 * cannot be determined. Always returns the same value, so multiple calls
97 /* DEPRECATED! These functions are going to go away: they are not thread
100 IPAddressImage(IPAddress addr);
102 IPAddressMachine(IPAddress addr);