netInterface.cc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "platform/event.h"
  24. #include "network/netConnection.h"
  25. #include "network/netInterface.h"
  26. #include "io/bitStream.h"
  27. #include "math/mRandom.h"
  28. #include "game/gameInterface.h"
  29. NetInterface *GNet = NULL;
  30. NetInterface::NetInterface()
  31. {
  32. AssertFatal(GNet == NULL, "ERROR: Multiple net interfaces declared.");
  33. GNet = this;
  34. mLastTimeoutCheckTime = 0;
  35. mAllowConnections = true;
  36. }
  37. void NetInterface::initRandomData()
  38. {
  39. mRandomDataInitialized = true;
  40. U32 seed = Platform::getRealMilliseconds();
  41. #ifdef TORQUE_ALLOW_JOURNALING
  42. if(Game->isJournalReading())
  43. Game->journalRead(&seed);
  44. else if(Game->isJournalWriting())
  45. Game->journalWrite(seed);
  46. #endif //TORQUE_ALLOW_JOURNALING
  47. RandomR250 myRandom(seed);
  48. for(U32 i = 0; i < 12; i++)
  49. mRandomHashData[i] = myRandom.randI();
  50. }
  51. void NetInterface::addPendingConnection(NetConnection *connection)
  52. {
  53. Con::printf("Adding a pending connection");
  54. mPendingConnections.push_back(connection);
  55. }
  56. void NetInterface::removePendingConnection(NetConnection *connection)
  57. {
  58. for(U32 i = 0; i < (U32)mPendingConnections.size(); i++)
  59. if(mPendingConnections[i] == connection)
  60. mPendingConnections.erase(i);
  61. }
  62. NetConnection *NetInterface::findPendingConnection(const NetAddress *address, U32 connectSequence)
  63. {
  64. for(U32 i = 0; i < (U32)mPendingConnections.size(); i++)
  65. if(Net::compareAddresses(address, mPendingConnections[i]->getNetAddress()) &&
  66. connectSequence == mPendingConnections[i]->getSequence())
  67. return mPendingConnections[i];
  68. return NULL;
  69. }
  70. void NetInterface::processPacketReceiveEvent(PacketReceiveEvent *prEvent)
  71. {
  72. U32 dataSize = prEvent->size - PacketReceiveEventHeaderSize;
  73. BitStream pStream(prEvent->data, dataSize);
  74. // Determine what to do with this packet:
  75. if(prEvent->data[0] & 0x01) // it's a protocol packet...
  76. {
  77. // if the LSB of the first byte is set, it's a game data packet
  78. // so pass it to the appropriate connection.
  79. // lookup the connection in the addressTable
  80. NetConnection *conn = NetConnection::lookup(&prEvent->sourceAddress);
  81. if(conn)
  82. conn->processRawPacket(&pStream);
  83. }
  84. else
  85. {
  86. // Otherwise, it's either a game info packet or a
  87. // connection handshake packet.
  88. U8 packetType;
  89. pStream.read(&packetType);
  90. NetAddress *addr = &prEvent->sourceAddress;
  91. if(packetType <= GameHeartbeat)
  92. handleInfoPacket(addr, packetType, &pStream);
  93. else
  94. {
  95. // check if there's a connection already:
  96. switch(packetType)
  97. {
  98. case ConnectChallengeRequest:
  99. handleConnectChallengeRequest(addr, &pStream);
  100. break;
  101. case ConnectRequest:
  102. handleConnectRequest(addr, &pStream);
  103. break;
  104. case ConnectChallengeResponse:
  105. handleConnectChallengeResponse(addr, &pStream);
  106. break;
  107. case ConnectAccept:
  108. handleConnectAccept(addr, &pStream);
  109. break;
  110. case Disconnect:
  111. handleDisconnect(addr, &pStream);
  112. break;
  113. case ConnectReject:
  114. handleConnectReject(addr, &pStream);
  115. break;
  116. }
  117. }
  118. }
  119. }
  120. //-----------------------------------------------------------------------------
  121. //-----------------------------------------------------------------------------
  122. // Connection handshaking basic overview:
  123. // The torque engine does a two phase connect handshake to
  124. // prevent a spoofed source address Denial-of-Service (DOS) attack
  125. //
  126. // Basically, the initiator of a connection (client) sends a
  127. // Connect Challenge Request packet to the server to initiate the connection
  128. // The server then hashes the source address of the client request
  129. // with some random magic server data to come up with a 16-byte key that
  130. // the client can then use to gain entry to the server.
  131. // This way there are no partially active connection records on the
  132. // server at all.
  133. //
  134. // The client then sends a Connect Request packet to the server,
  135. // including any game specific data necessary to start a connection (a
  136. // server password, for instance), along with the key the server sent
  137. // on the Connect Challenge Response packet.
  138. //
  139. // The server, on receipt of the Connect Request, compares the
  140. // entry key with a computed key, makes sure it can create the requested
  141. // NetConnection subclass, and then passes all processing on to the connection
  142. // instance.
  143. //
  144. // If the subclass reads and accepts he connect request successfully, the
  145. // server sends a Connect Accept packet - otherwise the connection
  146. // is rejected with the sendConnectReject function
  147. //-----------------------------------------------------------------------------
  148. //-----------------------------------------------------------------------------
  149. void NetInterface::sendConnectChallengeRequest(NetConnection *conn)
  150. {
  151. Con::printf("Sending Connect challenge Request");
  152. BitStream *out = BitStream::getPacketStream();
  153. out->write(U8(ConnectChallengeRequest));
  154. out->write(conn->getSequence());
  155. conn->mConnectSendCount++;
  156. conn->mConnectLastSendTime = Platform::getVirtualMilliseconds();
  157. BitStream::sendPacketStream(conn->getNetAddress());
  158. }
  159. void NetInterface::handleConnectChallengeRequest(const NetAddress *addr, BitStream *stream)
  160. {
  161. char buf[256];
  162. Net::addressToString(addr, buf);
  163. Con::printf("Got Connect challenge Request from %s", buf);
  164. if(!mAllowConnections)
  165. return;
  166. U32 connectSequence;
  167. stream->read(&connectSequence);
  168. if(!mRandomDataInitialized)
  169. initRandomData();
  170. U32 addressDigest[4];
  171. computeNetMD5(addr, connectSequence, addressDigest);
  172. BitStream *out = BitStream::getPacketStream();
  173. out->write(U8(ConnectChallengeResponse));
  174. out->write(connectSequence);
  175. out->write(addressDigest[0]);
  176. out->write(addressDigest[1]);
  177. out->write(addressDigest[2]);
  178. out->write(addressDigest[3]);
  179. BitStream::sendPacketStream(addr);
  180. }
  181. //-----------------------------------------------------------------------------
  182. void NetInterface::handleConnectChallengeResponse(const NetAddress *address, BitStream *stream)
  183. {
  184. Con::printf("Got Connect challenge Response");
  185. U32 connectSequence;
  186. stream->read(&connectSequence);
  187. NetConnection *conn = findPendingConnection(address, connectSequence);
  188. if(!conn || conn->getConnectionState() != NetConnection::AwaitingChallengeResponse)
  189. return;
  190. U32 addressDigest[4];
  191. stream->read(&addressDigest[0]);
  192. stream->read(&addressDigest[1]);
  193. stream->read(&addressDigest[2]);
  194. stream->read(&addressDigest[3]);
  195. conn->setAddressDigest(addressDigest);
  196. conn->setConnectionState(NetConnection::AwaitingConnectResponse);
  197. conn->mConnectSendCount = 0;
  198. Con::printf("Sending Connect Request");
  199. sendConnectRequest(conn);
  200. }
  201. //-----------------------------------------------------------------------------
  202. void NetInterface::sendConnectRequest(NetConnection *conn)
  203. {
  204. BitStream *out = BitStream::getPacketStream();
  205. out->write(U8(ConnectRequest));
  206. out->write(conn->getSequence());
  207. U32 addressDigest[4];
  208. conn->getAddressDigest(addressDigest);
  209. out->write(addressDigest[0]);
  210. out->write(addressDigest[1]);
  211. out->write(addressDigest[2]);
  212. out->write(addressDigest[3]);
  213. out->writeString(conn->getClassName());
  214. conn->writeConnectRequest(out);
  215. conn->mConnectSendCount++;
  216. conn->mConnectLastSendTime = Platform::getVirtualMilliseconds();
  217. BitStream::sendPacketStream(conn->getNetAddress());
  218. }
  219. //-----------------------------------------------------------------------------
  220. void NetInterface::handleConnectRequest(const NetAddress *address, BitStream *stream)
  221. {
  222. if(!mAllowConnections)
  223. return;
  224. Con::printf("Got Connect Request");
  225. U32 connectSequence;
  226. stream->read(&connectSequence);
  227. // see if the connection is in the main connection table:
  228. NetConnection *connect = NetConnection::lookup(address);
  229. if(connect && connect->getSequence() == connectSequence)
  230. {
  231. sendConnectAccept(connect);
  232. return;
  233. }
  234. U32 addressDigest[4];
  235. U32 computedAddressDigest[4];
  236. stream->read(&addressDigest[0]);
  237. stream->read(&addressDigest[1]);
  238. stream->read(&addressDigest[2]);
  239. stream->read(&addressDigest[3]);
  240. computeNetMD5(address, connectSequence, computedAddressDigest);
  241. if(addressDigest[0] != computedAddressDigest[0] ||
  242. addressDigest[1] != computedAddressDigest[1] ||
  243. addressDigest[2] != computedAddressDigest[2] ||
  244. addressDigest[3] != computedAddressDigest[3])
  245. return; // bogus connection attempt
  246. if(connect)
  247. {
  248. if(connect->getSequence() > connectSequence)
  249. return; // the existing connection should be kept - the incoming request is stale.
  250. else
  251. connect->deleteObject(); // disconnect this one, and allow the new one to be created.
  252. }
  253. char connectionClass[255];
  254. stream->readString(connectionClass);
  255. ConsoleObject *co = ConsoleObject::create(connectionClass);
  256. NetConnection *conn = dynamic_cast<NetConnection *>(co);
  257. if(!conn || !conn->canRemoteCreate())
  258. {
  259. delete co;
  260. return;
  261. }
  262. conn->registerObject();
  263. conn->setNetAddress(address);
  264. conn->setNetworkConnection(true);
  265. conn->setSequence(connectSequence);
  266. const char *errorString = NULL;
  267. if(!conn->readConnectRequest(stream, &errorString))
  268. {
  269. sendConnectReject(conn, errorString);
  270. conn->deleteObject();
  271. return;
  272. }
  273. conn->setNetworkConnection(true);
  274. conn->onConnectionEstablished(false);
  275. conn->setEstablished();
  276. conn->setConnectSequence(connectSequence);
  277. sendConnectAccept(conn);
  278. }
  279. //-----------------------------------------------------------------------------
  280. void NetInterface::sendConnectAccept(NetConnection *conn)
  281. {
  282. BitStream *out = BitStream::getPacketStream();
  283. out->write(U8(ConnectAccept));
  284. out->write(conn->getSequence());
  285. conn->writeConnectAccept(out);
  286. BitStream::sendPacketStream(conn->getNetAddress());
  287. }
  288. void NetInterface::handleConnectAccept(const NetAddress *address, BitStream *stream)
  289. {
  290. U32 connectSequence;
  291. stream->read(&connectSequence);
  292. NetConnection *conn = findPendingConnection(address, connectSequence);
  293. if(!conn || conn->getConnectionState() != NetConnection::AwaitingConnectResponse)
  294. return;
  295. const char *errorString = NULL;
  296. if(!conn->readConnectAccept(stream, &errorString))
  297. {
  298. conn->handleStartupError(errorString);
  299. removePendingConnection(conn);
  300. conn->deleteObject();
  301. return;
  302. }
  303. removePendingConnection(conn); // remove from the pending connection list
  304. conn->setNetworkConnection(true);
  305. conn->onConnectionEstablished(true); // notify the connection that it has been established
  306. conn->setEstablished(); // installs the connection in the connection table, and causes pings/timeouts to happen
  307. conn->setConnectSequence(connectSequence);
  308. }
  309. void NetInterface::sendConnectReject(NetConnection *conn, const char *reason)
  310. {
  311. if(!reason)
  312. return; // if the stream is NULL, we reject silently
  313. BitStream *out = BitStream::getPacketStream();
  314. out->write(U8(ConnectReject));
  315. out->write(conn->getSequence());
  316. out->writeString(reason);
  317. BitStream::sendPacketStream(conn->getNetAddress());
  318. }
  319. void NetInterface::handleConnectReject(const NetAddress *address, BitStream *stream)
  320. {
  321. U32 connectSequence;
  322. stream->read(&connectSequence);
  323. NetConnection *conn = findPendingConnection(address, connectSequence);
  324. if(!conn || (conn->getConnectionState() != NetConnection::AwaitingChallengeResponse &&
  325. conn->getConnectionState() != NetConnection::AwaitingConnectResponse))
  326. return;
  327. removePendingConnection(conn);
  328. char reason[256];
  329. stream->readString(reason);
  330. conn->onConnectionRejected(reason);
  331. conn->deleteObject();
  332. }
  333. void NetInterface::handleDisconnect(const NetAddress *address, BitStream *stream)
  334. {
  335. NetConnection *conn = NetConnection::lookup(address);
  336. if(!conn)
  337. return;
  338. U32 connectSequence;
  339. char reason[256];
  340. stream->read(&connectSequence);
  341. stream->readString(reason);
  342. if(conn->getSequence() != connectSequence)
  343. return;
  344. conn->onDisconnect(reason);
  345. conn->deleteObject();
  346. }
  347. void NetInterface::handleInfoPacket(const NetAddress *address, U8 packetType, BitStream *stream)
  348. {
  349. }
  350. void NetInterface::processClient()
  351. {
  352. NetObject::collapseDirtyList(); // collapse all the mask bits...
  353. for(NetConnection *walk = NetConnection::getConnectionList();
  354. walk; walk = walk->getNext())
  355. {
  356. if(walk->isConnectionToServer() && (walk->isLocalConnection() || walk->isNetworkConnection()))
  357. walk->checkPacketSend(false);
  358. }
  359. }
  360. void NetInterface::processServer()
  361. {
  362. NetObject::collapseDirtyList(); // collapse all the mask bits...
  363. for(NetConnection *walk = NetConnection::getConnectionList();
  364. walk; walk = walk->getNext())
  365. {
  366. if(!walk->isConnectionToServer() && (walk->isLocalConnection() || walk->isNetworkConnection()))
  367. walk->checkPacketSend(false);
  368. }
  369. }
  370. void NetInterface::startConnection(NetConnection *conn)
  371. {
  372. addPendingConnection(conn);
  373. conn->mConnectionSendCount = 0;
  374. conn->setConnectSequence(Platform::getVirtualMilliseconds());
  375. conn->setConnectionState(NetConnection::AwaitingChallengeResponse);
  376. // This is a the client side of the connection, so set the connection to
  377. // server flag. We need to set this early so that if the connection times
  378. // out, its onRemove() will handle the cleanup properly.
  379. conn->setIsConnectionToServer();
  380. // Everything set, so send off the request.
  381. sendConnectChallengeRequest(conn);
  382. }
  383. void NetInterface::sendDisconnectPacket(NetConnection *conn, const char *reason)
  384. {
  385. Con::printf("Issuing Disconnect packet.");
  386. // send a disconnect packet...
  387. U32 connectSequence = conn->getSequence();
  388. BitStream *out = BitStream::getPacketStream();
  389. out->write(U8(Disconnect));
  390. out->write(connectSequence);
  391. out->writeString(reason);
  392. BitStream::sendPacketStream(conn->getNetAddress());
  393. }
  394. void NetInterface::checkTimeouts()
  395. {
  396. U32 time = Platform::getVirtualMilliseconds();
  397. if(time > mLastTimeoutCheckTime + TimeoutCheckInterval)
  398. {
  399. for(U32 i = 0; i < (U32)mPendingConnections.size();)
  400. {
  401. NetConnection *pending = mPendingConnections[i];
  402. if(pending->getConnectionState() == NetConnection::AwaitingChallengeResponse &&
  403. time > pending->mConnectLastSendTime + ChallengeRetryTime)
  404. {
  405. if(pending->mConnectSendCount > ChallengeRetryCount)
  406. {
  407. pending->onConnectTimedOut();
  408. removePendingConnection(pending);
  409. pending->deleteObject();
  410. continue;
  411. }
  412. else
  413. sendConnectChallengeRequest(pending);
  414. }
  415. else if(pending->getConnectionState() == NetConnection::AwaitingConnectResponse &&
  416. time > pending->mConnectLastSendTime + ConnectRetryTime)
  417. {
  418. if(pending->mConnectSendCount > ConnectRetryCount)
  419. {
  420. pending->onConnectTimedOut();
  421. removePendingConnection(pending);
  422. pending->deleteObject();
  423. continue;
  424. }
  425. else
  426. sendConnectRequest(pending);
  427. }
  428. i++;
  429. }
  430. mLastTimeoutCheckTime = time;
  431. NetConnection *walk = NetConnection::getConnectionList();
  432. while(walk)
  433. {
  434. NetConnection *next = walk->getNext();
  435. if(walk->checkTimeout(time))
  436. {
  437. // this baddie timed out
  438. walk->onTimedOut();
  439. walk->deleteObject();
  440. }
  441. walk = next;
  442. }
  443. }
  444. }
  445. #define F1(x, y, z) (z ^ (x & (y ^ z)))
  446. #define F2(x, y, z) F1(z, x, y)
  447. #define F3(x, y, z) (x ^ y ^ z)
  448. #define F4(x, y, z) (y ^ (x | ~z))
  449. inline U32 rotlFixed(U32 x, unsigned int y)
  450. {
  451. return (x >> y) | (x << (32 - y));
  452. }
  453. #define MD5STEP(f, w, x, y, z, data, s) w = rotlFixed(w + f(x, y, z) + data, s) + x
  454. void NetInterface::computeNetMD5(const NetAddress *address, U32 connectSequence, U32 digest[4])
  455. {
  456. digest[0] = 0x67452301L;
  457. digest[1] = 0xefcdab89L;
  458. digest[2] = 0x98badcfeL;
  459. digest[3] = 0x10325476L;
  460. U32 a, b, c, d;
  461. a=digest[0];
  462. b=digest[1];
  463. c=digest[2];
  464. d=digest[3];
  465. U32 in[16];
  466. in[0] = address->type;
  467. in[1] = (U32(address->netNum[0]) << 24) |
  468. (U32(address->netNum[1]) << 16) |
  469. (U32(address->netNum[2]) << 8) |
  470. (U32(address->netNum[3]));
  471. in[2] = address->port;
  472. in[3] = connectSequence;
  473. for(U32 i = 0; i < 12; i++)
  474. in[i + 4] = mRandomHashData[i];
  475. MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
  476. MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
  477. MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
  478. MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
  479. MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
  480. MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
  481. MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
  482. MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
  483. MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
  484. MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
  485. MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
  486. MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
  487. MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
  488. MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
  489. MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
  490. MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
  491. MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
  492. MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
  493. MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
  494. MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
  495. MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
  496. MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
  497. MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
  498. MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
  499. MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
  500. MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
  501. MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
  502. MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
  503. MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
  504. MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
  505. MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
  506. MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
  507. MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
  508. MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
  509. MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
  510. MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
  511. MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
  512. MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
  513. MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
  514. MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
  515. MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
  516. MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
  517. MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
  518. MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
  519. MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
  520. MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
  521. MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
  522. MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
  523. MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
  524. MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
  525. MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
  526. MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
  527. MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
  528. MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
  529. MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
  530. MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
  531. MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
  532. MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
  533. MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
  534. MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
  535. MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
  536. MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
  537. MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
  538. MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
  539. digest[0]+=a;
  540. digest[1]+=b;
  541. digest[2]+=c;
  542. digest[3]+=d;
  543. }
  544. ConsoleFunctionGroupBegin(NetInterface, "Global control functions for the netInterfaces.");
  545. ConsoleFunction(allowConnections,void,2,2,"( enable ) Use the allowConnections to enable (or disable) remote connections to the local game server.\n"
  546. "@param enable A boolean value enabling, or disabling connections to the local server.\n"
  547. "@return No return value")
  548. {
  549. GNet->setAllowsConnections(dAtob(argv[1]));
  550. }
  551. ConsoleFunctionGroupEnd(NetInterface);