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

Side by Side Diff: sandbox/sandbox_poc/pocdll/network.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: Switch a few remaining call-sites. Created 8 years, 9 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
« no previous file with comments | « ppapi/shared_impl/private/net_address_private_impl.cc ('k') | sync/util/nigori.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "sandbox/sandbox_poc/pocdll/exports.h" 5 #include "sandbox/sandbox_poc/pocdll/exports.h"
6 #include "sandbox/sandbox_poc/pocdll/utils.h" 6 #include "sandbox/sandbox_poc/pocdll/utils.h"
7 7
8 // This file contains the tests used to verify the security of the network. 8 // This file contains the tests used to verify the security of the network.
9 9
10 void POCDLL_API TestNetworkListen(HANDLE log) { 10 void POCDLL_API TestNetworkListen(HANDLE log) {
(...skipping 17 matching lines...) Expand all
28 ::WSAGetLastError()); 28 ::WSAGetLastError());
29 ::WSACleanup(); 29 ::WSACleanup();
30 return; 30 return;
31 } 31 }
32 32
33 // The sockaddr_in structure specifies the address family, 33 // The sockaddr_in structure specifies the address family,
34 // IP address, and port for the socket that is being bound. 34 // IP address, and port for the socket that is being bound.
35 sockaddr_in service; 35 sockaddr_in service;
36 service.sin_family = AF_INET; 36 service.sin_family = AF_INET;
37 service.sin_addr.s_addr = inet_addr("127.0.0.1"); 37 service.sin_addr.s_addr = inet_addr("127.0.0.1");
38 service.sin_port = htons(88); 38 service.sin_port = base::HostToNet16(88);
rvargas (doing something else) 2012/03/21 18:47:41 I'm on the fence about this particular change. POC
Wez 2012/03/21 20:09:03 Done.
39 39
40 if (bind(listen_socket, reinterpret_cast<SOCKADDR*>(&service), 40 if (bind(listen_socket, reinterpret_cast<SOCKADDR*>(&service),
41 sizeof(service)) == SOCKET_ERROR) { 41 sizeof(service)) == SOCKET_ERROR) {
42 fprintf(output, "[BLOCKED] Bind socket on port 88. Error %ld\r\n", 42 fprintf(output, "[BLOCKED] Bind socket on port 88. Error %ld\r\n",
43 ::WSAGetLastError()); 43 ::WSAGetLastError());
44 closesocket(listen_socket); 44 closesocket(listen_socket);
45 ::WSACleanup(); 45 ::WSACleanup();
46 return; 46 return;
47 } 47 }
48 48
49 // Listen for incoming connection requests 49 // Listen for incoming connection requests
50 // on the created socket 50 // on the created socket
51 if (listen(listen_socket, SOMAXCONN) == SOCKET_ERROR) { 51 if (listen(listen_socket, SOMAXCONN) == SOCKET_ERROR) {
52 fprintf(output, "[BLOCKED] Listen socket on port 88. Error %ld\r\n", 52 fprintf(output, "[BLOCKED] Listen socket on port 88. Error %ld\r\n",
53 ::WSAGetLastError()); 53 ::WSAGetLastError());
54 54
55 } else { 55 } else {
56 fprintf(output, "[GRANTED] Listen socket on port 88.\r\n", 56 fprintf(output, "[GRANTED] Listen socket on port 88.\r\n",
57 ::WSAGetLastError()); 57 ::WSAGetLastError());
58 } 58 }
59 59
60 ::WSACleanup(); 60 ::WSACleanup();
61 return; 61 return;
62 #else // DONT_WANT_INTERCEPTIONS_JUST_WANT_NETWORK 62 #else // DONT_WANT_INTERCEPTIONS_JUST_WANT_NETWORK
63 // Just print out that this test is not running. 63 // Just print out that this test is not running.
64 fprintf(output, "[ERROR] No network tests.\r\n"); 64 fprintf(output, "[ERROR] No network tests.\r\n");
65 #endif // DONT_WANT_INTERCEPTIONS_JUST_WANT_NETWORK 65 #endif // DONT_WANT_INTERCEPTIONS_JUST_WANT_NETWORK
66 } 66 }
OLDNEW
« no previous file with comments | « ppapi/shared_impl/private/net_address_private_impl.cc ('k') | sync/util/nigori.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698