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-2008 Telethra, 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
;
64 unsigned int capacity
;
65 unsigned int max_queued
;
66 struct mbuf_item
*array
;
69 struct mbuf_set
*mbuf_init (unsigned int size
);
70 void mbuf_free (struct mbuf_set
*ms
);
72 struct mbuf_buffer
*mbuf_alloc_buf (const struct buffer
*buf
);
73 void mbuf_free_buf (struct mbuf_buffer
*mb
);
75 void mbuf_add_item (struct mbuf_set
*ms
, const struct mbuf_item
*item
);
77 bool mbuf_extract_item (struct mbuf_set
*ms
, struct mbuf_item
*item
, const bool lock
);
79 void mbuf_dereference_instance (struct mbuf_set
*ms
, struct multi_instance
*mi
);
82 mbuf_defined (const struct mbuf_set
*ms
)
88 mbuf_len (const struct mbuf_set
*ms
)
94 mbuf_maximum_queued (const struct mbuf_set
*ms
)
96 return (int) ms
->max_queued
;
99 static inline struct multi_instance
*
100 mbuf_peek (struct mbuf_set
*ms
)
102 struct multi_instance
*mbuf_peek_dowork (struct mbuf_set
*ms
);
103 if (mbuf_defined (ms
))
104 return mbuf_peek_dowork (ms
);