summaryrefslogtreecommitdiff
path: root/libcutils/socket_local_unix.h
diff options
context:
space:
mode:
authorDavid Pursell <dpursell@google.com>2016-01-14 17:18:27 -0800
committerDavid Pursell <dpursell@google.com>2016-01-15 15:57:35 -0800
commit0eb8e1b706b577194bab1e23fab5b7d20d5259f1 (patch)
tree13640449bbfe882904ab3342bcf43b1a02e70cc9 /libcutils/socket_local_unix.h
parent047597b3fc345ee657ff1f00ad87521cf4ae455f (diff)
libcutils: share Windows networking code.
This CL moves Windows networking code from fastboot to libcutils so that it can be shared with other host programs such as adb. Not all libcutils networking functions have been implemented for Windows, just those necessary for fastboot. In the next CL I will do the same for adb, adding any additional required functions. Unit tests have also been added to test the functions using a loopback connection. Bug: http://b/26236380. Change-Id: Ibc51a67030fe69a04c23512eefa9d19b055c7c12
Diffstat (limited to 'libcutils/socket_local_unix.h')
-rw-r--r--libcutils/socket_local_unix.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/libcutils/socket_local_unix.h b/libcutils/socket_local_unix.h
new file mode 100644
index 000000000..45b9856b6
--- /dev/null
+++ b/libcutils/socket_local_unix.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SOCKET_LOCAL_H
+#define __SOCKET_LOCAL_H
+
+#define FILESYSTEM_SOCKET_PREFIX "/tmp/"
+#define ANDROID_RESERVED_SOCKET_PREFIX "/dev/socket/"
+
+/*
+ * Set up a given sockaddr_un, to have it refer to the given
+ * name in the given namespace. The namespace must be one
+ * of <code>ANDROID_SOCKET_NAMESPACE_ABSTRACT</code>,
+ * <code>ANDROID_SOCKET_NAMESPACE_RESERVED</code>, or
+ * <code>ANDROID_SOCKET_NAMESPACE_FILESYSTEM</code>. Upon success,
+ * the pointed at sockaddr_un is filled in and the pointed at
+ * socklen_t is set to indicate the final length. This function
+ * will fail if the namespace is invalid (not one of the indicated
+ * constants) or if the name is too long.
+ *
+ * @return 0 on success or -1 on failure
+ */
+int socket_make_sockaddr_un(const char *name, int namespaceId,
+ struct sockaddr_un *p_addr, socklen_t *alen);
+
+#endif