TizenRT Libs&Environment  v2.0 M2
netdb.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * include/netdb.h
20  *
21  * Copyright (C) 2015 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Reference: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html
25  *
26  * Redistribution and use in source and binary forms, with or without
27  * modification, are permitted provided that the following conditions
28  * are met:
29  *
30  * 1. Redistributions of source code must retain the above copyright
31  * notice, this list of conditions and the following disclaimer.
32  * 2. Redistributions in binary form must reproduce the above copyright
33  * notice, this list of conditions and the following disclaimer in
34  * the documentation and/or other materials provided with the
35  * distribution.
36  * 3. Neither the name NuttX nor the names of its contributors may be
37  * used to endorse or promote products derived from this software
38  * without specific prior written permission.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
43  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
44  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
45  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
46  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
47  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
48  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
50  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51  * POSSIBILITY OF SUCH DAMAGE.
52  *
53  ****************************************************************************/
65 #ifndef __INCLUDE_NETDB_H
66 #define __INCLUDE_NETDB_H
67 
68 /****************************************************************************
69  * Included Files
70  ****************************************************************************/
71 
72 #include <tinyara/config.h>
73 #include <tinyara/compiler.h>
74 
75 /* Inclusion of the <netdb.h> header may also make visible all symbols from
76  * <netinet/in.h>, <sys/socket.h>, and <inttypes.h>.
77  */
78 
79 #include <inttypes.h>
80 
81 #include <net/lwip/netdb.h>
82 #include <netinet/in.h>
83 #include <sys/socket.h>
84 
85  /****************************************************************************
86  * Public Types
87  ****************************************************************************/
88 #define h_addr h_addr_list[0] /* For backward compatibility */
89 
90 struct netent {
91  FAR char *n_name; /* Official, fully-qualified (including the domain)
92  * name of the host. */
93  FAR char **n_aliases; /* A pointer to an array of pointers to alternative
94  * network names, terminated by a null pointer. */
95  int n_addrtype; /* The address type of the network. */
96  uint32_t n_net; /* The network number, in host byte order. */
97 };
98 
99 struct protoent {
100  FAR char *p_name; /* Official name of the protocol. */
101  FAR char **p_aliases; /* A pointer to an array of pointers to
102  * alternative protocol names, terminated by a
103  * null pointer. */
104  int p_proto; /* The protocol number. */
105 };
106 
107 struct servent {
108  FAR char *s_name; /* Official name of the service. */
109  FAR char **s_aliases; /* A pointer to an array of pointers to
110  * alternative service names, terminated by a
111  * null pointer. */
112  int s_port; /* The port number at which the service resides,
113  * in network byte order. */
114  FAR char *s_proto; /* The name of the protocol to use when
115  * contacting the service. */
116 };
117 
118 struct servent_data {
119  void *fp;
120  char **aliases;
122  int stayopen;
123  char *line;
124 };
125 
126 /****************************************************************************
127  * Public Data
128  ****************************************************************************/
129 
130 #ifdef __cplusplus
131 #define EXTERN extern "C"
132 extern "C" {
133 #else
134 #define EXTERN extern
135 #endif
136 
144 struct hostent *gethostbyname(const char *name);
145 
153 void freeaddrinfo(struct addrinfo *ai);
154 
165 int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
166 
180 int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
181 
182 /* REVISIT: This should at least be per-task? */
184 
185 #undef EXTERN
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* __INCLUDE_NETDB_H */
191 
FAR char ** s_aliases
Definition: netdb.h:109
Definition: netdb.h:90
char ** aliases
Definition: netdb.h:120
struct hostent * gethostbyname(const char *name)
gethostbyname is a function to get 32bit ip address from domain name or ip address string...
int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
getnameinfo() is a function that returns translated string from 32bit(ipv4)/128bit(ipv6) IP address...
Definition: netdb.h:107
int s_port
Definition: netdb.h:112
int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
getaddrinfo() is a function that returns information on a particular host name (such as its IP addres...
void freeaddrinfo(struct addrinfo *ai)
freeaddrinfo() frees the memory allocated by the getaddrinfo() function.
int n_addrtype
Definition: netdb.h:95
Definition: netdb.h:99
FAR char * s_proto
Definition: netdb.h:114
uint32_t n_net
Definition: netdb.h:96
EXTERN int h_errno
Definition: netdb.h:183
FAR char ** p_aliases
Definition: netdb.h:101
char * line
Definition: netdb.h:123
int maxaliases
Definition: netdb.h:121
int stayopen
Definition: netdb.h:122
#define EXTERN
Definition: netdb.h:134
FAR char ** n_aliases
Definition: netdb.h:93
Inttypes APIs.
FAR char * s_name
Definition: netdb.h:108
FAR char * n_name
Definition: netdb.h:91
FAR char * p_name
Definition: netdb.h:100
int p_proto
Definition: netdb.h:104
void * fp
Definition: netdb.h:119
Socket APIs.