Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 5 | #include <sys/ioctl.h> |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 6 | #include <sys/socket.h> |
| 7 | #include <unistd.h> |
| 8 | |
| 9 | #include "shill/sockets.h" |
| 10 | |
| 11 | namespace shill { |
| 12 | |
| 13 | Sockets::~Sockets() {} |
| 14 | |
| 15 | int Sockets::Bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { |
| 16 | return bind(sockfd, addr, addrlen); |
| 17 | } |
| 18 | |
| 19 | int Sockets::Close(int fd) { |
| 20 | return close(fd); |
| 21 | } |
| 22 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 23 | int Sockets::Ioctl(int d, int request, void *argp) { |
| 24 | return ioctl(d, request, argp); |
| 25 | } |
| 26 | |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 27 | ssize_t Sockets::Send(int sockfd, const void *buf, size_t len, int flags) { |
| 28 | return send(sockfd, buf, len, flags); |
| 29 | } |
| 30 | |
| 31 | ssize_t Sockets::SendTo(int sockfd, const void *buf, size_t len, int flags, |
| 32 | const struct sockaddr *dest_addr, socklen_t addrlen) { |
| 33 | return sendto(sockfd, buf, len, flags, dest_addr, addrlen); |
| 34 | } |
| 35 | |
| 36 | int Sockets::Socket(int domain, int type, int protocol) { |
| 37 | return socket(domain, type, protocol); |
| 38 | } |
| 39 | |
Darin Petkov | e0a312e | 2011-07-20 13:45:28 -0700 | [diff] [blame] | 40 | ScopedSocketCloser::ScopedSocketCloser(Sockets *sockets, int fd) |
| 41 | : sockets_(sockets), |
| 42 | fd_(fd) {} |
| 43 | |
| 44 | ScopedSocketCloser::~ScopedSocketCloser() { |
| 45 | sockets_->Close(fd_); |
| 46 | fd_ = -1; |
| 47 | } |
| 48 | |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 49 | } // namespace shill |