xref: /freebsd/sys/dev/wtap/if_medium.h (revision 2008043f386721d58158e37e0d7e50df8095942d)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2010-2011 Monthadar Al Jaberi, TerraNet AB
5  * All rights reserved.
6  *
7  * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer,
15  *    without modification.
16  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
17  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
18  *    redistribution must be conditioned upon including a substantially
19  *    similar Disclaimer requirement for further binary redistribution.
20  *
21  * NO WARRANTY
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
25  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
26  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
27  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32  * THE POSSIBILITY OF SUCH DAMAGES.
33  */
34 
35 #ifndef	__DEV_WTAP_MEDIUM_H__
36 #define	__DEV_WTAP_MEDIUM_H__
37 
38 #include "if_wtapvar.h"
39 #include "wtap_hal/handler.h"
40 
41 struct packet {
42 	STAILQ_ENTRY(packet)	pf_list;
43 	struct mbuf *		m;
44 	int			id;
45 };
46 typedef STAILQ_HEAD(, packet) md_pkthead;
47 
48 struct wtap_medium {
49 	struct mtx 			md_mtx;
50 #if 0
51 	int				visibility[MAX_NBR_WTAP];
52 	struct stailhead 		*headp;
53 	packet_head			pktbuf;
54 	STAILQ_HEAD(stailhead, packet) pktbuf;
55 	STAILQ_HEAD(stailhead, packet) pktbuf;
56 	/* = STAILQ_HEAD_INITIALIZER(head); */
57 #endif
58 	/* 0 means we drop packets, 1 we queue them */
59 	int				open;
60 	md_pkthead			md_pktbuf;	/* master queue */
61 	struct eventhandler		*tx_handler;
62 	struct timehandler		*bc_handler;
63 };
64 
65 extern	void init_medium(struct wtap_medium *);
66 extern	void deinit_medium(struct wtap_medium *);
67 extern	void medium_open(struct wtap_medium *);
68 extern	void medium_close(struct wtap_medium *);
69 extern	int medium_transmit(struct wtap_medium *, int id, struct mbuf*);
70 extern	struct packet *medium_get_next_packet(struct wtap_medium *);
71 
72 #endif	/* __DEV_WTAP_MEDIUM_H__ */
73