1 /*- 2 * Copyright (c) 2005-2014 Sandvine Incorporated 3 * Copyright (c) 2000 Darrell Anderson <anderson@cs.duke.edu> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 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. 14 * 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 25 * SUCH DAMAGE. 26 * 27 * $FreeBSD$ 28 */ 29 30 #ifndef _NETINET_NETDUMP_H_ 31 #define _NETINET_NETDUMP_H_ 32 33 #include <sys/types.h> 34 #include <sys/disk.h> 35 #include <sys/ioccom.h> 36 37 #include <net/if.h> 38 #include <netinet/in.h> 39 40 #define NETDUMP_PORT 20023 /* Server UDP port for heralds. */ 41 #define NETDUMP_ACKPORT 20024 /* Client UDP port for acks. */ 42 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. */ 48 49 #define NETDUMP_DATASIZE 4096 /* Arbitrary packet size limit. */ 50 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). */ 56 uint32_t mh__pad; 57 } __packed; 58 59 struct netdump_ack { 60 uint32_t na_seqno; /* Match acks with msgs. */ 61 } __packed; 62 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; 69 }; 70 71 #define NETDUMPGCONF_FREEBSD12 _IOR('n', 1, struct netdump_conf_freebsd12) 72 #define NETDUMPSCONF_FREEBSD12 _IOW('n', 2, struct netdump_conf_freebsd12) 73 74 #define _PATH_NETDUMP "/dev/netdump" 75 76 #ifdef _KERNEL 77 #ifdef NETDUMP 78 79 #define NETDUMP_MAX_IN_FLIGHT 64 80 81 enum netdump_ev { 82 NETDUMP_START, 83 NETDUMP_END, 84 }; 85 86 struct ifnet; 87 struct mbuf; 88 89 void netdump_reinit(struct ifnet *); 90 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); 95 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; 101 }; 102 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; \ 108 \ 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, \ 114 } 115 116 #define NETDUMP_REINIT(ifp) netdump_reinit(ifp) 117 118 #define NETDUMP_SET(ifp, driver) \ 119 (ifp)->if_netdump_methods = &driver##_netdump_methods 120 121 #else /* !NETDUMP */ 122 123 #define NETDUMP_DEFINE(driver) 124 #define NETDUMP_REINIT(ifp) 125 #define NETDUMP_SET(ifp, driver) 126 127 #endif /* NETDUMP */ 128 #endif /* _KERNEL */ 129 130 #endif /* _NETINET_NETDUMP_H_ */ 131