xref: /freebsd/sys/dev/wtap/if_medium.h (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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  * $FreeBSD$
35  */
36 
37 #ifndef	__DEV_WTAP_MEDIUM_H__
38 #define	__DEV_WTAP_MEDIUM_H__
39 
40 #include "if_wtapvar.h"
41 #include "wtap_hal/handler.h"
42 
43 struct packet {
44 	STAILQ_ENTRY(packet)	pf_list;
45 	struct mbuf *		m;
46 	int			id;
47 };
48 typedef STAILQ_HEAD(, packet) md_pkthead;
49 
50 struct wtap_medium {
51 	struct mtx 			md_mtx;
52 #if 0
53 	int				visibility[MAX_NBR_WTAP];
54 	struct stailhead 		*headp;
55 	packet_head			pktbuf;
56 	STAILQ_HEAD(stailhead, packet) pktbuf;
57 	STAILQ_HEAD(stailhead, packet) pktbuf;
58 	/* = STAILQ_HEAD_INITIALIZER(head); */
59 #endif
60 	/* 0 means we drop packets, 1 we queue them */
61 	int				open;
62 	md_pkthead			md_pktbuf;	/* master queue */
63 	struct eventhandler		*tx_handler;
64 	struct timehandler		*bc_handler;
65 };
66 
67 extern	void init_medium(struct wtap_medium *);
68 extern	void deinit_medium(struct wtap_medium *);
69 extern	void medium_open(struct wtap_medium *);
70 extern	void medium_close(struct wtap_medium *);
71 extern	int medium_transmit(struct wtap_medium *, int id, struct mbuf*);
72 extern	struct packet *medium_get_next_packet(struct wtap_medium *);
73 
74 #endif	/* __DEV_WTAP_MEDIUM_H__ */
75