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
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
29 * Handle both multicast and broadcast functions.
34 /* define this to enable special test mode */
40 struct multi_instance
;
42 #define MBUF_INDEX(head, offset, size) (((head) + (offset)) & ((size)-1))
49 # define MF_UNICAST (1<<0)
55 struct mbuf_buffer
*buffer
;
56 struct multi_instance
*instance
;
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
);
81 mbuf_defined (const struct mbuf_set
*ms
)
86 static inline unsigned int
87 mbuf_len (const struct mbuf_set
*ms
)
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
);