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

Side by Side Diff: media/cast/test/utility/udp_proxy_main.cc

Issue 722503002: Use uint16 for port numbers, misc edition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self-review Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <cstdio> 5 #include <cstdio>
6 #include <cstdlib> 6 #include <cstdlib>
7 #include <deque> 7 #include <deque>
8 #include <string> 8 #include <string>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 if (argc == 5) { 138 if (argc == 5) {
139 // V2 proxy 139 // V2 proxy
140 CHECK(net::ParseIPLiteralToNumber(argv[2], &remote_ip_number)); 140 CHECK(net::ParseIPLiteralToNumber(argv[2], &remote_ip_number));
141 remote_port = atoi(argv[3]); 141 remote_port = atoi(argv[3]);
142 network_type = argv[4]; 142 network_type = argv[4];
143 } else { 143 } else {
144 // V1 proxy 144 // V1 proxy
145 network_type = argv[2]; 145 network_type = argv[2];
146 } 146 }
147 net::IPEndPoint remote_endpoint(remote_ip_number, remote_port); 147 if (local_port < 0 || local_port > 65535 || remote_port < 0 ||
148 net::IPEndPoint local_endpoint(local_ip_number, local_port); 148 remote_port > 65535) {
Peter Kasting 2014/11/12 23:53:55 Again, we probably should have done this already.
149 fprintf(stderr, "Port numbers must be between 0 and 65535\n");
150 exit(1);
151 }
152 net::IPEndPoint remote_endpoint(remote_ip_number,
153 static_cast<uint16>(remote_port));
154 net::IPEndPoint local_endpoint(local_ip_number,
155 static_cast<uint16>(local_port));
149 scoped_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe; 156 scoped_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe;
150 157
151 if (network_type == "perfect") { 158 if (network_type == "perfect") {
152 // No action needed. 159 // No action needed.
153 } else if (network_type == "wifi") { 160 } else if (network_type == "wifi") {
154 in_pipe = media::cast::test::WifiNetwork().Pass(); 161 in_pipe = media::cast::test::WifiNetwork().Pass();
155 out_pipe = media::cast::test::WifiNetwork().Pass(); 162 out_pipe = media::cast::test::WifiNetwork().Pass();
156 } else if (network_type == "bad") { 163 } else if (network_type == "bad") {
157 in_pipe = media::cast::test::BadNetwork().Pass(); 164 in_pipe = media::cast::test::BadNetwork().Pass();
158 out_pipe = media::cast::test::BadNetwork().Pass(); 165 out_pipe = media::cast::test::BadNetwork().Pass();
(...skipping 15 matching lines...) Expand all
174 remote_endpoint, 181 remote_endpoint,
175 in_pipe.Pass(), 182 in_pipe.Pass(),
176 out_pipe.Pass(), 183 out_pipe.Pass(),
177 NULL)); 184 NULL));
178 base::MessageLoop message_loop; 185 base::MessageLoop message_loop;
179 last_printout = base::TimeTicks::Now(); 186 last_printout = base::TimeTicks::Now();
180 CheckByteCounters(); 187 CheckByteCounters();
181 message_loop.Run(); 188 message_loop.Run();
182 return 1; 189 return 1;
183 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698