1 /*
2  * Copyright (c) 2018-2021, OARC, Inc.
3  * All rights reserved.
4  *
5  * This file is part of dnsjit.
6  *
7  * dnsjit is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * dnsjit is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with dnsjit.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 //lua:require("dnsjit.core.log")
22 //lua:require("dnsjit.core.receiver_h")
23 //lua:require("dnsjit.core.producer_h")
24 //lua:require("dnsjit.core.object.payload_h")
25 //lua:require("dnsjit.core.timespec_h")
26 
27 typedef struct output_tcpcli {
28     core_log_t _log;
29     size_t     pkts, errs;
30     int        fd;
31 
32     uint8_t               recvbuf[64 * 1024];
33     core_object_payload_t pkt;
34     uint16_t              dnslen;
35     uint8_t               have_dnslen;
36     size_t                recv, pkts_recv;
37 
38     core_timespec_t timeout;
39     int8_t          blocking;
40 } output_tcpcli_t;
41 
42 core_log_t* output_tcpcli_log();
43 
44 void output_tcpcli_init(output_tcpcli_t* self);
45 void output_tcpcli_destroy(output_tcpcli_t* self);
46 int  output_tcpcli_connect(output_tcpcli_t* self, const char* host, const char* port);
47 int  output_tcpcli_nonblocking(output_tcpcli_t* self);
48 int  output_tcpcli_set_nonblocking(output_tcpcli_t* self, int nonblocking);
49 
50 core_receiver_t output_tcpcli_receiver(output_tcpcli_t* self);
51 core_producer_t output_tcpcli_producer(output_tcpcli_t* self);
52