OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * |
| 3 * Copyright 2015-2016, Google Inc. |
| 4 * All rights reserved. |
| 5 * |
| 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are |
| 8 * met: |
| 9 * |
| 10 * * Redistributions of source code must retain the above copyright |
| 11 * notice, this list of conditions and the following disclaimer. |
| 12 * * Redistributions in binary form must reproduce the above |
| 13 * copyright notice, this list of conditions and the following disclaimer |
| 14 * in the documentation and/or other materials provided with the |
| 15 * distribution. |
| 16 * * Neither the name of Google Inc. nor the names of its |
| 17 * contributors may be used to endorse or promote products derived from |
| 18 * this software without specific prior written permission. |
| 19 * |
| 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 * |
| 32 */ |
| 33 |
| 34 #ifndef GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H |
| 35 #define GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H |
| 36 |
| 37 #include "src/core/iomgr/endpoint.h" |
| 38 #include "src/core/iomgr/fd_posix.h" |
| 39 |
| 40 /* Forward decl of grpc_server */ |
| 41 typedef struct grpc_server grpc_server; |
| 42 |
| 43 /* Forward decl of grpc_udp_server */ |
| 44 typedef struct grpc_udp_server grpc_udp_server; |
| 45 |
| 46 /* Called when data is available to read from the socket. */ |
| 47 typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, |
| 48 grpc_server *server); |
| 49 |
| 50 /* Create a server, initially not bound to any ports */ |
| 51 grpc_udp_server *grpc_udp_server_create(void); |
| 52 |
| 53 /* Start listening to bound ports */ |
| 54 void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server, |
| 55 grpc_pollset **pollsets, size_t pollset_count, |
| 56 grpc_server *server); |
| 57 |
| 58 int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index); |
| 59 |
| 60 /* Add a port to the server, returning port number on success, or negative |
| 61 on failure. |
| 62 |
| 63 The :: and 0.0.0.0 wildcard addresses are treated identically, accepting |
| 64 both IPv4 and IPv6 connections, but :: is the preferred style. This usually |
| 65 creates one socket, but possibly two on systems which support IPv6, |
| 66 but not dualstack sockets. */ |
| 67 |
| 68 /* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle |
| 69 all of the multiple socket port matching logic in one place */ |
| 70 int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, |
| 71 size_t addr_len, grpc_udp_server_read_cb read_cb); |
| 72 |
| 73 void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server, |
| 74 grpc_closure *on_done); |
| 75 |
| 76 #endif /* GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H */ |
OLD | NEW |