]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/dns.cc
3 * $Id: dns.cc,v 1.80 1999/12/30 17:36:30 wessels Exp $
5 * DEBUG: section 34 Dnsserver interface
6 * AUTHOR: Harvest Derived
8 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from the
12 * Internet community. Development is led by Duane Wessels of the
13 * National Laboratory for Applied Network Research and funded by the
14 * National Science Foundation. Squid is Copyrighted (C) 1998 by
15 * Duane Wessels and the University of California San Diego. Please
16 * see the COPYRIGHT file for full details. Squid incorporates
17 * software developed and/or copyrighted by other sources. Please see
18 * the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
38 static helper
*dnsservers
= NULL
;
42 dnsStats(StoreEntry
* sentry
)
44 storeAppendPrintf(sentry
, "Dnsserver Statistics:\n");
45 helperStats(sentry
, dnsservers
);
56 if (!Config
.Program
.dnsserver
)
58 if (dnsservers
== NULL
)
59 dnsservers
= helperCreate("dnsserver");
60 dnsservers
->n_to_start
= Config
.dnsChildren
;
61 dnsservers
->ipc_type
= IPC_TCP_SOCKET
;
62 assert(dnsservers
->cmdline
== NULL
);
63 wordlistAdd(&dnsservers
->cmdline
, Config
.Program
.dnsserver
);
64 if (Config
.onoff
.res_defnames
)
65 wordlistAdd(&dnsservers
->cmdline
, "-D");
66 for (w
= Config
.dns_nameservers
; w
!= NULL
; w
= w
->next
) {
67 wordlistAdd(&dnsservers
->cmdline
, "-s");
68 wordlistAdd(&dnsservers
->cmdline
, w
->key
);
70 helperOpenServers(dnsservers
);
72 cachemgrRegister("dns",
73 "Dnsserver Statistics",
85 helperShutdown(dnsservers
);
86 wordlistDestroy(&dnsservers
->cmdline
);
89 helperFree(dnsservers
);
94 dnsSubmit(const char *lookup
, HLPCB
* callback
, void *data
)
97 snprintf(buf
, 256, "%s\n", lookup
);
98 helperSubmit(dnsservers
, buf
, callback
, data
);
103 * The function to return the DNS via SNMP
106 snmp_netDnsFn(variable_list
* Var
, snint
* ErrP
)
108 variable_list
*Answer
= NULL
;
109 debug(49, 5) ("snmp_netDnsFn: Processing request:\n", Var
->name
[LEN_SQ_NET
+
111 snmpDebugOid(5, Var
->name
, Var
->name_length
);
112 *ErrP
= SNMP_ERR_NOERROR
;
113 switch (Var
->name
[LEN_SQ_NET
+ 1]) {
115 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
116 dnsservers
->stats
.requests
,
120 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
121 dnsservers
->stats
.replies
,
125 Answer
= snmp_var_new_integer(Var
->name
, Var
->name_length
,
126 dnsservers
->n_running
,
130 *ErrP
= SNMP_ERR_NOSUCHNAME
;
135 #endif /*SQUID_SNMP */