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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [include/] [net/] [netdb.h] - Blame information for rev 565

Go to most recent revision | Details | Compare with Previous | View Log

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