1e5054602SMark Johnston /*- 2e5054602SMark Johnston * Copyright (c) 2005-2014 Sandvine Incorporated 3e5054602SMark Johnston * Copyright (c) 2000 Darrell Anderson <anderson@cs.duke.edu> 4e5054602SMark Johnston * All rights reserved. 5e5054602SMark Johnston * 6e5054602SMark Johnston * Redistribution and use in source and binary forms, with or without 7e5054602SMark Johnston * modification, are permitted provided that the following conditions 8e5054602SMark Johnston * are met: 9e5054602SMark Johnston * 1. Redistributions of source code must retain the above copyright 10e5054602SMark Johnston * notice, this list of conditions and the following disclaimer. 11e5054602SMark Johnston * 2. Redistributions in binary form must reproduce the above copyright 12e5054602SMark Johnston * notice, this list of conditions and the following disclaimer in the 13e5054602SMark Johnston * documentation and/or other materials provided with the distribution. 14e5054602SMark Johnston * 15e5054602SMark Johnston * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16e5054602SMark Johnston * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17e5054602SMark Johnston * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18e5054602SMark Johnston * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19e5054602SMark Johnston * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20e5054602SMark Johnston * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21e5054602SMark Johnston * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22e5054602SMark Johnston * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23e5054602SMark Johnston * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24e5054602SMark Johnston * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25e5054602SMark Johnston * SUCH DAMAGE. 26e5054602SMark Johnston * 27e5054602SMark Johnston * $FreeBSD$ 28e5054602SMark Johnston */ 29e5054602SMark Johnston 30e5054602SMark Johnston #ifndef _NETINET_NETDUMP_H_ 31e5054602SMark Johnston #define _NETINET_NETDUMP_H_ 32e5054602SMark Johnston 33e5054602SMark Johnston #include <sys/types.h> 34e5054602SMark Johnston #include <sys/disk.h> 35e5054602SMark Johnston #include <sys/ioccom.h> 36e5054602SMark Johnston 37e5054602SMark Johnston #include <net/if.h> 38e5054602SMark Johnston #include <netinet/in.h> 39e5054602SMark Johnston 40e5054602SMark Johnston #define NETDUMP_PORT 20023 /* Server UDP port for heralds. */ 41e5054602SMark Johnston #define NETDUMP_ACKPORT 20024 /* Client UDP port for acks. */ 42e5054602SMark Johnston 43e5054602SMark Johnston #define NETDUMP_HERALD 1 /* Broadcast before starting a dump. */ 44e5054602SMark Johnston #define NETDUMP_FINISHED 2 /* Send after finishing a dump. */ 45e5054602SMark Johnston #define NETDUMP_VMCORE 3 /* Contains dump data. */ 46e5054602SMark Johnston #define NETDUMP_KDH 4 /* Contains kernel dump header. */ 47e5054602SMark Johnston #define NETDUMP_EKCD_KEY 5 /* Contains kernel dump key. */ 48e5054602SMark Johnston 49e5054602SMark Johnston #define NETDUMP_DATASIZE 4096 /* Arbitrary packet size limit. */ 50e5054602SMark Johnston 51e5054602SMark Johnston struct netdump_msg_hdr { 52e5054602SMark Johnston uint32_t mh_type; /* Netdump message type. */ 53e5054602SMark Johnston uint32_t mh_seqno; /* Match acks with msgs. */ 54e5054602SMark Johnston uint64_t mh_offset; /* vmcore offset (bytes). */ 55e5054602SMark Johnston uint32_t mh_len; /* Attached data (bytes). */ 56e5054602SMark Johnston uint32_t mh__pad; 57e5054602SMark Johnston } __packed; 58e5054602SMark Johnston 59e5054602SMark Johnston struct netdump_ack { 60e5054602SMark Johnston uint32_t na_seqno; /* Match acks with msgs. */ 61e5054602SMark Johnston } __packed; 62e5054602SMark Johnston 63*6b6e2954SConrad Meyer struct netdump_conf_freebsd12 { 64*6b6e2954SConrad Meyer struct diocskerneldump_arg_freebsd12 ndc12_kda; 65*6b6e2954SConrad Meyer char ndc12_iface[IFNAMSIZ]; 66*6b6e2954SConrad Meyer struct in_addr ndc12_server; 67*6b6e2954SConrad Meyer struct in_addr ndc12_client; 68*6b6e2954SConrad Meyer struct in_addr ndc12_gateway; 69e5054602SMark Johnston }; 70e5054602SMark Johnston 71*6b6e2954SConrad Meyer #define NETDUMPGCONF_FREEBSD12 _IOR('n', 1, struct netdump_conf_freebsd12) 72*6b6e2954SConrad Meyer #define NETDUMPSCONF_FREEBSD12 _IOW('n', 2, struct netdump_conf_freebsd12) 73e5054602SMark Johnston 74*6b6e2954SConrad Meyer #define _PATH_NETDUMP "/dev/netdump" 75e5054602SMark Johnston 76e5054602SMark Johnston #ifdef _KERNEL 77e5054602SMark Johnston #ifdef NETDUMP 78e5054602SMark Johnston 79e5054602SMark Johnston #define NETDUMP_MAX_IN_FLIGHT 64 80e5054602SMark Johnston 81e5054602SMark Johnston enum netdump_ev { 82e5054602SMark Johnston NETDUMP_START, 83e5054602SMark Johnston NETDUMP_END, 84e5054602SMark Johnston }; 85e5054602SMark Johnston 86e5054602SMark Johnston struct ifnet; 87e5054602SMark Johnston struct mbuf; 88e5054602SMark Johnston 89e5054602SMark Johnston void netdump_reinit(struct ifnet *); 90e5054602SMark Johnston 91e5054602SMark Johnston typedef void netdump_init_t(struct ifnet *, int *nrxr, int *ncl, int *clsize); 92e5054602SMark Johnston typedef void netdump_event_t(struct ifnet *, enum netdump_ev); 93e5054602SMark Johnston typedef int netdump_transmit_t(struct ifnet *, struct mbuf *); 94e5054602SMark Johnston typedef int netdump_poll_t(struct ifnet *, int); 95e5054602SMark Johnston 96e5054602SMark Johnston struct netdump_methods { 97e5054602SMark Johnston netdump_init_t *nd_init; 98e5054602SMark Johnston netdump_event_t *nd_event; 99e5054602SMark Johnston netdump_transmit_t *nd_transmit; 100e5054602SMark Johnston netdump_poll_t *nd_poll; 101e5054602SMark Johnston }; 102e5054602SMark Johnston 103e5054602SMark Johnston #define NETDUMP_DEFINE(driver) \ 104e5054602SMark Johnston static netdump_init_t driver##_netdump_init; \ 105e5054602SMark Johnston static netdump_event_t driver##_netdump_event; \ 106e5054602SMark Johnston static netdump_transmit_t driver##_netdump_transmit; \ 107e5054602SMark Johnston static netdump_poll_t driver##_netdump_poll; \ 108e5054602SMark Johnston \ 109e5054602SMark Johnston static struct netdump_methods driver##_netdump_methods = { \ 110e5054602SMark Johnston .nd_init = driver##_netdump_init, \ 111e5054602SMark Johnston .nd_event = driver##_netdump_event, \ 112e5054602SMark Johnston .nd_transmit = driver##_netdump_transmit, \ 113e5054602SMark Johnston .nd_poll = driver##_netdump_poll, \ 114e5054602SMark Johnston } 115e5054602SMark Johnston 116e5054602SMark Johnston #define NETDUMP_REINIT(ifp) netdump_reinit(ifp) 117e5054602SMark Johnston 118e5054602SMark Johnston #define NETDUMP_SET(ifp, driver) \ 119e5054602SMark Johnston (ifp)->if_netdump_methods = &driver##_netdump_methods 120e5054602SMark Johnston 121e5054602SMark Johnston #else /* !NETDUMP */ 122e5054602SMark Johnston 123e5054602SMark Johnston #define NETDUMP_DEFINE(driver) 124e5054602SMark Johnston #define NETDUMP_REINIT(ifp) 125e5054602SMark Johnston #define NETDUMP_SET(ifp, driver) 126e5054602SMark Johnston 127e5054602SMark Johnston #endif /* NETDUMP */ 128e5054602SMark Johnston #endif /* _KERNEL */ 129e5054602SMark Johnston 130e5054602SMark Johnston #endif /* _NETINET_NETDUMP_H_ */ 131