104d19802SAdrian Chadd /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3718cf2ccSPedro F. Giffuni * 404d19802SAdrian Chadd * Copyright (c) 2010-2011 Monthadar Al Jaberi, TerraNet AB 504d19802SAdrian Chadd * All rights reserved. 604d19802SAdrian Chadd * 704d19802SAdrian Chadd * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting 804d19802SAdrian Chadd * All rights reserved. 904d19802SAdrian Chadd * 1004d19802SAdrian Chadd * Redistribution and use in source and binary forms, with or without 1104d19802SAdrian Chadd * modification, are permitted provided that the following conditions 1204d19802SAdrian Chadd * are met: 1304d19802SAdrian Chadd * 1. Redistributions of source code must retain the above copyright 1404d19802SAdrian Chadd * notice, this list of conditions and the following disclaimer, 1504d19802SAdrian Chadd * without modification. 1604d19802SAdrian Chadd * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1704d19802SAdrian Chadd * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 1804d19802SAdrian Chadd * redistribution must be conditioned upon including a substantially 1904d19802SAdrian Chadd * similar Disclaimer requirement for further binary redistribution. 2004d19802SAdrian Chadd * 2104d19802SAdrian Chadd * NO WARRANTY 2204d19802SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2304d19802SAdrian Chadd * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2404d19802SAdrian Chadd * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 2504d19802SAdrian Chadd * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 2604d19802SAdrian Chadd * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 2704d19802SAdrian Chadd * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2804d19802SAdrian Chadd * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2904d19802SAdrian Chadd * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 3004d19802SAdrian Chadd * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3104d19802SAdrian Chadd * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 3204d19802SAdrian Chadd * THE POSSIBILITY OF SUCH DAMAGES. 3304d19802SAdrian Chadd */ 3404d19802SAdrian Chadd 3504d19802SAdrian Chadd #ifndef __DEV_WTAP_MEDIUM_H__ 3604d19802SAdrian Chadd #define __DEV_WTAP_MEDIUM_H__ 3704d19802SAdrian Chadd 3804d19802SAdrian Chadd #include "if_wtapvar.h" 3904d19802SAdrian Chadd #include "wtap_hal/handler.h" 4004d19802SAdrian Chadd 4104d19802SAdrian Chadd struct packet { 4204d19802SAdrian Chadd STAILQ_ENTRY(packet) pf_list; 4304d19802SAdrian Chadd struct mbuf * m; 4404d19802SAdrian Chadd int id; 4504d19802SAdrian Chadd }; 4604d19802SAdrian Chadd typedef STAILQ_HEAD(, packet) md_pkthead; 4704d19802SAdrian Chadd 4804d19802SAdrian Chadd struct wtap_medium { 4904d19802SAdrian Chadd struct mtx md_mtx; 5004d19802SAdrian Chadd #if 0 5104d19802SAdrian Chadd int visibility[MAX_NBR_WTAP]; 5204d19802SAdrian Chadd struct stailhead *headp; 5304d19802SAdrian Chadd packet_head pktbuf; 5404d19802SAdrian Chadd STAILQ_HEAD(stailhead, packet) pktbuf; 5504d19802SAdrian Chadd STAILQ_HEAD(stailhead, packet) pktbuf; 5604d19802SAdrian Chadd /* = STAILQ_HEAD_INITIALIZER(head); */ 5704d19802SAdrian Chadd #endif 5804d19802SAdrian Chadd /* 0 means we drop packets, 1 we queue them */ 5904d19802SAdrian Chadd int open; 6004d19802SAdrian Chadd md_pkthead md_pktbuf; /* master queue */ 6104d19802SAdrian Chadd struct eventhandler *tx_handler; 6204d19802SAdrian Chadd struct timehandler *bc_handler; 6304d19802SAdrian Chadd }; 6404d19802SAdrian Chadd 6504d19802SAdrian Chadd extern void init_medium(struct wtap_medium *); 6604d19802SAdrian Chadd extern void deinit_medium(struct wtap_medium *); 6704d19802SAdrian Chadd extern void medium_open(struct wtap_medium *); 6804d19802SAdrian Chadd extern void medium_close(struct wtap_medium *); 6904d19802SAdrian Chadd extern int medium_transmit(struct wtap_medium *, int id, struct mbuf*); 7004d19802SAdrian Chadd extern struct packet *medium_get_next_packet(struct wtap_medium *); 7104d19802SAdrian Chadd 7204d19802SAdrian Chadd #endif /* __DEV_WTAP_MEDIUM_H__ */ 73