#ifndef __NETDB_LOADED #define __NETDB_LOADED 1 /**************************************************************************** ** ** - Network database library info ** ***************************************************************************** ** Header introduced by the X/Open CAE Specification, Issue 4, Version 2 ***************************************************************************** ** ** Copyright 2007 Hewlett-Packard Development Company, L.P. ** ** Confidential computer software. Valid license from HP and/or ** its subsidiaries required for possession, use, or copying. ** ** Consistent with FAR 12.211 and 12.212, Commercial Computer Software, ** Computer Software Documentation, and Technical Data for Commercial ** Items are licensed to the U.S. Government under vendor's standard ** commercial license. ** ** Neither HP nor any of its subsidiaries shall be liable for technical ** or editorial errors or omissions contained herein. The information ** in this document is provided "as is" without warranty of any kind and ** is subject to change without notice. The warranties for HP products ** are set forth in the express limited warranty statements accompanying ** such products. Nothing herein should be construed as constituting an ** additional warranty. ** ***************************************************************************** */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif /* ** All includes of other header files must be done prior to altering ** the pointer size mode. */ #include #include #include /* ** IPv6: Include these here for now so res_init() and RES_USE_INET6 will ** be available for gethostbyname() users. */ #include #include #include /* ** Start processing in 32-bit addressing mode */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __save # pragma __pointer_size 32 #endif /* ** Those socket structures allocated by the DEC C RTL or the underlying tcp/ip ** layer are always 32 bit pointers. Declare typedefs which are pointers to ** these structures while in 32 bit pointer context. We will then use these ** typedefs in the function prototypes when in 64 bit pointer context. */ typedef struct hostent * __struct_hostent_ptr32; typedef struct servent * __struct_servent_ptr32; typedef struct netent * __struct_netent_ptr32; typedef struct protoent * __struct_protoent_ptr32; /* ** The OpenVMS V7.0 release added a second implementation of the socket ** functions which is compatible with BSD 4.4. Define a local to be ** used throughout the remaining header file which reflects which ** implementation is being used. ** ** An application program enables this support by defining _SOCKADDR_LEN ** prior to including this header file. */ #ifdef _SOCKADDR_LEN # if (__CRTL_VER < 70000000) # error " BSD 4.4 Socket package not available before OpenVMS V7.0" # undef _SOCKADDR_LEN # endif #endif /* ** Set __nomember_alignment to avoid internal and tail ** padding in structures; default base alignment. ** Required for consistency across programming languages. */ #pragma __member_alignment __save #pragma __nomember_alignment /* ** Conditionally define in_addr_t and size_t structures */ #if !defined __IN_ADDR_T && !defined _DECC_V4_SOURCE # define __IN_ADDR_T typedef __in_addr_t in_addr_t; #endif #ifndef __SIZE_T # define __SIZE_T 1 #ifdef __NAMESPACE_STD namespace std { #endif typedef __size_t size_t; #ifdef __NAMESPACE_STD } /* namespace std */ using std::size_t; #endif #endif /* ** Internal Constants for Reentrant Socket Functions */ #ifdef _REENTRANT #define _MAXALIASES 35 #define _MAXLINELEN 1024 #define _MAXADDRS 35 #define _HOSTBUFSIZE (BUFSIZ + 1) struct hostent_data { struct in_addr host_addr; char *h_addr_ptrs[_MAXADDRS + 1]; char hostaddr[_MAXADDRS]; char hostbuf[_HOSTBUFSIZE]; char *host_aliases[_MAXALIASES]; char *host_addrs[2]; FILE *hostf; int svc_gethostflag; int svc_gethostbind; }; struct netent_data { FILE *net_fp; char line[_MAXLINELEN]; char *net_aliases[_MAXALIASES]; int _net_stayopen; int svc_getnetflag; }; struct protoent_data { FILE *proto_fp; char line[1024]; char *proto_aliases[_MAXALIASES]; int _proto_stayopen; int svc_getprotoflag; }; struct servent_data { FILE *serv_fp; char line[_MAXLINELEN]; char *serv_aliases[_MAXALIASES]; int _serv_stayopen; int svc_getservflag; }; #endif /* _REENTRANT */ #define _PATH_HOSTS "TCPIP$SYSTEM:HOSTS.DAT" #define _PATH_NETWORKS "TCPIP$SYSTEM:NETWORKS.DAT" #define _PATH_PROTOCOLS "TCPIP$SYSTEM:PROTOCOLS.DAT" #define _PATH_SERVICES "TCPIP$ETC:SERVICES.DAT" /* ** Structures returned by network data base library. All addresses are ** supplied in host order, and returned in network order (suitable for ** use in system calls). **/ /* ** Hostent Structure ** ** This structure specifies or obtains a host name, a list of aliases ** associated with the host, and the host's number specified ** as an Internet address from the host database. An entry in the host ** database is created with the following command: ** ** TCPIP> SET HOST XXXX ** ** See the HP TCP/IP Services for OpenVMS Management Guide for ** a description of the host database. */ struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */ #define h_addr h_addr_list[0] /* address, for backward compatiblity */ }; /* ** Netent Structure ** ** This structure specifies or obtains a network name, a list of aliases ** associated with the network, and the network's number specified ** as an Internet address from the network database. An entry in the network ** database is created with the following command: ** ** TCPIP> SET NETWORK XXXX ** ** See the HP TCP/IP Services for OpenVMS Management Guide for ** a description of the network database. ** */ /* * Assumption here is that a network number * fits in 32 bits -- probably a poor one. */ struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ __in_addr_t n_net; /* network # */ }; /* ** Servent Structure ** ** This structure specifies or obtains a service name, a list of aliases ** associated with the service, and the service's number specified ** as an Internet address from the services database. An entry in the services ** database is created with the following command: ** ** TCPIP> SET SERV XXXX ** ** See the HP TCP/IP Services for OpenVMS Management Guide for ** a description of the services database. */ struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port # */ char *s_proto; /* protocol to use */ }; struct protoent { char *p_name; /* official protocol name */ char **p_aliases; /* alias list */ int p_proto; /* protocol # */ }; /* * Flag values for getaddrinfo() */ #define AI_PASSIVE 0x00000001 /* socket address intended for bind() */ #define AI_CANONNAME 0x00000002 /* request for canonical name */ #define AI_NUMERICHOST 0x00000004 /* numeric host address string */ #define AI_V4MAPPED 0x00000008 /* request IPV4 mapped IPV6 address */ #define AI_ALL 0x00000010 /* Both AAAA and A records */ #define AI_ADDRCONFIG 0x00000020 /* Address Family must be configured */ #define AI_NUMERICSERV 0x00000040 /* numeric service string */ #define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) /* Default behavior */ #define AI_MASK (AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|\ AI_V4MAPPED|AI_ALL|AI_ADDRCONFIG|AI_NUMERICSERV) /* * Flag values for getnameinfo() */ #define NI_DGRAM 0x00000001 #define NI_NAMEREQD 0x00000002 #define NI_NOFQDN 0x00000004 #define NI_NUMERICHOST 0x00000008 #define NI_NUMERICSERV 0x00000010 #define NI_NUMERICSCOPE 0x00000020 #define NI_WITHSCOPEID 0x00000040 #define NI_MAXHOST 1025 #define NI_MAXSERV 32 /* * Scope delimit character */ #define SCOPE_DELIMITER '%' /* ** DEC C extensions */ #if !defined _XOPEN_SOURCE_EXTENDED /* ** Rpcent Structures */ struct rpcent { char *r_name; /* name of server for rpc program */ char **r_aliases; /* alias list */ int r_number; /* rpc program number */ }; #endif /* ** Error return codes from gethostbyname and gethostbyaddr (left in h_errno). */ #define NETDB_INTERNAL -1 /* see errno */ #define NETDB_SUCCESS 0 /* no problem */ #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid name, no data record of requested type */ #define NO_ADDRESS NO_DATA /* no address, look for MX record */ /* ** As of OpenVMS V7.0, the DEC C RTL supports h_errno. */ int *decc$h_errno_get_addr(void); #define h_errno (*decc$h_errno_get_addr()) #if __INITIAL_POINTER_SIZE # pragma __pointer_size 64 /* * 64-bit addrinfo structure */ struct __addrinfo64 { int ai_flags; /* input flags */ int ai_family; /* protofamily for socket */ int ai_socktype; /* socket type */ int ai_protocol; /* protocol for socket */ size_t ai_addrlen; /* length of socket-address */ char *ai_canonname; /* service location canonical name */ struct sockaddr *ai_addr; /* socket-address for socket */ struct __addrinfo64 *ai_next; /* pointer to next in list */ }; typedef struct addrinfo *__addrinfo_ptr64; typedef const struct addrinfo *__const_addrinfo_ptr64; typedef __addrinfo_ptr64 *__addrinfo_ptr64_ptr64; typedef struct __addrinfo64 *__addrinfo64_ptr64; typedef __addrinfo64_ptr64 *__addrinfo64_ptr64_ptr64; typedef const struct __addrinfo64 *__const_addrinfo64_ptr64; # pragma __pointer_size 32 /* * 32-bit addrinfo structure */ struct __addrinfo32 { int ai_flags; /* input flags */ int ai_family; /* protofamily for socket */ int ai_socktype; /* socket type */ int ai_protocol; /* protocol for socket */ size_t ai_addrlen; /* length of socket-address */ char *ai_canonname; /* service location canonical name */ struct sockaddr *ai_addr; /* socket-address for socket */ struct __addrinfo32 *ai_next; /* pointer to next in list */ }; typedef struct addrinfo *__addrinfo_ptr32; typedef const struct addrinfo *__const_addrinfo_ptr32; typedef __addrinfo_ptr32 *__addrinfo_ptr32_ptr32; typedef struct __addrinfo32 *__addrinfo32_ptr32; typedef __addrinfo32_ptr32 *__addrinfo32_ptr32_ptr32; typedef const struct __addrinfo32 *__const_addrinfo32_ptr32; #endif /* __INITIAL_POINTER_SIZE */ /* * addrinfo structure */ struct addrinfo { int ai_flags; /* input flags */ int ai_family; /* protofamily for socket */ int ai_socktype; /* socket type */ int ai_protocol; /* protocol for socket */ size_t ai_addrlen; /* length of socket-address */ char *ai_canonname; /* service location canonical name */ struct sockaddr *ai_addr; /* socket-address for socket */ struct addrinfo *ai_next; /* pointer to next in list */ }; typedef struct addrinfo *__addrinfo_ptr; typedef __addrinfo_ptr *__addrinfo_ptr_ptr; typedef const struct addrinfo *__const_addrinfo_ptr; #if __CRTL_VER >= 70300000 # if __INITIAL_POINTER_SIZE # pragma __pointer_size 64 # endif int getaddrinfo(const char *, const char *, const struct addrinfo *, __addrinfo_ptr * ); int getaddrinfo_compat43(const char *, const char *, const struct addrinfo *, __addrinfo_ptr * ); void freeaddrinfo(struct addrinfo *); int getnameinfo (const struct sockaddr *, size_t, char *, size_t, char *, size_t, int); # if __INITIAL_POINTER_SIZE # pragma __pointer_size 32 # endif const char *gai_strerror (int); #endif #if __INITIAL_POINTER_SIZE && __CRTL_VER >= 70311000 int __getaddrinfo32(__const_char_ptr32, __const_char_ptr32, __const_addrinfo32_ptr32, __addrinfo32_ptr32_ptr32); int __getaddrinfo_compat4332(__const_char_ptr32, __const_char_ptr32, __const_addrinfo32_ptr32, __addrinfo32_ptr32_ptr32); void __freeaddrinfo32(__addrinfo32_ptr32); int __getaddrinfo64(__const_char_ptr64, __const_char_ptr64, __const_addrinfo64_ptr64, __addrinfo64_ptr64_ptr64); int __getaddrinfo_compat4364(__const_char_ptr64, __const_char_ptr64, __const_addrinfo64_ptr64, __addrinfo64_ptr64_ptr64); void __freeaddrinfo64(__addrinfo64_ptr64); #endif #if __INITIAL_POINTER_SIZE == 64 && __CRTL_VER >= 70311000 # define getaddrinfo(__P1,__p2,__P3,__P4) __getaddrinfo64(__P1,__p2,__P3,__P4) # define getaddrinfo_compat43(__P1,__p2,__P3,__P4) __getaddrinfo_compat4364(__P1,__p2,__P3,__P4) # define freeaddrinfo(__P1) __freeaddrinfo64(__P1) #endif #if !defined(_SOCKADDR_LEN) # if __CRTL_VER >= 70300000 # ifdef getaddrinfo # undef getaddrinfo # endif # define getaddrinfo(__p1,__p2,__p3,__p4) getaddrinfo_compat43(__p1,__p2,__p3,__p4) # endif # if __INITIAL_POINTER_SIZE && __CRTL_VER >= 70311000 # define __getaddrinfo32(__P1,__p2,__P3,__P4) __getaddrinfo_compat4332(__P1,__p2,__P3,__P4) # define __getaddrinfo64(__P1,__p2,__P3,__P4) __getaddrinfo_compat4364(__P1,__p2,__P3,__P4) # endif #endif /* * Error values for getaddrinfo() */ #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ #define EAI_AGAIN 2 /* temporary failure in name resolution */ #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ #define EAI_FAMILY 5 /* ai_family not supported */ #define EAI_MEMORY 6 /* memory allocation failure */ #define EAI_NODATA 7 /* no address associated with hostname */ #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ #define EAI_SYSTEM 11 /* system error returned in errno */ #define EAI_BADHINTS 12 #define EAI_PROTOCOL 13 #define EAI_MAX 14 /* ** If the user has used /pointer_size=32 or /pointer_size=64, we will allow 64 ** bit pointers to be used in function calls. */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size 64 #endif /* ** The following functions return pointers to memory allocated by the DEC C ** RTL or the underlying tcp/ip layer. These pointers are always 32 bit ** pointers, while the pointer parameters may be 32 or 64 bits. */ __struct_netent_ptr32 getnetbyaddr (__in_addr_t __net, int __type); __struct_netent_ptr32 getnetent (void); __struct_protoent_ptr32 getprotobynumber (int __proto); __struct_protoent_ptr32 getprotoent (void); __struct_netent_ptr32 getnetbyname (const char *__name); __struct_servent_ptr32 getservbyname (const char *__name, const char *__proto); __struct_servent_ptr32 getservbyport (int __port, const char *__proto); __struct_protoent_ptr32 getprotobyname (const char *__name); #if __CRTL_VER >= 70000000 __struct_hostent_ptr32 gethostent (void); __struct_servent_ptr32 getservent (void); void endnetent (void); void endprotoent (void); void endhostent (void); void endservent (void); void sethostent (int __stayopen); void setservent (int __stayopen); void setnetent (int __stayopen); void setprotoent (int __stayopen); #endif /* ** These functions have new semantics for BSD 4.4 */ #ifdef _SOCKADDR_LEN # if __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __save # pragma __extern_prefix "__bsd44_" # else # define gethostbyaddr(__p1,__p2,__p3) __bsd44_gethostbyaddr(__p1,__p2,__p3) # define gethostbyname(__p1) __bsd44_gethostbyname(__p1) # endif #endif __struct_hostent_ptr32 gethostbyaddr (const void *__addr, size_t __len, int __type); __struct_hostent_ptr32 gethostbyname (const char *__name); __struct_hostent_ptr32 gethostbyname2 (const char *, int); #ifdef _SOCKADDR_LEN # if __CAN_USE_EXTERN_PREFIX # pragma __extern_prefix __restore # endif #endif /* ** DEC C Extensions */ #if !defined _XOPEN_SOURCE_EXTENDED && __CRTL_VER >= 70000000 void herror (const char *__s1); /* ** The hstrerror function always returns a 32 bit pointer */ __char_ptr32 hstrerror (int __n); #endif #define NETDB_INTERNAL -1 /* see errno */ #define NETDB_SUCCESS 0 /* no problem */ #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid name, no data record of requested type */ #define NO_ADDRESS NO_DATA /* no address, look for MX record */ /* ** Restore the users pointer context */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __member_alignment __restore #pragma __standard #endif /* __NETDB_LOADED */