OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "nacl_io/socket/socket_node.h" | 5 #include "nacl_io/socket/socket_node.h" |
6 | 6 |
7 #include "nacl_io/ossocket.h" | 7 #include "nacl_io/ossocket.h" |
8 #ifdef PROVIDES_SOCKET_API | 8 #ifdef PROVIDES_SOCKET_API |
9 | 9 |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 if (lvl != SOL_SOCKET) | 269 if (lvl != SOL_SOCKET) |
270 return ENOPROTOOPT; | 270 return ENOPROTOOPT; |
271 | 271 |
272 AUTO_LOCK(node_lock_); | 272 AUTO_LOCK(node_lock_); |
273 | 273 |
274 switch (optname) { | 274 switch (optname) { |
275 case SO_REUSEADDR: { | 275 case SO_REUSEADDR: { |
276 // SO_REUSEADDR is effectivly always on since we can't | 276 // SO_REUSEADDR is effectivly always on since we can't |
277 // disable it with PPAPI sockets. Just return success | 277 // disable it with PPAPI sockets. Just return success |
278 // here regardless. | 278 // here regardless. |
279 if (len < sizeof(int)) | 279 if (static_cast<size_t>(len) < sizeof(int)) |
binji
2014/04/02 18:35:53
Might be nicer to do this once at the top of the f
noelallen1
2014/04/03 17:58:52
It's a different type, not size.
| |
280 return EINVAL; | 280 return EINVAL; |
281 return 0; | 281 return 0; |
282 } | 282 } |
283 case SO_LINGER: { | 283 case SO_LINGER: { |
284 // Not supported by the PPAPI interface but we preserve | 284 // Not supported by the PPAPI interface but we preserve |
285 // the settings and pretend to support it. | 285 // the settings and pretend to support it. |
286 if (len < sizeof(struct linger)) | 286 if (static_cast<size_t>(len) < sizeof(struct linger)) |
287 return EINVAL; | 287 return EINVAL; |
288 struct linger new_linger = *static_cast<const linger*>(optval); | 288 struct linger new_linger = *static_cast<const linger*>(optval); |
289 // Don't allow setting linger to be enabled until we | 289 // Don't allow setting linger to be enabled until we |
290 // implement the required synchronous shutdown()/close(). | 290 // implement the required synchronous shutdown()/close(). |
291 // TODO(sbc): remove this after http://crbug.com/312401 | 291 // TODO(sbc): remove this after http://crbug.com/312401 |
292 // gets fixed. | 292 // gets fixed. |
293 if (new_linger.l_onoff != 0) | 293 if (new_linger.l_onoff != 0) |
294 return EINVAL; | 294 return EINVAL; |
295 linger_ = new_linger; | 295 linger_ = new_linger; |
296 return 0; | 296 return 0; |
297 } | 297 } |
298 case SO_KEEPALIVE: { | 298 case SO_KEEPALIVE: { |
299 // Not supported by the PPAPI interface but we preserve | 299 // Not supported by the PPAPI interface but we preserve |
300 // the flag and pretend to support it. | 300 // the flag and pretend to support it. |
301 if (len < sizeof(int)) | 301 if (static_cast<size_t>(len) < sizeof(int)) |
302 return EINVAL; | 302 return EINVAL; |
303 int value = *static_cast<const int*>(optval); | 303 int value = *static_cast<const int*>(optval); |
304 keep_alive_ = value != 0; | 304 keep_alive_ = value != 0; |
305 return 0; | 305 return 0; |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 return ENOPROTOOPT; | 309 return ENOPROTOOPT; |
310 } | 310 } |
311 | 311 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 return 0; | 467 return 0; |
468 } | 468 } |
469 | 469 |
470 *len = ResourceToSockAddr(local_addr_, *len, addr); | 470 *len = ResourceToSockAddr(local_addr_, *len, addr); |
471 return 0; | 471 return 0; |
472 } | 472 } |
473 | 473 |
474 } // namespace nacl_io | 474 } // namespace nacl_io |
475 | 475 |
476 #endif // PROVIDES_SOCKET_API | 476 #endif // PROVIDES_SOCKET_API |
OLD | NEW |