1 /* 2 * Copyright (c) 1980,1983,1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 /* 14 * Structures returned by network data base library. 15 * All addresses are supplied in host order, and 16 * returned in network order (suitable for use in system calls). 17 */ 18 19 #ifndef _netdb_h 20 #define _netdb_h 21 22 /* from UCB 5.9 4/5/88 */ 23 24 #pragma ident "%Z%%M% %I% %E% SMI" 25 26 #define _PATH_HEQUIV "/etc/hosts.equiv" 27 #define _PATH_HOSTS "/etc/hosts" 28 #define _PATH_NETWORKS "/etc/networks" 29 #define _PATH_PROTOCOLS "/etc/protocols" 30 #define _PATH_SERVICES "/etc/services" 31 32 struct hostent { 33 char *h_name; /* official name of host */ 34 char **h_aliases; /* alias list */ 35 int h_addrtype; /* host address type */ 36 int h_length; /* length of address */ 37 char **h_addr_list; /* list of addresses from name server */ 38 #define h_addr h_addr_list[0] /* address, for backward compatiblity */ 39 }; 40 41 /* 42 * Assumption here is that a network number 43 * fits in 32 bits -- probably a poor one. 44 */ 45 struct netent { 46 char *n_name; /* official name of net */ 47 char **n_aliases; /* alias list */ 48 int n_addrtype; /* net address type */ 49 unsigned long n_net; /* network # */ 50 }; 51 52 struct servent { 53 char *s_name; /* official service name */ 54 char **s_aliases; /* alias list */ 55 int s_port; /* port # */ 56 char *s_proto; /* protocol to use */ 57 }; 58 59 struct protoent { 60 char *p_name; /* official protocol name */ 61 char **p_aliases; /* alias list */ 62 int p_proto; /* protocol # */ 63 }; 64 65 struct rpcent { 66 char *r_name; /* name of server for this rpc program */ 67 char **r_aliases; /* alias list */ 68 int r_number; /* rpc program number */ 69 }; 70 71 struct hostent *gethostbyname(), *gethostbyaddr(), *gethostent(); 72 struct netent *getnetbyname(), *getnetbyaddr(), *getnetent(); 73 struct servent *getservbyname(), *getservbyport(), *getservent(); 74 struct protoent *getprotobyname(), *getprotobynumber(), *getprotoent(); 75 struct rpcent *getrpcbyname(), *getrpcbynumber(), *getrpcent(); 76 77 /* 78 * Error return codes from gethostbyname() and gethostbyaddr() 79 * (when using the resolver) 80 */ 81 82 extern int h_errno; 83 84 #define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */ 85 #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ 86 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 87 #define NO_DATA 4 /* Valid name, no data record of requested type */ 88 #define NO_ADDRESS NO_DATA /* no address, look for MX record */ 89 90 #define MAXALIASES 35 91 #define MAXADDRS 35 92 93 #endif /*!_netdb_h*/ 94