BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /**
2 * @file DPRelay.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  
30 #ifndef BADVPN_CLIENT_DPRELAY_H
31 #define BADVPN_CLIENT_DPRELAY_H
32  
33 #include <stdint.h>
34 #include <limits.h>
35  
36 #include <protocol/scproto.h>
37 #include <protocol/dataproto.h>
38 #include <misc/debug.h>
39 #include <structure/LinkedList1.h>
40 #include <base/DebugObject.h>
41 #include <flow/BufferWriter.h>
42 #include <client/DataProto.h>
43  
44 struct DPRelay_flow;
45  
46 typedef struct {
47 int frame_mtu;
48 BufferWriter writer;
49 DataProtoSource dp_source;
50 struct DPRelay_flow *current_flow;
51 DebugObject d_obj;
52 DebugCounter d_ctr;
53 } DPRelayRouter;
54  
55 typedef struct {
56 DPRelayRouter *router;
57 peerid_t source_id;
58 LinkedList1 flows_list;
59 DebugObject d_obj;
60 } DPRelaySource;
61  
62 typedef struct {
63 peerid_t dest_id;
64 LinkedList1 flows_list;
65 DataProtoSink *dp_sink;
66 DebugObject d_obj;
67 } DPRelaySink;
68  
69 struct DPRelay_flow {
70 DPRelaySource *src;
71 DPRelaySink *sink;
72 DataProtoFlow dp_flow;
73 LinkedList1Node src_list_node;
74 LinkedList1Node sink_list_node;
75 };
76  
77 int DPRelayRouter_Init (DPRelayRouter *o, int frame_mtu, BReactor *reactor) WARN_UNUSED;
78 void DPRelayRouter_Free (DPRelayRouter *o);
79 void DPRelayRouter_SubmitFrame (DPRelayRouter *o, DPRelaySource *src, DPRelaySink *sink, uint8_t *data, int data_len, int num_packets, int inactivity_time);
80  
81 void DPRelaySource_Init (DPRelaySource *o, DPRelayRouter *router, peerid_t source_id, BReactor *reactor);
82 void DPRelaySource_Free (DPRelaySource *o);
83  
84 void DPRelaySink_Init (DPRelaySink *o, peerid_t dest_id);
85 void DPRelaySink_Free (DPRelaySink *o);
86 void DPRelaySink_Attach (DPRelaySink *o, DataProtoSink *dp_sink);
87 void DPRelaySink_Detach (DPRelaySink *o);
88  
89 #endif