OpenVPN: Update to version 2.3.2. Solves TLS security bug.
[tomato.git] / release / src / router / openvpn / src / openvpn / mbuf.h
blob1085adc7c01849cbb46a5b35bc33c5b53d5b5ad3
1 /*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
8 * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program (see the file COPYING included with this
21 * distribution); if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef MBUF_H
26 #define MBUF_H
29 * Handle both multicast and broadcast functions.
32 #if P2MP
34 /* define this to enable special test mode */
35 /*#define MBUF_TEST*/
37 #include "basic.h"
38 #include "buffer.h"
40 struct multi_instance;
42 #define MBUF_INDEX(head, offset, size) (((head) + (offset)) & ((size)-1))
44 struct mbuf_buffer
46 struct buffer buf;
47 int refcount;
49 # define MF_UNICAST (1<<0)
50 unsigned int flags;
53 struct mbuf_item
55 struct mbuf_buffer *buffer;
56 struct multi_instance *instance;
59 struct mbuf_set
61 unsigned int head;
62 unsigned int len;
63 unsigned int capacity;
64 unsigned int max_queued;
65 struct mbuf_item *array;
68 struct mbuf_set *mbuf_init (unsigned int size);
69 void mbuf_free (struct mbuf_set *ms);
71 struct mbuf_buffer *mbuf_alloc_buf (const struct buffer *buf);
72 void mbuf_free_buf (struct mbuf_buffer *mb);
74 void mbuf_add_item (struct mbuf_set *ms, const struct mbuf_item *item);
76 bool mbuf_extract_item (struct mbuf_set *ms, struct mbuf_item *item);
78 void mbuf_dereference_instance (struct mbuf_set *ms, struct multi_instance *mi);
80 static inline bool
81 mbuf_defined (const struct mbuf_set *ms)
83 return ms && ms->len;
86 static inline unsigned int
87 mbuf_len (const struct mbuf_set *ms)
89 return ms->len;
92 static inline int
93 mbuf_maximum_queued (const struct mbuf_set *ms)
95 return (int) ms->max_queued;
98 static inline struct multi_instance *
99 mbuf_peek (struct mbuf_set *ms)
101 struct multi_instance *mbuf_peek_dowork (struct mbuf_set *ms);
102 if (mbuf_defined (ms))
103 return mbuf_peek_dowork (ms);
104 else
105 return NULL;
108 #endif
109 #endif