+/*
+ * This file is part of PowerDNS or dnsdist.
+ * Copyright -- PowerDNS.COM B.V. and its contributors
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In addition, for the avoidance of any doubt, permission is granted to
+ * link this program with OpenSSL and to (re)distribute the binaries
+ * produced as the result of such linking.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <bitset>
#include "statbag.hh"
#include "dnspcap.hh"
#include "sstuff.hh"
#include "anadns.hh"
-// this is needed because boost multi_index also uses 'L', as do we (which is sad enough)
-#undef L
#include <set>
#include <deque>
#include "namespaces.hh"
StatBag S;
+void usage() {
+ cerr<<"syntax: dnsscan INFILE ..."<<endl;
+}
+
int main(int argc, char** argv)
try
{
*/
if(argc<2) {
- cerr<<"Syntax: dnsscan file1 [file2 ..] "<<endl;
- exit(1);
+ usage();
+ exit(EXIT_SUCCESS);
+ }
+
+ for(int n=1; n < argc; ++n) {
+ if ((string) argv[n] == "--help") {
+ usage();
+ return EXIT_SUCCESS;
+ }
+
+ if ((string) argv[n] == "--version") {
+ cerr<<"dnsscan "<<VERSION<<endl;
+ return EXIT_SUCCESS;
+ }
}
unsigned int counts[256];
while(pr.getUDPPacket()) {
try {
- MOADNSParser mdp((const char*)pr.d_payload, pr.d_len);
+ MOADNSParser mdp(false, (const char*)pr.d_payload, pr.d_len);
if(mdp.d_qtype < 256)
counts[mdp.d_qtype]++;
- for(unsigned int i=0; i < mdp.d_qname.length(); ++i)
- if(!isalnum(mdp.d_qname[i]) && mdp.d_qname[i]!='.' && mdp.d_qname[i]!='-' && mdp.d_qname[i]!='_') {
- // cout<<mdp.d_qname<<"|"<<mdp.d_qtype<<"|"<<mdp.d_qclass<<"\n";
- // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
- break;
- }
- if(mdp.d_qtype > 256 || mdp.d_qclass!=1 ) {
- // sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
-
- }
- for(MOADNSParser::answers_t::const_iterator i=mdp.d_answers.begin(); i!=mdp.d_answers.end(); ++i) {
-
- }
-
}
- catch(MOADNSException &e) {
- cout<<"Error from remote "<<U32ToIP(ntohl(*((uint32_t*)&pr.d_ip->ip_src)))<<": "<<e.what()<<"\n";
+ catch(const MOADNSException &mde) {
+ cout<<"Error from remote "<<pr.getSource().toString()<<": "<<mde.what()<<"\n";
// sock.sendTo(string(pr.d_payload, pr.d_payload + pr.d_len), remote);
}
}