1 /* 2 Modified for [Open]BeOS 3 */ 4 5 /* 6 * ++Copyright++ 1980, 1983, 1988, 1993 7 * - 8 * Copyright (c) 1980, 1983, 1988, 1993 9 * The Regents of the University of California. All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the University of 22 * California, Berkeley and its contributors. 23 * 4. Neither the name of the University nor the names of its contributors 24 * may be used to endorse or promote products derived from this software 25 * without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * - 39 * Portions Copyright (c) 1993 by Digital Equipment Corporation. 40 * 41 * Permission to use, copy, modify, and distribute this software for any 42 * purpose with or without fee is hereby granted, provided that the above 43 * copyright notice and this permission notice appear in all copies, and that 44 * the name of Digital Equipment Corporation not be used in advertising or 45 * publicity pertaining to distribution of the document or software without 46 * specific, written prior permission. 47 * 48 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 49 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 50 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 51 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 52 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 53 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 54 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 55 * SOFTWARE. 56 * - 57 * Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 58 * All rights reserved. 59 * 60 * Redistribution and use in source and binary forms, with or without 61 * modification, are permitted provided that the following conditions 62 * are met: 63 * 1. Redistributions of source code must retain the above copyright 64 * notice, this list of conditions and the following disclaimer. 65 * 2. Redistributions in binary form must reproduce the above copyright 66 * notice, this list of conditions and the following disclaimer in the 67 * documentation and/or other materials provided with the distribution. 68 * 3. All advertising materials mentioning features or use of this software 69 * must display the following acknowledgement: 70 * This product includes software developed by WIDE Project and 71 * its contributors. 72 * 4. Neither the name of the project nor the names of its contributors 73 * may be used to endorse or promote products derived from this software 74 * without specific prior written permission. 75 * 76 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 77 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 78 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 79 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 80 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 81 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 82 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 83 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 84 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 85 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 86 * SUCH DAMAGE. 87 * - 88 * --Copyright-- 89 */ 90 91 /* 92 * @(#)netdb.h 8.1 (Berkeley) 6/2/93 93 * $Id: netdb.h,v 1.8 2004/05/13 00:48:55 phoudoin Exp $ 94 */ 95 96 /* Modified for OpenBeOS 97 */ 98 99 #ifndef _NETDB_H_ 100 #define _NETDB_H_ 101 102 #include <sys/types.h> 103 #include <netinet/in.h> 104 #include <stdio.h> 105 106 107 /* 108 #include <sys/param.h> 109 #include <sys/types.h> 110 #if (!defined(BSD)) || (BSD < 199306) 111 # include <sys/bitypes.h> 112 #endif 113 #include <sys/cdefs.h> 114 #include <sys/socket.h> 115 #include <netinet/in.h> 116 #include <stdio.h> 117 */ 118 119 #ifdef __cplusplus 120 extern "C" { 121 #endif 122 123 124 #ifndef _PATH_HEQUIV 125 #define _PATH_HEQUIV "/etc/hosts.equiv" 126 #endif 127 #ifndef _PATH_HOSTS 128 #define _PATH_HOSTS "/etc/hosts" 129 #endif 130 #ifndef _PATH_NETWORKS 131 #define _PATH_NETWORKS "/etc/networks" 132 #endif 133 #ifndef _PATH_PROTOCOLS 134 #define _PATH_PROTOCOLS "/etc/protocols" 135 #endif 136 #ifndef _PATH_SERVICES 137 #define _PATH_SERVICES "/etc/services" 138 #endif 139 140 extern int * __h_errno (void); 141 #define h_errno (*__h_errno()) 142 143 /* 144 * Structures returned by network data base library. All addresses are 145 * supplied in host order, and returned in network order (suitable for 146 * use in system calls). 147 */ 148 struct hostent { 149 char *h_name; /* official name of host */ 150 char **h_aliases; /* alias list */ 151 int h_addrtype; /* host address type */ 152 int h_length; /* length of address */ 153 char **h_addr_list; /* list of addresses from name server */ 154 #define h_addr h_addr_list[0] /* address, for backward compatiblity */ 155 }; 156 157 /* 158 * Assumption here is that a network number 159 * fits in an unsigned long -- probably a poor one. 160 */ 161 struct netent { 162 char *n_name; /* official name of net */ 163 char **n_aliases; /* alias list */ 164 int n_addrtype; /* net address type */ 165 unsigned long n_net; /* network # */ 166 }; 167 168 struct servent { 169 char *s_name; /* official service name */ 170 char **s_aliases; /* alias list */ 171 int s_port; /* port # */ 172 char *s_proto; /* protocol to use */ 173 }; 174 175 struct protoent { 176 char *p_name; /* official protocol name */ 177 char **p_aliases; /* alias list */ 178 int p_proto; /* protocol # */ 179 }; 180 181 struct addrinfo { 182 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 183 int ai_family; /* PF_xxx */ 184 int ai_socktype; /* SOCK_xxx */ 185 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 186 size_t ai_addrlen; /* length of ai_addr */ 187 char *ai_canonname; /* canonical name for hostname */ 188 struct sockaddr *ai_addr; /* binary address */ 189 struct addrinfo *ai_next; /* next structure in linked list */ 190 }; 191 192 /* 193 * Error return codes from gethostbyname() and gethostbyaddr() 194 * (left in extern int h_errno). 195 */ 196 197 #define NETDB_INTERNAL -1 /* see errno */ 198 #define NETDB_SUCCESS 0 /* no problem */ 199 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ 200 #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ 201 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 202 #define NO_DATA 4 /* Valid name, no data record of requested type */ 203 #define NO_ADDRESS NO_DATA /* no address, look for MX record */ 204 205 /* 206 * Error return codes from getaddrinfo() 207 */ 208 #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 209 #define EAI_AGAIN 2 /* temporary failure in name resolution */ 210 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 211 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 212 #define EAI_FAMILY 5 /* ai_family not supported */ 213 #define EAI_MEMORY 6 /* memory allocation failure */ 214 #define EAI_NODATA 7 /* no address associated with hostname */ 215 #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 216 #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 217 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 218 #define EAI_SYSTEM 11 /* system error returned in errno */ 219 #define EAI_BADHINTS 12 220 #define EAI_PROTOCOL 13 221 #define EAI_MAX 14 222 223 /* 224 * Flag values for getaddrinfo() 225 */ 226 #define AI_PASSIVE 0x00000001 227 #define AI_CANONNAME 0x00000002 228 #define AI_NUMERICHOST 0x00000004 229 #define AI_MASK 0x00000007 230 231 /* 232 * Flag values for getipnodebyname() 233 */ 234 #define AI_V4MAPPED 0x00000008 235 #define AI_ALL 0x00000010 236 #define AI_ADDRCONFIG 0x00000020 237 #define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG) 238 239 /* 240 * Constants for getnameinfo() 241 */ 242 #define NI_MAXHOST 1025 243 #define NI_MAXSERV 32 244 245 /* 246 * Flag values for getnameinfo() 247 */ 248 #define NI_NOFQDN 0x00000001 249 #define NI_NUMERICHOST 0x00000002 250 #define NI_NAMEREQD 0x00000004 251 #define NI_NUMERICSERV 0x00000008 252 #define NI_DGRAM 0x00000010 253 #define NI_WITHSCOPEID 0x00000020 254 #define NI_NUMERICSCOPE 0x00000040 255 256 /* 257 * Scope delimit character 258 */ 259 #define SCOPE_DELIMITER '%' 260 261 262 #if defined (__hpux) || defined(__osf__) || defined(_AIX) 263 #define _MAXALIASES 35 264 #define _MAXLINELEN 1024 265 #define _MAXADDRS 35 266 #define _HOSTBUFSIZE (BUFSIZ + 1) 267 268 struct hostent_data { 269 struct in_addr host_addr; 270 char *h_addr_ptrs[_MAXADDRS + 1]; 271 char hostaddr[_MAXADDRS]; 272 char hostbuf[_HOSTBUFSIZE]; 273 char *host_aliases[_MAXALIASES]; 274 char *host_addrs[2]; 275 FILE *hostf; 276 #ifdef __osf__ 277 int svc_gethostflag; 278 int svc_gethostbind; 279 #endif 280 #ifdef __hpux 281 short _nsw_src; 282 short _flags; 283 char *current; 284 int currentlen; 285 #endif 286 }; 287 288 struct netent_data { 289 FILE *net_fp; 290 #ifdef __osf__ 291 char line[_MAXLINELEN]; 292 #endif 293 #ifdef __hpux 294 char line[_MAXLINELEN+1]; 295 #endif 296 char *net_aliases[_MAXALIASES]; 297 #ifdef __osf__ 298 int _net_stayopen; 299 int svc_getnetflag; 300 #endif 301 #ifdef __hpux 302 short _nsw_src; 303 short _flags; 304 char *current; 305 int currentlen; 306 #endif 307 }; 308 309 struct protoent_data { 310 FILE *proto_fp; 311 #ifdef __osf__ 312 char line[1024]; 313 #endif 314 #ifdef __hpux 315 char line[_MAXLINELEN+1]; 316 #endif 317 char *proto_aliases[_MAXALIASES]; 318 #ifdef __osf__ 319 int _proto_stayopen; 320 int svc_getprotoflag; 321 #endif 322 #ifdef __hpux 323 short _nsw_src; 324 short _flags; 325 char *current; 326 int currentlen; 327 #endif 328 }; 329 330 struct servent_data { 331 FILE *serv_fp; 332 #ifdef __osf__ 333 char line[_MAXLINELEN]; 334 #endif 335 #ifdef __hpux 336 char line[_MAXLINELEN+1]; 337 #endif 338 char *serv_aliases[_MAXALIASES]; 339 #ifdef __osf__ 340 int _serv_stayopen; 341 int svc_getservflag; 342 #endif 343 #ifdef __hpux 344 short _nsw_src; 345 short _flags; 346 char *current; 347 int currentlen; 348 #endif 349 }; 350 #endif 351 352 #define __P(a) a 353 354 void endhostent __P((void)); 355 void endnetent __P((void)); 356 void endprotoent __P((void)); 357 void endservent __P((void)); 358 void freehostent __P((struct hostent *)); 359 struct hostent *gethostbyaddr __P((const char *, int, int)); 360 struct hostent *gethostbyname __P((const char *)); 361 struct hostent *gethostbyname2 __P((const char *, int)); 362 struct hostent *gethostent __P((void)); 363 struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *)); 364 struct hostent *getipnodebyname __P((const char *, int, int, int *)); 365 struct netent *getnetbyaddr __P((unsigned long, int)); 366 struct netent *getnetbyname __P((const char *)); 367 struct netent *getnetent __P((void)); 368 struct protoent *getprotobyname __P((const char *)); 369 struct protoent *getprotobynumber __P((int)); 370 struct protoent *getprotoent __P((void)); 371 struct servent *getservbyname __P((const char *, const char *)); 372 struct servent *getservbyport __P((int, const char *)); 373 struct servent *getservent __P((void)); 374 void herror __P((const char *)); 375 const char *hstrerror __P((int)); 376 void sethostent __P((int)); 377 /* void sethostfile __P((const char *)); */ 378 void setnetent __P((int)); 379 void setprotoent __P((int)); 380 void setservent __P((int)); 381 int getaddrinfo __P((const char *, const char *, 382 const struct addrinfo *, struct addrinfo **)); 383 int getnameinfo __P((const struct sockaddr *, size_t, char *, 384 size_t, char *, size_t, int)); 385 void freeaddrinfo __P((struct addrinfo *)); 386 const char *gai_strerror __P((int)); 387 struct hostent *getipnodebyname __P((const char *, int, int, int *)); 388 struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *)); 389 void freehostent __P((struct hostent *)); 390 391 392 struct hostent *gethostbyaddr_r __P((const char *, int, int, struct hostent *, 393 char *, int, int *)); 394 struct hostent *gethostbyname_r __P((const char *, struct hostent *, 395 char *, int, int *)); 396 struct hostent *gethostent_r __P((struct hostent *, char *, int, int *)); 397 void sethostent_r __P((int)); 398 void endhostent_r __P((void)); 399 400 struct netent *getnetbyname_r __P((const char *, struct netent *, 401 char *, int)); 402 struct netent *getnetbyaddr_r __P((long, int, struct netent *, 403 char *, int)); 404 struct netent *getnetent_r __P((struct netent *, char *, int)); 405 void setnetent_r __P((int)); 406 void endnetent_r __P((void)); 407 408 struct protoent *getprotobyname_r __P((const char *, 409 struct protoent *, char *, int)); 410 struct protoent *getprotobynumber_r __P((int, 411 struct protoent *, char *, int)); 412 struct protoent *getprotoent_r __P((struct protoent *, char *, int)); 413 void setprotoent_r __P((int)); 414 void endprotoent_r __P((void)); 415 416 struct servent *getservbyname_r __P((const char *name, const char *, 417 struct servent *, char *, int)); 418 struct servent *getservbyport_r __P((int port, const char *, 419 struct servent *, char *, int)); 420 struct servent *getservent_r __P((struct servent *, char *, int)); 421 void setservent_r __P((int)); 422 void endservent_r __P((void)); 423 424 425 /* BeOS specific, because of lack of UNIX passwd functions */ 426 int getusername(char *username, unsigned userlen); 427 int getpassword(char *password, unsigned passlen); 428 429 430 #ifdef __cplusplus 431 } 432 #endif 433 434 #endif /* !_NETDB_H_ */ 435