"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/dns/include/dns/tcpmsg.h" (7 Sep 2020, 3144 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


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