summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/protocol.h
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2016-08-19 11:26:05 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2016-08-19 11:43:31 -0400
commit78c06c7e342bb159bcf22c85502cb7db3a695ffd (patch)
tree2ac566e4a34dd2945db79e949cc5c94d8463e034 /src/mongo/rpc/protocol.h
parent1a3d60af4d27d72e15637bb43510fe1b592a6c43 (diff)
downloadmongo-78c06c7e342bb159bcf22c85502cb7db3a695ffd.tar.gz
SERVER-25393 Disallow mongos making connections to older versions
Diffstat (limited to 'src/mongo/rpc/protocol.h')
-rw-r--r--src/mongo/rpc/protocol.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/mongo/rpc/protocol.h b/src/mongo/rpc/protocol.h
index 45280849c29..6ac205ccc2f 100644
--- a/src/mongo/rpc/protocol.h
+++ b/src/mongo/rpc/protocol.h
@@ -33,6 +33,7 @@
#include <type_traits>
#include "mongo/base/status_with.h"
+#include "mongo/db/wire_version.h"
namespace mongo {
class BSONObj;
@@ -108,19 +109,34 @@ StatusWith<StringData> toString(ProtocolSet protocols);
StatusWith<ProtocolSet> parseProtocolSet(StringData repr);
/**
+ * Validates client and server wire version. The server is returned from isMaster, and the client is
+ * from WireSpec.instance().
+ */
+Status validateWireVersion(const WireVersionInfo client, const WireVersionInfo server);
+
+/**
+ * Struct to pass around information about protocol set and wire version.
+ */
+struct ProtocolSetAndWireVersionInfo {
+ ProtocolSet protocolSet;
+ WireVersionInfo version;
+};
+
+/**
* Determines the ProtocolSet of a remote server from an isMaster reply.
*/
-StatusWith<ProtocolSet> parseProtocolSetFromIsMasterReply(const BSONObj& isMasterReply);
+StatusWith<ProtocolSetAndWireVersionInfo> parseProtocolSetFromIsMasterReply(
+ const BSONObj& isMasterReply);
/**
* Returns true if wire version supports OP_COMMAND in mongod (not mongos).
*/
-bool supportsWireVersionForOpCommandInMongod(int minWireVersion, int maxWireVersion);
+bool supportsWireVersionForOpCommandInMongod(const WireVersionInfo version);
/**
* Computes supported protocols from wire versions.
*/
-ProtocolSet computeProtocolSet(int minWireVersion, int maxWireVersion);
+ProtocolSet computeProtocolSet(const WireVersionInfo version);
} // namespace rpc
} // namespace mongo