summaryrefslogtreecommitdiff
path: root/tools/sniffer.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
committerAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
commit5d342a758c6095b4d30aba0750b54f13b8916f51 (patch)
tree762e9aa84781f5e3b96db2c02d356c29cf0217c0 /tools/sniffer.cpp
parentcbe2d992e9cd1ea66af9fa91df006106775d3073 (diff)
downloadmongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz
Imported Upstream version 2.0.0
Diffstat (limited to 'tools/sniffer.cpp')
-rw-r--r--tools/sniffer.cpp30
1 files changed, 24 insertions, 6 deletions
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 <pcap.h>
#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;
}
}