source: rtems-libbsd/freebsd/lib/libc/net/netdb_private.h @ bceabc9

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since bceabc9 was bceabc9, checked in by Sebastian Huber <sebastian.huber@…>, on 10/09/13 at 20:42:09

Move files to match FreeBSD layout

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*-
2 * Copyright (C) 2005 The FreeBSD Project.  All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
25 * $FreeBSD$
26 */
27
28#ifndef _NETDB_PRIVATE_H_
29#define _NETDB_PRIVATE_H_
30
31#include <stdio.h>                              /* XXX: for FILE */
32
33#define NETDB_THREAD_ALLOC(name)                                        \
34static thread_key_t name##_key;                                         \
35static once_t name##_init_once = ONCE_INITIALIZER;                      \
36static int name##_thr_keycreated = 0;                                   \
37\
38static void name##_free(void *);                                        \
39\
40static void                                                             \
41name##_keycreate(void)                                                  \
42{                                                                       \
43        name##_thr_keycreated =                                         \
44            (thr_keycreate(&name##_key, name##_free) == 0);             \
45}                                                                       \
46\
47struct name *                                                           \
48__##name##_init(void)                                                   \
49{                                                                       \
50        struct name *he;                                                \
51                                                                        \
52        if (thr_once(&name##_init_once, name##_keycreate) != 0 ||       \
53            !name##_thr_keycreated)                                     \
54                return (NULL);                                          \
55        if ((he = thr_getspecific(name##_key)) != NULL)                 \
56                return (he);                                            \
57        if ((he = calloc(1, sizeof(*he))) == NULL)                      \
58                return (NULL);                                          \
59        if (thr_setspecific(name##_key, he) == 0)                       \
60                return (he);                                            \
61        free(he);                                                       \
62        return (NULL);                                                  \
63}
64
65#define _MAXALIASES     35
66#define _MAXLINELEN     1024
67#define _MAXADDRS       35
68#define _HOSTBUFSIZE    (8 * 1024)
69#define _NETBUFSIZE     1025
70
71struct hostent_data {
72        uint32_t host_addr[4];                  /* IPv4 or IPv6 */
73        char *h_addr_ptrs[_MAXADDRS + 1];
74        char *host_aliases[_MAXALIASES];
75        char hostbuf[_HOSTBUFSIZE];
76        FILE *hostf;
77        int stayopen;
78#ifdef YP
79        char *yp_domain;
80#endif
81};
82
83struct netent_data {
84        char *net_aliases[_MAXALIASES];
85        char netbuf[_NETBUFSIZE];
86        FILE *netf;
87        int stayopen;
88#ifdef YP
89        char *yp_domain;
90#endif
91};
92
93struct protoent_data {
94        FILE *fp;
95        char *aliases[_MAXALIASES];
96        int stayopen;
97        char line[_MAXLINELEN + 1];
98};
99
100struct hostdata {
101        struct hostent host;
102        char data[sizeof(struct hostent_data)];
103};
104
105struct netdata {
106        struct netent net;
107        char data[sizeof(struct netent_data)];
108};
109
110struct protodata {
111        struct protoent proto;
112        char data[sizeof(struct protoent_data)];
113};
114
115struct hostdata *__hostdata_init(void);
116struct hostent *__hostent_init(void);
117struct hostent_data *__hostent_data_init(void);
118struct netdata *__netdata_init(void);
119struct netent_data *__netent_data_init(void);
120struct protodata *__protodata_init(void);
121struct protoent_data *__protoent_data_init(void);
122int __copy_hostent(struct hostent *, struct hostent *, char *, size_t);
123int __copy_netent(struct netent *, struct netent *, char *, size_t);
124int __copy_protoent(struct protoent *, struct protoent *, char *, size_t);
125
126void __endprotoent_p(struct protoent_data *);
127int __getprotoent_p(struct protoent *, struct protoent_data *);
128void __setprotoent_p(int, struct protoent_data *);
129void _endhostdnsent(void);
130void _endhosthtent(struct hostent_data *);
131void _endnetdnsent(void);
132void _endnethtent(struct netent_data *);
133struct hostent *_gethostbynisaddr(const void *, socklen_t, int);
134struct hostent *_gethostbynisname(const char *, int);
135void _map_v4v6_address(const char *, char *);
136void _map_v4v6_hostent(struct hostent *, char **, char *);
137void _sethostdnsent(int);
138void _sethosthtent(int, struct hostent_data *);
139void _setnetdnsent(int);
140void _setnethtent(int, struct netent_data *);
141
142#endif /* _NETDB_PRIVATE_H_ */
Note: See TracBrowser for help on using the repository browser.