VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/slirp/dnsproxy/dnsproxy.h@ 90447

Last change on this file since 90447 was 53624, checked in by vboxsync, 10 years ago

scm automatic cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: dnsproxy.h 53624 2014-12-31 14:59:44Z vboxsync $ */
2/*
3 * Copyright (c) 2003,2004,2005 Armin Wolfermann
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef _DNSPROXY_H_
25#define _DNSPROXY_H_
26
27/* LONGLONG */
28#include <sys/types.h>
29
30#if TIME_WITH_SYS_TIME
31# include <sys/time.h>
32# include <time.h>
33#else
34# if HAVE_SYS_TIME_H
35# include <sys/time.h>
36# else
37# include <time.h>
38# endif
39#endif
40
41#ifndef VBOX
42#include <sys/socket.h>
43#include <netinet/in.h>
44#ifdef HAVE_ARPA_INET_H
45# include <arpa/inet.h>
46#endif
47#include <stdarg.h>
48
49#include <event.h>
50
51#ifdef DEBUG
52#define DPRINTF(x) do { printf x ; } while (0)
53#else
54#define DPRINTF(x)
55#endif
56
57#ifdef GLOBALS
58#define GLOBAL(a) a
59#define GLOBAL_INIT(a,b) a = b
60#else
61#define GLOBAL(a) extern a
62#define GLOBAL_INIT(a,b) extern a
63#endif
64#endif
65
66struct request {
67 unsigned short id;
68
69 struct sockaddr_in client;
70 unsigned short clientid;
71 unsigned char recursion;
72
73#ifndef VBOX
74 struct event timeout;
75#endif
76
77 struct request **prev;
78 struct request *next;
79#ifdef VBOX
80 /* this field used for saving last attempt
81 * to connect server, timeout function should change
82 * it's value on next server. And dnsproxy_query should
83 * initializate with first server in the list
84 *
85 * dnsgen is a generation number - a copy of pData->dnsgen at the
86 * time of request creation (poor man's weak reference).
87 * dns_server must not be used if pData->dnsgen changed.
88 */
89 struct dns_entry *dns_server;
90 uint32_t dnsgen;
91 int nbyte; /* length of dns request */
92 char byte[1]; /* copy of original request */
93#endif
94};
95
96#ifndef VBOX
97GLOBAL_INIT(unsigned int authoritative_port, 53);
98GLOBAL_INIT(unsigned int authoritative_timeout, 10);
99GLOBAL_INIT(unsigned int recursive_port, 53);
100GLOBAL_INIT(unsigned int recursive_timeout, 90);
101GLOBAL_INIT(unsigned int stats_timeout, 3600);
102GLOBAL_INIT(unsigned int port, 53);
103
104GLOBAL(char *authoritative);
105GLOBAL(char *chrootdir);
106GLOBAL(char *listenat);
107GLOBAL(char *recursive);
108GLOBAL(char *user);
109
110GLOBAL(unsigned long active_queries);
111GLOBAL(unsigned long all_queries);
112GLOBAL(unsigned long authoritative_queries);
113GLOBAL(unsigned long recursive_queries);
114GLOBAL(unsigned long removed_queries);
115GLOBAL(unsigned long dropped_queries);
116GLOBAL(unsigned long answered_queries);
117GLOBAL(unsigned long dropped_answers);
118GLOBAL(unsigned long late_answers);
119GLOBAL(unsigned long hash_collisions);
120
121/* dnsproxy.c */
122RETSIGTYPE signal_handler(int);
123int signal_event(void);
124
125/* daemon.c */
126int daemon(int, int);
127#endif
128
129/* hash.c */
130void hash_add_request(PNATState, struct request *);
131void hash_remove_request(PNATState, struct request *);
132struct request *hash_find_request(PNATState, unsigned short);
133
134/* internal.c */
135int add_internal(PNATState, char *);
136int is_internal(PNATState, struct in_addr);
137
138#ifndef VBOX
139/* log.c */
140void log_syslog(const char *);
141void info(const char *, ...);
142void error(const char *, ...);
143void fatal(const char *, ...);
144
145/* parse.c */
146int parse(const char *);
147
148/* statistics.c */
149void statistics_start(void);
150#else
151# define DPRINTF Log2
152int dnsproxy_init(PNATState pData);
153void dnsproxy_query(PNATState pData, struct socket *so, struct mbuf *m, int iphlen);
154void dnsproxy_answer(PNATState pData, struct socket *so, struct mbuf *m);
155#endif
156
157#endif /* _DNSPROXY_H_ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette