1 // Copyright 2017 The Fuchsia 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 #pragma once 6 7 #include <lib/zxs/zxs.h> 8 #include <zircon/compiler.h> 9 10 #include "private.h" 11 12 __BEGIN_CDECLS 13 14 // Flags for zxsio.flags 15 16 // Set if listen() was called for this socket. 17 #define ZXSIO_DID_LISTEN (1<<0) 18 19 typedef struct zxsio zxsio_t; 20 21 struct zxsio { 22 // base fdio io object 23 fdio_t io; 24 25 // The underlying |zxs_socket_t|. 26 // 27 // The Zircon socket is contained in this structure. 28 zxs_socket_t s; 29 30 // see ZXSIO flags above 31 uint32_t flags; 32 }; 33 34 // Returns a pointer to the |zxs_socket_t| inside the given |fd|, if such a 35 // struct exists. 36 // 37 // Caller receives a reference to the |fdio_t|. The caller is responsible for 38 // calling fdio_release to balance the reference count. 39 // 40 // Returns |NULL| if no |zxs_socket_t| was found. 41 fdio_t* fd_to_socket(int fd, const zxs_socket_t** out_socket); 42 43 __END_CDECLS 44