OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [common/] [current/] [include/] [net/] [netdb.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      include/netdb.h
4
//
5
//      eCos implementations of network "database" functions
6
//
7
//==========================================================================
8
// ####BSDALTCOPYRIGHTBEGIN####                                             
9
// -------------------------------------------                              
10
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
11
// or other sources, and if so are covered by the appropriate copyright     
12
// and license included herein.                                             
13
// -------------------------------------------                              
14
// ####BSDALTCOPYRIGHTEND####                                               
15
//==========================================================================
16
//#####DESCRIPTIONBEGIN####
17
//
18
// Author(s):    gthomas
19
// Contributors: gthomas
20
// Date:         2000-01-10
21
// Purpose:      
22
// Description:  
23
//              
24
//
25
//####DESCRIPTIONEND####
26
//
27
//==========================================================================
28
 
29
//
30
// Support for various "network databases"
31
//
32
 
33
#ifndef _NETDB_H_
34
#define _NETDB_H_
35
 
36
#include <sys/param.h>
37
 
38
#ifdef __cplusplus
39
extern "C" {
40
#endif
41
 
42
// Internet protocols
43
struct protoent {
44
    char *p_name;
45
    int   p_proto;
46
};
47
 
48
struct protoent *getprotobyname(const char *);
49
struct protoent *getprotobynumber(const int);
50
 
51
// Internet services
52
struct servent {
53
    char    *s_name;        /* official service name */
54
    char    **s_aliases;    /* alias list */
55
    int     s_port;         /* port number */
56
    char    *s_proto;       /* protocol to use */
57
};
58
 
59
struct servent *getservbyname(const char *name, const char *proto);
60
struct servent *getservbyport(int port, const char *proto);
61
 
62
// Name/address manipulation
63
struct addrinfo {
64
        int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
65
        int     ai_family;      /* PF_xxx */
66
        int     ai_socktype;    /* SOCK_xxx */
67
        int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
68
        size_t  ai_addrlen;     /* length of ai_addr */
69
        char    *ai_canonname;  /* canonical name for hostname */
70
        struct  sockaddr *ai_addr;      /* binary address */
71
        struct  addrinfo *ai_next;      /* next structure in linked list */
72
};
73
 
74
/*
75
 * Error return codes from getaddrinfo(), getnameinfo()
76
 */
77
#define EAI_NONE         0      /* valid return - no errors */
78
#define EAI_AGAIN        2      /* temporary failure in name resolution */
79
#define EAI_BADFLAGS     3      /* invalid value for ai_flags */
80
#define EAI_FAIL         4      /* non-recoverable failure in name resolution */
81
#define EAI_FAMILY       5      /* ai_family not supported */
82
#define EAI_MEMORY       6      /* memory allocation failure */
83
#define EAI_NONAME       8      /* hostname nor servname provided, or not known */
84
#define EAI_SERVICE      9      /* servname not supported for ai_socktype */
85
#define EAI_SOCKTYPE    10      /* ai_socktype not supported */
86
#define EAI_SYSTEM      11      /* system error returned in errno */
87
#define EAI_BADHINTS    12      /* inconsistent hints */
88
#define EAI_PROTOCOL    13
89
#define EAI_MAX         14
90
 
91
/*
92
 * Flag values for getaddrinfo()
93
 */
94
#define AI_PASSIVE      0x00000001 /* get address to use bind() */
95
#define AI_CANONNAME    0x00000002 /* fill ai_canonname */
96
#define AI_NUMERICHOST  0x00000004 /* prevent name resolution */
97
/* valid flags for addrinfo */
98
#define AI_MASK \
99
    (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG)
100
 
101
#define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
102
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
103
#define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
104
#define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
105
/* special recommended flags for getipnodebyname */
106
#define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
107
 
108
int   getaddrinfo(const char *, const char *,
109
                  const struct addrinfo *, struct addrinfo **);
110
void  freeaddrinfo(struct addrinfo *);
111
char *gai_strerror(int);
112
 
113
/*
114
 * Support for getnameinfo()
115
 */
116
 
117
#define NI_MAXHOST      1025
118
#define NI_MAXSERV      32
119
 
120
#define NI_NUMERICHOST 1       /* Don't try to look up hostname.  */
121
#define NI_NUMERICSERV 2       /* Don't convert port number to name.  */
122
#define NI_NOFQDN      4       /* Only return nodename portion.  */
123
#define NI_NAMEREQD    8       /* Don't return numeric addresses.  */
124
#define NI_DGRAM       16      /* Look up UDP service rather than TCP.  */
125
 
126
/* Translate a socket address to a location and service name.  */
127
int getnameinfo (const struct sockaddr *sa, socklen_t salen,
128
                 char *host, socklen_t hostlen,
129
                 char *serv, socklen_t servlen,
130
                 unsigned int flags);
131
 
132
// Miscellaneous address manipulation functions
133
#include <netinet/in.h>
134
char     *inet_ntoa(struct in_addr);
135
char     *inet_ntoa_r(struct in_addr, char *);
136
char     *inet_ntop(int af, const char *src, char *dst, size_t len);
137
int      inet_pton(int af, const char *src, char *dst);
138
char     *_inet_ntop(struct sockaddr *sa, char *dst, size_t len);
139
u_int16_t _inet_port(struct sockaddr *sa);
140
 
141
#ifdef __cplusplus
142
}
143
#endif
144
#endif // _NETDB_H_

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.