OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ |
| 6 #define IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <sys/types.h> |
| 10 |
| 11 namespace base { |
| 12 class FilePath; |
| 13 } |
| 14 |
| 15 namespace IPC { |
| 16 |
| 17 // Creates a UNIX-domain socket at |pipe_name| and bind()s it, then listen()s |
| 18 // on it. If successful, |server_listen_fd| will be set to the new file |
| 19 // descriptor, and the function will return true. Otherwise returns false. |
| 20 bool CreateServerUnixDomainSocket(const base::FilePath& pipe_name, |
| 21 int* server_listen_fd); |
| 22 |
| 23 // Creates a UNIX-domain socket at |pipe_name| and connect()s to it. If |
| 24 // successful, |client_socket| will be set to the new file descriptor, and |
| 25 // the function will return true. Otherwise returns false. |
| 26 bool CreateClientUnixDomainSocket(const base::FilePath& pipe_name, |
| 27 int* client_socket); |
| 28 |
| 29 // Gets the effective user ID of the other end of the UNIX-domain socket |
| 30 // specified by |fd|. If successful, sets |client_euid| to the uid, and returns |
| 31 // true. Otherwise returns false. |
| 32 bool GetPeerEuid(int fd, uid_t* client_euid); |
| 33 |
| 34 // Accepts a client attempting to connect to |server_listen_fd|, storing the |
| 35 // new file descriptor for the connection in |server_socket| and returning true |
| 36 // if successful. |
| 37 bool ServerAcceptConnection(int server_listen_fd, int* server_socket); |
| 38 |
| 39 // The maximum length of the name of a pipe for MODE_NAMED_SERVER or |
| 40 // MODE_NAMED_CLIENT if you want to pass in your own socket. |
| 41 // The standard size on linux is 108, mac is 104. To maintain consistency |
| 42 // across platforms we standardize on the smaller value. |
| 43 static const size_t kMaxPipeNameLength = 104; |
| 44 |
| 45 } |
| 46 |
| 47 #endif // IPC_UNIX_DOMAIN_SOCKET_UTIL_H_ |
OLD | NEW |