blob: b1662f758c67f064c640bd03f2f22c18c148f24b [file] [log] [blame]
Darin Petkov633ac6f2011-07-08 13:56:13 -07001// 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 Petkove0a312e2011-07-20 13:45:28 -07005#include <sys/ioctl.h>
Darin Petkov633ac6f2011-07-08 13:56:13 -07006#include <sys/socket.h>
7#include <unistd.h>
8
9#include "shill/sockets.h"
10
11namespace shill {
12
13Sockets::~Sockets() {}
14
15int Sockets::Bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
16 return bind(sockfd, addr, addrlen);
17}
18
19int Sockets::Close(int fd) {
20 return close(fd);
21}
22
Darin Petkove0a312e2011-07-20 13:45:28 -070023int Sockets::Ioctl(int d, int request, void *argp) {
24 return ioctl(d, request, argp);
25}
26
Darin Petkov633ac6f2011-07-08 13:56:13 -070027ssize_t Sockets::Send(int sockfd, const void *buf, size_t len, int flags) {
28 return send(sockfd, buf, len, flags);
29}
30
31ssize_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
36int Sockets::Socket(int domain, int type, int protocol) {
37 return socket(domain, type, protocol);
38}
39
Darin Petkove0a312e2011-07-20 13:45:28 -070040ScopedSocketCloser::ScopedSocketCloser(Sockets *sockets, int fd)
41 : sockets_(sockets),
42 fd_(fd) {}
43
44ScopedSocketCloser::~ScopedSocketCloser() {
45 sockets_->Close(fd_);
46 fd_ = -1;
47}
48
Darin Petkov633ac6f2011-07-08 13:56:13 -070049} // namespace shill