OpenDNSSEC-signer
1.4.5
Main Page
Data Structures
Files
File List
Globals
signer
src
wire
tcpset.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 NLNet Labs. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
*
13
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
*
25
*/
26
32
#ifndef WIRE_TCPSET_H
33
#define WIRE_TCPSET_H
34
35
#include "config.h"
36
#include "
shared/allocator.h
"
37
#include "
wire/buffer.h
"
38
#include "
wire/xfrd.h
"
39
40
#include <stdint.h>
41
42
#define TCPSET_MAX 50
43
48
typedef
struct
tcp_conn_struct
tcp_conn_type
;
49
struct
tcp_conn_struct
{
50
int
fd
;
51
/* how many bytes have been read/written - total, incl. tcp length bytes */
52
uint32_t
total_bytes
;
53
/* msg len bytes */
54
uint16_t
msglen
;
55
/* packet buffer of connection */
56
buffer_type
*
packet
;
57
/* state: reading or writing */
58
unsigned
is_reading
: 1;
59
};
60
61
/*
62
* Set of tcp connections.
63
*
64
*/
65
typedef
struct
tcp_set_struct
tcp_set_type
;
66
struct
tcp_set_struct
{
67
tcp_conn_type
*
tcp_conn
[
TCPSET_MAX
];
68
xfrd_type
*
tcp_waiting_first
;
69
xfrd_type
*
tcp_waiting_last
;
70
size_t
tcp_count
;
71
};
72
79
tcp_conn_type
*
tcp_conn_create
(
allocator_type
* allocator);
80
87
tcp_set_type
*
tcp_set_create
(
allocator_type
* allocator);
88
94
void
tcp_conn_ready
(
tcp_conn_type
* tcp);
95
96
/*
97
* Read from a tcp connection.
98
* On first call, make sure total_bytes = 0, msglen=0, buffer clear,
99
* and the packet and fd need to be set.
100
* \param[in] tcp tcp connection
101
* \return int -1 on error,
102
* 0 on short read,
103
* 1 on completed read.
104
*
105
*/
106
int
tcp_conn_read
(
tcp_conn_type
* tcp);
107
108
/*
109
* Write to a tcp connection.
110
* On first call, make sure total_bytes=0, msglen=limit, buffer filled,
111
* and the packet and fd need to be set.
112
* \param[in] tcp tcp connection
113
* \return int -1 on error,
114
* 0 on short write,
115
* 1 on completed write.
116
*
117
*/
118
int
tcp_conn_write
(
tcp_conn_type
* tcp);
119
126
void
tcp_set_cleanup
(
tcp_set_type
*
set
,
allocator_type
* allocator);
127
128
#endif
/* WIRE_TCPSET_H */
Generated on Tue Jul 22 2014 00:37:52 for OpenDNSSEC-signer by
1.8.1.2