Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: net/socket/web_socket_server_socket.cc

Issue 9716020: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/web_socket_server_socket.h" 5 #include "net/socket/web_socket_server_socket.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 int spaces1 = CountSpaces(fields.Get(kKey1FieldName)); 682 int spaces1 = CountSpaces(fields.Get(kKey1FieldName));
683 int spaces2 = CountSpaces(fields.Get(kKey2FieldName)); 683 int spaces2 = CountSpaces(fields.Get(kKey2FieldName));
684 if (spaces1 == 0 || 684 if (spaces1 == 0 ||
685 spaces2 == 0 || 685 spaces2 == 0 ||
686 key_number1 % spaces1 != 0 || 686 key_number1 % spaces1 != 0 ||
687 key_number2 % spaces2 != 0) { 687 key_number2 % spaces2 != 0) {
688 return net::ERR_WS_PROTOCOL_ERROR; 688 return net::ERR_WS_PROTOCOL_ERROR;
689 } 689 }
690 690
691 char challenge[4 + 4 + sizeof(key3)]; 691 char challenge[4 + 4 + sizeof(key3)];
692 int32 part1 = htonl(key_number1 / spaces1); 692 int32 part1 = base::HostToNet32(key_number1 / spaces1);
693 int32 part2 = htonl(key_number2 / spaces2); 693 int32 part2 = base::HostToNet32(key_number2 / spaces2);
694 memcpy(challenge, &part1, 4); 694 memcpy(challenge, &part1, 4);
695 memcpy(challenge + 4, &part2, 4); 695 memcpy(challenge + 4, &part2, 4);
696 memcpy(challenge + 4 + 4, key3, sizeof(key3)); 696 memcpy(challenge + 4 + 4, key3, sizeof(key3));
697 base::MD5Digest challenge_response; 697 base::MD5Digest challenge_response;
698 base::MD5Sum(challenge, sizeof(challenge), &challenge_response); 698 base::MD5Sum(challenge, sizeof(challenge), &challenge_response);
699 699
700 // Concocting response handshake. 700 // Concocting response handshake.
701 class Buffer { 701 class Buffer {
702 public: 702 public:
703 Buffer() 703 Buffer()
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 887
888 WebSocketServerSocket* CreateWebSocketServerSocket( 888 WebSocketServerSocket* CreateWebSocketServerSocket(
889 Socket* transport_socket, WebSocketServerSocket::Delegate* delegate) { 889 Socket* transport_socket, WebSocketServerSocket::Delegate* delegate) {
890 return new WebSocketServerSocketImpl(transport_socket, delegate); 890 return new WebSocketServerSocketImpl(transport_socket, delegate);
891 } 891 }
892 892
893 WebSocketServerSocket::~WebSocketServerSocket() { 893 WebSocketServerSocket::~WebSocketServerSocket() {
894 } 894 }
895 895
896 } // namespace net; 896 } // namespace net;
OLDNEW
« no previous file with comments | « net/socket/socks_client_socket.cc ('k') | ppapi/shared_impl/private/net_address_private_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698