[279] | 1 | #ifndef _NETDB_H
|
---|
| 2 | #define _NETDB_H
|
---|
| 3 |
|
---|
| 4 | #ifdef __cplusplus
|
---|
| 5 | extern "C" {
|
---|
| 6 | #endif
|
---|
| 7 |
|
---|
| 8 | #include <features.h>
|
---|
| 9 | #include <netinet/in.h>
|
---|
| 10 |
|
---|
| 11 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
---|
| 12 | #define __NEED_size_t
|
---|
| 13 | #include <bits/alltypes.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
[331] | 16 | struct addrinfo {
|
---|
[279] | 17 | int ai_flags;
|
---|
| 18 | int ai_family;
|
---|
| 19 | int ai_socktype;
|
---|
| 20 | int ai_protocol;
|
---|
| 21 | socklen_t ai_addrlen;
|
---|
| 22 | struct sockaddr *ai_addr;
|
---|
| 23 | char *ai_canonname;
|
---|
| 24 | struct addrinfo *ai_next;
|
---|
| 25 | };
|
---|
| 26 |
|
---|
| 27 | #define AI_PASSIVE 0x01
|
---|
| 28 | #define AI_CANONNAME 0x02
|
---|
| 29 | #define AI_NUMERICHOST 0x04
|
---|
| 30 | #define AI_V4MAPPED 0x08
|
---|
| 31 | #define AI_ALL 0x10
|
---|
| 32 | #define AI_ADDRCONFIG 0x20
|
---|
| 33 | #define AI_NUMERICSERV 0x400
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | #define NI_NUMERICHOST 0x01
|
---|
| 37 | #define NI_NUMERICSERV 0x02
|
---|
| 38 | #define NI_NOFQDN 0x04
|
---|
| 39 | #define NI_NAMEREQD 0x08
|
---|
| 40 | #define NI_DGRAM 0x10
|
---|
| 41 | #define NI_NUMERICSCOPE 0x100
|
---|
| 42 |
|
---|
| 43 | #define EAI_BADFLAGS -1
|
---|
| 44 | #define EAI_NONAME -2
|
---|
| 45 | #define EAI_AGAIN -3
|
---|
| 46 | #define EAI_FAIL -4
|
---|
| 47 | #define EAI_FAMILY -6
|
---|
| 48 | #define EAI_SOCKTYPE -7
|
---|
| 49 | #define EAI_SERVICE -8
|
---|
| 50 | #define EAI_MEMORY -10
|
---|
| 51 | #define EAI_SYSTEM -11
|
---|
| 52 | #define EAI_OVERFLOW -12
|
---|
| 53 |
|
---|
| 54 | int getaddrinfo (const char *__restrict, const char *__restrict, const struct addrinfo *__restrict, struct addrinfo **__restrict);
|
---|
| 55 | void freeaddrinfo (struct addrinfo *);
|
---|
| 56 | int getnameinfo (const struct sockaddr *__restrict, socklen_t, char *__restrict, socklen_t, char *__restrict, socklen_t, int);
|
---|
| 57 | const char *gai_strerror(int);
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | /* Legacy functions follow (marked OBsolete in SUS) */
|
---|
| 61 |
|
---|
[331] | 62 | struct netent {
|
---|
[279] | 63 | char *n_name;
|
---|
| 64 | char **n_aliases;
|
---|
| 65 | int n_addrtype;
|
---|
| 66 | uint32_t n_net;
|
---|
| 67 | };
|
---|
| 68 |
|
---|
[331] | 69 | struct hostent {
|
---|
[279] | 70 | char *h_name;
|
---|
| 71 | char **h_aliases;
|
---|
| 72 | int h_addrtype;
|
---|
| 73 | int h_length;
|
---|
| 74 | char **h_addr_list;
|
---|
| 75 | };
|
---|
| 76 | #define h_addr h_addr_list[0]
|
---|
| 77 |
|
---|
[331] | 78 | struct servent {
|
---|
[279] | 79 | char *s_name;
|
---|
| 80 | char **s_aliases;
|
---|
| 81 | int s_port;
|
---|
| 82 | char *s_proto;
|
---|
| 83 | };
|
---|
| 84 |
|
---|
[331] | 85 | struct protoent {
|
---|
[279] | 86 | char *p_name;
|
---|
| 87 | char **p_aliases;
|
---|
| 88 | int p_proto;
|
---|
| 89 | };
|
---|
| 90 |
|
---|
| 91 | void sethostent (int);
|
---|
| 92 | void endhostent (void);
|
---|
| 93 | struct hostent *gethostent (void);
|
---|
| 94 |
|
---|
| 95 | void setnetent (int);
|
---|
| 96 | void endnetent (void);
|
---|
| 97 | struct netent *getnetent (void);
|
---|
| 98 | struct netent *getnetbyaddr (uint32_t, int);
|
---|
| 99 | struct netent *getnetbyname (const char *);
|
---|
| 100 |
|
---|
| 101 | void setservent (int);
|
---|
| 102 | void endservent (void);
|
---|
| 103 | struct servent *getservent (void);
|
---|
| 104 | struct servent *getservbyname (const char *, const char *);
|
---|
| 105 | struct servent *getservbyport (int, const char *);
|
---|
| 106 |
|
---|
| 107 | void setprotoent (int);
|
---|
| 108 | void endprotoent (void);
|
---|
| 109 | struct protoent *getprotoent (void);
|
---|
| 110 | struct protoent *getprotobyname (const char *);
|
---|
| 111 | struct protoent *getprotobynumber (int);
|
---|
| 112 |
|
---|
| 113 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \
|
---|
| 114 | || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
|
---|
| 115 | || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
|
---|
| 116 | struct hostent *gethostbyname (const char *);
|
---|
| 117 | struct hostent *gethostbyaddr (const void *, socklen_t, int);
|
---|
| 118 | int *__h_errno_location(void);
|
---|
| 119 | #define h_errno (*__h_errno_location())
|
---|
| 120 | #define HOST_NOT_FOUND 1
|
---|
| 121 | #define TRY_AGAIN 2
|
---|
| 122 | #define NO_RECOVERY 3
|
---|
| 123 | #define NO_DATA 4
|
---|
| 124 | #define NO_ADDRESS NO_DATA
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
| 127 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
|
---|
| 128 | void herror(const char *);
|
---|
| 129 | const char *hstrerror(int);
|
---|
| 130 | int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
|
---|
| 131 | int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);
|
---|
| 132 | struct hostent *gethostbyname2(const char *, int);
|
---|
| 133 | int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *);
|
---|
| 134 | int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **);
|
---|
| 135 | int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **);
|
---|
| 136 | #define EAI_NODATA -5
|
---|
| 137 | #define EAI_ADDRFAMILY -9
|
---|
| 138 | #define EAI_INPROGRESS -100
|
---|
| 139 | #define EAI_CANCELED -101
|
---|
| 140 | #define EAI_NOTCANCELED -102
|
---|
| 141 | #define EAI_ALLDONE -103
|
---|
| 142 | #define EAI_INTR -104
|
---|
| 143 | #define EAI_IDN_ENCODE -105
|
---|
| 144 | #define NI_MAXHOST 255
|
---|
| 145 | #define NI_MAXSERV 32
|
---|
| 146 | #endif
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | #ifdef __cplusplus
|
---|
| 150 | }
|
---|
| 151 | #endif
|
---|
| 152 |
|
---|
| 153 | #endif
|
---|