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