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 | |
| 5 | #ifndef SHILL_SOCKETS_H_ |
| 6 | #define SHILL_SOCKETS_H_ |
| 7 | |
| 8 | #include <sys/types.h> |
| 9 | |
| 10 | namespace shill { |
| 11 | |
| 12 | // A "sys/socket.h" abstraction allowing mocking in tests. |
| 13 | class Sockets { |
| 14 | public: |
| 15 | virtual ~Sockets(); |
| 16 | |
| 17 | // bind |
| 18 | virtual int Bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); |
| 19 | |
| 20 | // close |
| 21 | virtual int Close(int fd); |
| 22 | |
| 23 | // send |
| 24 | virtual ssize_t Send(int sockfd, const void *buf, size_t len, int flags); |
| 25 | |
| 26 | // sendto |
| 27 | virtual ssize_t SendTo(int sockfd, const void *buf, size_t len, int flags, |
| 28 | const struct sockaddr *dest_addr, socklen_t addrlen); |
| 29 | |
| 30 | // socket |
| 31 | virtual int Socket(int domain, int type, int protocol); |
| 32 | }; |
| 33 | |
| 34 | } // namespace shill |
| 35 | |
| 36 | #endif // SHILL_SOCKETS_H_ |