BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /**
2 * @file FragmentProtoDisassembler.h
3 * @author Ambroz Bizjak <ambrop7@gmail.com>
4 *
5 * @section LICENSE
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the
15 * names of its contributors may be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * @section DESCRIPTION
30 *
31 * Object which encodes packets into packets composed of chunks
32 * according to FragmentProto.
33 */
34  
35 #ifndef BADVPN_CLIENT_CCPROTODISASSEMBLER_H
36 #define BADVPN_CLIENT_CCPROTODISASSEMBLER_H
37  
38 #include <stdint.h>
39  
40 #include <protocol/fragmentproto.h>
41 #include <base/DebugObject.h>
42 #include <system/BReactor.h>
43 #include <system/BTime.h>
44 #include <flow/PacketPassInterface.h>
45 #include <flow/PacketRecvInterface.h>
46  
47 /**
48 * Object which encodes packets into packets composed of chunks
49 * according to FragmentProto.
50 *
51 * Input is with {@link PacketPassInterface}.
52 * Output is with {@link PacketRecvInterface}.
53 */
54 typedef struct {
55 BReactor *reactor;
56 int output_mtu;
57 int chunk_mtu;
58 btime_t latency;
59 PacketPassInterface input;
60 PacketRecvInterface output;
61 BTimer timer;
62 int in_len;
63 uint8_t *in;
64 int in_used;
65 uint8_t *out;
66 int out_used;
67 fragmentproto_frameid frame_id;
68 DebugObject d_obj;
69 } FragmentProtoDisassembler;
70  
71 /**
72 * Initializes the object.
73 *
74 * @param o the object
75 * @param reactor reactor we live in
76 * @param input_mtu maximum input packet size. Must be >=0 and <=UINT16_MAX.
77 * @param output_mtu maximum output packet size. Must be >sizeof(struct fragmentproto_chunk_header).
78 * @param chunk_mtu maximum chunk size. Must be >0, or <0 for no explicit limit.
79 * @param latency maximum time a pending output packet with some data can wait for more data
80 * before being sent out. If nonnegative, a timer will be used. If negative,
81 * packets will always be sent out immediately. If low latency is desired,
82 * prefer setting this to zero rather than negative.
83 */
84 void FragmentProtoDisassembler_Init (FragmentProtoDisassembler *o, BReactor *reactor, int input_mtu, int output_mtu, int chunk_mtu, btime_t latency);
85  
86 /**
87 * Frees the object.
88 *
89 * @param o the object
90 */
91 void FragmentProtoDisassembler_Free (FragmentProtoDisassembler *o);
92  
93 /**
94 * Returns the input interface.
95 *
96 * @param o the object
97 * @return input interface
98 */
99 PacketPassInterface * FragmentProtoDisassembler_GetInput (FragmentProtoDisassembler *o);
100  
101 /**
102 * Returns the output interface.
103 *
104 * @param o the object
105 * @return output interface
106 */
107 PacketRecvInterface * FragmentProtoDisassembler_GetOutput (FragmentProtoDisassembler *o);
108  
109 #endif