2 * Copyright (c) 2005-2014 Sandvine Incorporated
3 * Copyright (c) 2000 Darrell Anderson <anderson@cs.duke.edu>
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
30 #ifndef _NETINET_NETDUMP_H_
31 #define _NETINET_NETDUMP_H_
33 #include <sys/types.h>
35 #include <sys/ioccom.h>
38 #include <netinet/in.h>
40 #define NETDUMP_PORT 20023 /* Server UDP port for heralds. */
41 #define NETDUMP_ACKPORT 20024 /* Client UDP port for acks. */
43 #define NETDUMP_HERALD 1 /* Broadcast before starting a dump. */
44 #define NETDUMP_FINISHED 2 /* Send after finishing a dump. */
45 #define NETDUMP_VMCORE 3 /* Contains dump data. */
46 #define NETDUMP_KDH 4 /* Contains kernel dump header. */
47 #define NETDUMP_EKCD_KEY 5 /* Contains kernel dump key. */
49 #define NETDUMP_DATASIZE 4096 /* Arbitrary packet size limit. */
51 struct netdump_msg_hdr {
52 uint32_t mh_type; /* Netdump message type. */
53 uint32_t mh_seqno; /* Match acks with msgs. */
54 uint64_t mh_offset; /* vmcore offset (bytes). */
55 uint32_t mh_len; /* Attached data (bytes). */
60 uint32_t na_seqno; /* Match acks with msgs. */
63 struct netdump_conf_freebsd12 {
64 struct diocskerneldump_arg_freebsd12 ndc12_kda;
65 char ndc12_iface[IFNAMSIZ];
66 struct in_addr ndc12_server;
67 struct in_addr ndc12_client;
68 struct in_addr ndc12_gateway;
71 #define NETDUMPGCONF_FREEBSD12 _IOR('n', 1, struct netdump_conf_freebsd12)
72 #define NETDUMPSCONF_FREEBSD12 _IOW('n', 2, struct netdump_conf_freebsd12)
74 #define _PATH_NETDUMP "/dev/netdump"
79 #define NETDUMP_MAX_IN_FLIGHT 64
89 void netdump_reinit(struct ifnet *);
91 typedef void netdump_init_t(struct ifnet *, int *nrxr, int *ncl, int *clsize);
92 typedef void netdump_event_t(struct ifnet *, enum netdump_ev);
93 typedef int netdump_transmit_t(struct ifnet *, struct mbuf *);
94 typedef int netdump_poll_t(struct ifnet *, int);
96 struct netdump_methods {
97 netdump_init_t *nd_init;
98 netdump_event_t *nd_event;
99 netdump_transmit_t *nd_transmit;
100 netdump_poll_t *nd_poll;
103 #define NETDUMP_DEFINE(driver) \
104 static netdump_init_t driver##_netdump_init; \
105 static netdump_event_t driver##_netdump_event; \
106 static netdump_transmit_t driver##_netdump_transmit; \
107 static netdump_poll_t driver##_netdump_poll; \
109 static struct netdump_methods driver##_netdump_methods = { \
110 .nd_init = driver##_netdump_init, \
111 .nd_event = driver##_netdump_event, \
112 .nd_transmit = driver##_netdump_transmit, \
113 .nd_poll = driver##_netdump_poll, \
116 #define NETDUMP_REINIT(ifp) netdump_reinit(ifp)
118 #define NETDUMP_SET(ifp, driver) \
119 (ifp)->if_netdump_methods = &driver##_netdump_methods
123 #define NETDUMP_DEFINE(driver)
124 #define NETDUMP_REINIT(ifp)
125 #define NETDUMP_SET(ifp, driver)
130 #endif /* _NETINET_NETDUMP_H_ */