2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2019 Isilon Systems, LLC.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #ifndef DEBUGNET_INTERNAL
33 #error "Don't include this"
36 #define DNETDEBUG(f, ...) do { \
37 if (debugnet_debug > 0) \
38 printf(("%s: " f), __func__, ## __VA_ARGS__); \
40 #define DNETDEBUG_IF(i, f, ...) do { \
41 if (debugnet_debug > 0) \
42 if_printf((i), ("%s: " f), __func__, ## __VA_ARGS__); \
44 #define DNETDEBUGV(f, ...) do { \
45 if (debugnet_debug > 1) \
46 printf(("%s: " f), __func__, ## __VA_ARGS__); \
52 DN_STATE_GOT_HERALD_PORT,
56 uint64_t dp_rcvd_acks;
63 struct ether_addr dp_gw_mac;
64 uint16_t dp_server_port;
67 /* Saved driver if_input to restore on close. */
68 void (*dp_drv_input)(struct ifnet *, struct mbuf *);
70 enum dnet_pcb_st dp_state;
71 uint16_t dp_client_ack_port;
74 /* TODO(CEM): Obviate this assertion by using a BITSET(9) for acks. */
75 CTASSERT(sizeof(((struct debugnet_pcb *)0)->dp_rcvd_acks) * NBBY >=
76 DEBUGNET_MAX_IN_FLIGHT);
78 extern unsigned debugnet_debug;
79 SYSCTL_DECL(_net_debugnet);
81 int debugnet_ether_output(struct mbuf *, struct ifnet *, struct ether_addr,
83 void debugnet_handle_udp(struct debugnet_pcb *, struct mbuf **);
84 void debugnet_network_poll(struct ifnet *);
87 int debugnet_arp_gw(struct debugnet_pcb *);
88 void debugnet_handle_arp(struct debugnet_pcb *, struct mbuf **);
89 void debugnet_handle_ip(struct debugnet_pcb *, struct mbuf **);
90 int debugnet_ip_output(struct debugnet_pcb *, struct mbuf *);