OLD | NEW |
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 if (argc == 5) { | 147 if (argc == 5) { |
148 // V2 proxy | 148 // V2 proxy |
149 CHECK(net::ParseIPLiteralToNumber(argv[2], &remote_ip_number)); | 149 CHECK(net::ParseIPLiteralToNumber(argv[2], &remote_ip_number)); |
150 remote_port = atoi(argv[3]); | 150 remote_port = atoi(argv[3]); |
151 network_type = argv[4]; | 151 network_type = argv[4]; |
152 } else { | 152 } else { |
153 // V1 proxy | 153 // V1 proxy |
154 network_type = argv[2]; | 154 network_type = argv[2]; |
155 } | 155 } |
156 net::IPEndPoint remote_endpoint(remote_ip_number, remote_port); | 156 if (local_port < 0 || local_port > 65535 || remote_port < 0 || |
157 net::IPEndPoint local_endpoint(local_ip_number, local_port); | 157 remote_port > 65535) { |
| 158 fprintf(stderr, "Port numbers must be between 0 and 65535\n"); |
| 159 exit(1); |
| 160 } |
| 161 net::IPEndPoint remote_endpoint(remote_ip_number, |
| 162 static_cast<uint16>(remote_port)); |
| 163 net::IPEndPoint local_endpoint(local_ip_number, |
| 164 static_cast<uint16>(local_port)); |
158 scoped_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe; | 165 scoped_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe; |
159 scoped_ptr<media::cast::test::InterruptedPoissonProcess> ipp( | 166 scoped_ptr<media::cast::test::InterruptedPoissonProcess> ipp( |
160 media::cast::test::DefaultInterruptedPoissonProcess()); | 167 media::cast::test::DefaultInterruptedPoissonProcess()); |
161 | 168 |
162 if (network_type == "perfect") { | 169 if (network_type == "perfect") { |
163 // No action needed. | 170 // No action needed. |
164 } else if (network_type == "wifi") { | 171 } else if (network_type == "wifi") { |
165 in_pipe = media::cast::test::WifiNetwork().Pass(); | 172 in_pipe = media::cast::test::WifiNetwork().Pass(); |
166 out_pipe = media::cast::test::WifiNetwork().Pass(); | 173 out_pipe = media::cast::test::WifiNetwork().Pass(); |
167 } else if (network_type == "bad") { | 174 } else if (network_type == "bad") { |
(...skipping 22 matching lines...) Expand all Loading... |
190 remote_endpoint, | 197 remote_endpoint, |
191 in_pipe.Pass(), | 198 in_pipe.Pass(), |
192 out_pipe.Pass(), | 199 out_pipe.Pass(), |
193 NULL)); | 200 NULL)); |
194 base::MessageLoop message_loop; | 201 base::MessageLoop message_loop; |
195 g_counter.Get().last_printout = base::TimeTicks::Now(); | 202 g_counter.Get().last_printout = base::TimeTicks::Now(); |
196 CheckByteCounters(); | 203 CheckByteCounters(); |
197 message_loop.Run(); | 204 message_loop.Run(); |
198 return 1; | 205 return 1; |
199 } | 206 } |
OLD | NEW |