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

Side by Side Diff: content/browser/renderer_host/p2p_socket_host_udp.h

Issue 6800023: Security restrictions for P2P UDP Sockets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_
7 7
8 #include "content/common/p2p_sockets.h" 8 #include <set>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "content/browser/renderer_host/p2p_socket_host.h" 11 #include "content/browser/renderer_host/p2p_socket_host.h"
12 #include "content/common/p2p_sockets.h"
13 #include "net/base/ip_endpoint.h"
12 #include "net/udp/udp_server_socket.h" 14 #include "net/udp/udp_server_socket.h"
13 15
14 class P2PSocketHostUdp : public P2PSocketHost { 16 class P2PSocketHostUdp : public P2PSocketHost {
15 public: 17 public:
16 P2PSocketHostUdp(P2PSocketsHost* host, int routing_id, int id); 18 P2PSocketHostUdp(IPC::Message::Sender* message_sender,
19 int routing_id, int id);
17 virtual ~P2PSocketHostUdp(); 20 virtual ~P2PSocketHostUdp();
18 21
19 // P2PSocketHost overrides. 22 // P2PSocketHost overrides.
20 virtual bool Init(const net::IPEndPoint& local_address) OVERRIDE; 23 virtual bool Init(const net::IPEndPoint& local_address) OVERRIDE;
21 virtual void Send(const net::IPEndPoint& socket_address, 24 virtual void Send(const net::IPEndPoint& to,
22 const std::vector<char>& data) OVERRIDE; 25 const std::vector<char>& data) OVERRIDE;
23 26
24 private: 27 private:
28 friend class P2PSocketHostUdpTest;
29
25 enum State { 30 enum State {
26 STATE_UNINITIALIZED, 31 STATE_UNINITIALIZED,
27 STATE_OPEN, 32 STATE_OPEN,
28 STATE_ERROR, 33 STATE_ERROR,
29 }; 34 };
30 35
36 typedef std::set<net::IPEndPoint> AuthorizedPeerSet;
37
31 void OnError(); 38 void OnError();
32 void DoRead(); 39 void DoRead();
33 void DidCompleteRead(int result); 40 void DidCompleteRead(int result);
34 41
35 // Callbacks for RecvFrom() and SendTo(). 42 // Callbacks for RecvFrom() and SendTo().
36 void OnRecv(int result); 43 void OnRecv(int result);
37 void OnSend(int result); 44 void OnSend(int result);
38 45
39 State state_; 46 State state_;
40 scoped_ptr<net::DatagramServerSocket> socket_; 47 scoped_ptr<net::DatagramServerSocket> socket_;
41 scoped_refptr<net::IOBuffer> recv_buffer_; 48 scoped_refptr<net::IOBuffer> recv_buffer_;
42 net::IPEndPoint recv_address_; 49 net::IPEndPoint recv_address_;
43 bool send_pending_; 50 bool send_pending_;
44 51
52 // Set of peer for which we have received STUN binding request or
53 // response.
54 AuthorizedPeerSet authorized_peers_;
55
45 net::CompletionCallbackImpl<P2PSocketHostUdp> recv_callback_; 56 net::CompletionCallbackImpl<P2PSocketHostUdp> recv_callback_;
46 net::CompletionCallbackImpl<P2PSocketHostUdp> send_callback_; 57 net::CompletionCallbackImpl<P2PSocketHostUdp> send_callback_;
47 58
48 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostUdp); 59 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostUdp);
49 }; 60 };
50 61
51 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ 62 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/p2p_socket_host.cc ('k') | content/browser/renderer_host/p2p_socket_host_udp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698