"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.16.7/lib/dns/include/dns/tcpmsg.h" (4 Sep 2020, 3123 Bytes) of package /linux/misc/dns/bind9/9.16.7/bind-9.16.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "tcpmsg.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #ifndef DNS_TCPMSG_H
   13 #define DNS_TCPMSG_H 1
   14 
   15 /*! \file dns/tcpmsg.h */
   16 
   17 #include <inttypes.h>
   18 
   19 #include <isc/buffer.h>
   20 #include <isc/lang.h>
   21 #include <isc/socket.h>
   22 
   23 typedef struct dns_tcpmsg {
   24     /* private (don't touch!) */
   25     unsigned int     magic;
   26     uint16_t     size;
   27     isc_buffer_t     buffer;
   28     unsigned int     maxsize;
   29     isc_mem_t *  mctx;
   30     isc_socket_t *   sock;
   31     isc_task_t *     task;
   32     isc_taskaction_t action;
   33     void *       arg;
   34     isc_event_t  event;
   35     /* public (read-only) */
   36     isc_result_t   result;
   37     isc_sockaddr_t address;
   38 } dns_tcpmsg_t;
   39 
   40 ISC_LANG_BEGINDECLS
   41 
   42 void
   43 dns_tcpmsg_init(isc_mem_t *mctx, isc_socket_t *sock, dns_tcpmsg_t *tcpmsg);
   44 /*%<
   45  * Associate a tcp message state with a given memory context and
   46  * TCP socket.
   47  *
   48  * Requires:
   49  *
   50  *\li   "mctx" and "sock" be non-NULL and valid types.
   51  *
   52  *\li   "sock" be a read/write TCP socket.
   53  *
   54  *\li   "tcpmsg" be non-NULL and an uninitialized or invalidated structure.
   55  *
   56  * Ensures:
   57  *
   58  *\li   "tcpmsg" is a valid structure.
   59  */
   60 
   61 void
   62 dns_tcpmsg_setmaxsize(dns_tcpmsg_t *tcpmsg, unsigned int maxsize);
   63 /*%<
   64  * Set the maximum packet size to "maxsize"
   65  *
   66  * Requires:
   67  *
   68  *\li   "tcpmsg" be valid.
   69  *
   70  *\li   512 <= "maxsize" <= 65536
   71  */
   72 
   73 isc_result_t
   74 dns_tcpmsg_readmessage(dns_tcpmsg_t *tcpmsg, isc_task_t *task,
   75                isc_taskaction_t action, void *arg);
   76 /*%<
   77  * Schedule an event to be delivered when a DNS message is readable, or
   78  * when an error occurs on the socket.
   79  *
   80  * Requires:
   81  *
   82  *\li   "tcpmsg" be valid.
   83  *
   84  *\li   "task", "taskaction", and "arg" be valid.
   85  *
   86  * Returns:
   87  *
   88  *\li   ISC_R_SUCCESS       -- no error
   89  *\li   Anything that the isc_socket_recv() call can return.  XXXMLG
   90  *
   91  * Notes:
   92  *
   93  *\li   The event delivered is a fully generic event.  It will contain no
   94  *  actual data.  The sender will be a pointer to the dns_tcpmsg_t.
   95  *  The result code inside that structure should be checked to see
   96  *  what the final result was.
   97  */
   98 
   99 void
  100 dns_tcpmsg_cancelread(dns_tcpmsg_t *tcpmsg);
  101 /*%<
  102  * Cancel a readmessage() call.  The event will still be posted with a
  103  * CANCELED result code.
  104  *
  105  * Requires:
  106  *
  107  *\li   "tcpmsg" be valid.
  108  */
  109 
  110 void
  111 dns_tcpmsg_keepbuffer(dns_tcpmsg_t *tcpmsg, isc_buffer_t *buffer);
  112 /*%<
  113  * If a dns buffer is to be kept between calls, this function marks the
  114  * internal state-machine buffer as invalid, and copies all the contents
  115  * of the state into "buffer".
  116  *
  117  * Requires:
  118  *
  119  *\li   "tcpmsg" be valid.
  120  *
  121  *\li   "buffer" be non-NULL.
  122  */
  123 
  124 void
  125 dns_tcpmsg_invalidate(dns_tcpmsg_t *tcpmsg);
  126 /*%<
  127  * Clean up all allocated state, and invalidate the structure.
  128  *
  129  * Requires:
  130  *
  131  *\li   "tcpmsg" be valid.
  132  *
  133  * Ensures:
  134  *
  135  *\li   "tcpmsg" is invalidated and disassociated with all memory contexts,
  136  *  sockets, etc.
  137  */
  138 
  139 ISC_LANG_ENDDECLS
  140 
  141 #endif /* DNS_TCPMSG_H */