From 5d342a758c6095b4d30aba0750b54f13b8916f51 Mon Sep 17 00:00:00 2001 From: Antonin Kral Date: Wed, 14 Sep 2011 17:08:06 +0200 Subject: Imported Upstream version 2.0.0 --- tools/sniffer.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'tools/sniffer.cpp') diff --git a/tools/sniffer.cpp b/tools/sniffer.cpp index 0422f87..aeab808 100644 --- a/tools/sniffer.cpp +++ b/tools/sniffer.cpp @@ -26,7 +26,7 @@ killcursors */ - +#include "../pch.h" #include #ifdef _WIN32 @@ -35,7 +35,7 @@ #endif #include "../bson/util/builder.h" -#include "../util/message.h" +#include "../util/net/message.h" #include "../util/mmap.h" #include "../db/dbmessage.h" #include "../client/dbclient.h" @@ -69,6 +69,11 @@ using mongo::DBClientConnection; using mongo::QueryResult; using mongo::MemoryMappedFile; +mongo::CmdLine mongo::cmdLine; +namespace mongo { + void setupSignals( bool inFork ){} +} + #define SNAP_LEN 65535 int captureHeaderSize; @@ -99,7 +104,10 @@ struct sniff_ip { #define IP_V(ip) (((ip)->ip_vhl) >> 4) /* TCP header */ -typedef u_int32_t tcp_seq; +#ifdef _WIN32 +typedef unsigned __int32 uint32_t; +#endif +typedef uint32_t tcp_seq; struct sniff_tcp { u_short th_sport; /* source port */ @@ -271,7 +279,7 @@ void processMessage( Connection& c , Message& m ) { if ( m.operation() == mongo::opReply ) out() << " - " << (unsigned)m.header()->responseTo; - out() << endl; + out() << '\n'; try { switch( m.operation() ) { @@ -279,14 +287,23 @@ void processMessage( Connection& c , Message& m ) { mongo::QueryResult* r = (mongo::QueryResult*)m.singleData(); out() << "\treply" << " n:" << r->nReturned << " cursorId: " << r->cursorId << endl; if ( r->nReturned ) { - mongo::BSONObj o( r->data() , 0 ); + mongo::BSONObj o( r->data() ); out() << "\t" << o << endl; } break; } case mongo::dbQuery: { mongo::QueryMessage q(d); - out() << "\tquery: " << q.query << " ntoreturn: " << q.ntoreturn << " ntoskip: " << q.ntoskip << endl; + out() << "\tquery: " << q.query << " ntoreturn: " << q.ntoreturn << " ntoskip: " << q.ntoskip; + if( !q.fields.isEmpty() ) + out() << " hasfields"; + if( q.queryOptions & mongo::QueryOption_SlaveOk ) + out() << " SlaveOk"; + if( q.queryOptions & mongo::QueryOption_NoCursorTimeout ) + out() << " NoCursorTimeout"; + if( q.queryOptions & ~(mongo::QueryOption_SlaveOk | mongo::QueryOption_NoCursorTimeout) ) + out() << " queryOptions:" << hex << q.queryOptions; + out() << endl; break; } case mongo::dbUpdate: { @@ -323,6 +340,7 @@ void processMessage( Connection& c , Message& m ) { break; } default: + out() << "\tunknown opcode " << m.operation() << endl; cerr << "*** CANNOT HANDLE TYPE: " << m.operation() << endl; } } -- cgit v1.2.3