diff --git a/system/ulib/zxs/include/lib/zxs/inception.h b/system/ulib/zxs/include/lib/zxs/inception.h deleted file mode 100644 index 4873b11ce2b8f8c7d2b8c53902bb853475d651ab..0000000000000000000000000000000000000000 --- a/system/ulib/zxs/include/lib/zxs/inception.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2018 The Fuchsia Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef LIB_ZXS_INCEPTION_H_ -#define LIB_ZXS_INCEPTION_H_ - -// This header will be removed once all the socket protocol code is refactored -// from fdio to zxs. - -#include <stdint.h> -#include <sys/types.h> -#include <zircon/compiler.h> -#include <zircon/types.h> - -__BEGIN_CDECLS - -#define ZXSIO_PAYLOAD_SZ 900 - -typedef struct zxsio_msg zxsio_msg_t; - -// TODO: most of these fields will end up unused. Figure out which are needed. -// For now, we keep them to preserve the message header format of zxrio_msg -// to make the conversion process easier. -struct zxsio_msg { - zx_txid_t txid; // FIDL message header - uint32_t reserved0; - uint32_t flags; - uint32_t op; - - uint32_t datalen; // size of data[] - int32_t arg; // tx: argument, rx: return value - union { - int64_t off; // tx/rx: offset where needed - uint32_t mode; // tx: Open - uint32_t protocol; // rx: Open - uint32_t op; // tx: Ioctl - } arg2; - int32_t reserved1; - uint32_t hcount; // number of valid handles - zx_handle_t handle[4]; // up to 3 handles + reply channel handle - uint8_t data[ZXSIO_PAYLOAD_SZ]; // payload -}; - -#define ZXSIO_HDR_SZ (__builtin_offsetof(zxsio_msg_t, data)) - -__END_CDECLS - -#endif // LIB_ZXS_INCEPTION_H_ diff --git a/system/ulib/zxs/include/lib/zxs/protocol.h b/system/ulib/zxs/include/lib/zxs/protocol.h index 82d7237379f6041ded4074ea9965879e2f3eaf3b..e34da65e1fee0114ca3079f5357d91758aaf5d01 100644 --- a/system/ulib/zxs/include/lib/zxs/protocol.h +++ b/system/ulib/zxs/include/lib/zxs/protocol.h @@ -14,11 +14,8 @@ __BEGIN_CDECLS -#define ZXSIO_ONE_HANDLE 0x00000100 - // SIO (Socket I/O) #define ZXSIO_CLOSE 0x00000001 -#define ZXSIO_OPEN (0x00000003 | ZXSIO_ONE_HANDLE) #define ZXSIO_IOCTL 0x0000000a #define ZXSIO_CONNECT 0x00000010 #define ZXSIO_BIND 0x00000011 @@ -28,10 +25,7 @@ __BEGIN_CDECLS #define ZXSIO_GETSOCKOPT 0x00000015 #define ZXSIO_SETSOCKOPT 0x00000016 -#define ZXSIO_SOCKET_DIR_NONE "none-v3" -#define ZXSIO_SOCKET_DIR_SOCKET "socket-v3" - -// fdio signals +// SIO signals #define ZXSIO_SIGNAL_INCOMING ZX_USER_SIGNAL_0 #define ZXSIO_SIGNAL_OUTGOING ZX_USER_SIGNAL_1 #define ZXSIO_SIGNAL_ERROR ZX_USER_SIGNAL_2 @@ -54,15 +48,32 @@ typedef struct zxrio_sockopt_req_reply { socklen_t optlen; } zxrio_sockopt_req_reply_t; -// wire format for datagram messages -typedef struct fdio_socket_msg { - struct sockaddr_storage addr; - socklen_t addrlen; - int32_t flags; - char data[1]; // variable size -} fdio_socket_msg_t; +#define ZXSIO_PAYLOAD_SZ 900 + +// TODO: most of these fields will end up unused. Figure out which are needed. +// For now, we keep them to preserve the message header format of zxrio_msg +// to make the conversion process easier. +typedef struct zxsio_msg { + zx_txid_t txid; // FIDL message header + uint32_t reserved0; + uint32_t flags; + uint32_t op; + + uint32_t datalen; // size of data[] + int32_t arg; // tx: argument, rx: return value + union { + int64_t off; // tx/rx: offset where needed + uint32_t mode; // tx: Open + uint32_t protocol; // rx: Open + uint32_t op; // tx: Ioctl + } arg2; + int32_t reserved1; + uint32_t hcount; // number of valid handles + zx_handle_t handle[4]; // up to 3 handles + reply channel handle + uint8_t data[ZXSIO_PAYLOAD_SZ]; // payload +} zxsio_msg_t; -#define FDIO_SOCKET_MSG_HEADER_SIZE offsetof(fdio_socket_msg_t, data) +#define ZXSIO_HDR_SZ (__builtin_offsetof(zxsio_msg_t, data)) __END_CDECLS diff --git a/system/ulib/zxs/zxs.cpp b/system/ulib/zxs/zxs.cpp index c9d8dd91719b34fe5ff83c460be281c0f1900570..0e0135bc24af955753612848bc33f32a15879013 100644 --- a/system/ulib/zxs/zxs.cpp +++ b/system/ulib/zxs/zxs.cpp @@ -4,7 +4,6 @@ #include <fuchsia/net/c/fidl.h> #include <lib/zx/socket.h> -#include <lib/zxs/inception.h> #include <lib/zxs/protocol.h> #include <lib/zxs/zxs.h> #include <stdlib.h> @@ -13,6 +12,16 @@ #include <zircon/device/ioctl.h> #include <zircon/syscalls.h> +// wire format for datagram messages +typedef struct fdio_socket_msg { + struct sockaddr_storage addr; + socklen_t addrlen; + int32_t flags; + char data[1]; // variable size +} fdio_socket_msg_t; + +#define FDIO_SOCKET_MSG_HEADER_SIZE offsetof(fdio_socket_msg_t, data) + static bool is_rio_message_valid(zxsio_msg_t* msg) { if ((msg->datalen > ZXSIO_PAYLOAD_SZ) || (msg->hcount > 0)) { diff --git a/system/utest/zxs/zxs-test.cpp b/system/utest/zxs/zxs-test.cpp index 1b647bffa1d15462477f7c19c80c7f74b71b8525..d6f16ec30d5716097620221f1f0cf7fd15bfd041 100644 --- a/system/utest/zxs/zxs-test.cpp +++ b/system/utest/zxs/zxs-test.cpp @@ -6,7 +6,6 @@ #include <lib/async-loop/loop.h> #include <lib/async/cpp/wait.h> #include <lib/zx/socket.h> -#include <lib/zxs/inception.h> #include <lib/zxs/protocol.h> #include <lib/zxs/zxs.h> #include <string.h> @@ -157,7 +156,6 @@ static zx_status_t handle_message(async_dispatcher_t* dispatcher, memcpy(reply.data, "abcd", reply.datalen); break; } - case ZXSIO_OPEN: default: return ZX_ERR_STOP; }