1/* $OpenBSD: if_pflow.h,v 1.5 2009/02/27 11:09:36 gollo Exp $ */ 2 3/* 4 * Copyright (c) 2008 Henning Brauer <henning@openbsd.org> 5 * Copyright (c) 2008 Joerg Goltermann <jg@osn.de> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN 16 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * 19 * $FreeBSD$ 20 */ 21 22#ifndef _NET_IF_PFLOW_H_ 23#define _NET_IF_PFLOW_H_ 24 25#define PFLOW_ID_LEN sizeof(u_int64_t) 26 27#define PFLOW_MAXFLOWS 30 28#define PFLOW_VERSION 5 29#define PFLOW_ENGINE_TYPE 42 30#define PFLOW_ENGINE_ID 42 31#define PFLOW_MAXBYTES 0xffffffff 32#define PFLOW_TIMEOUT 30 33 34struct pflow_flow { 35 u_int32_t src_ip; 36 u_int32_t dest_ip; 37 u_int32_t nexthop_ip; 38 u_int16_t if_index_in; 39 u_int16_t if_index_out; 40 u_int32_t flow_packets; 41 u_int32_t flow_octets; 42 u_int32_t flow_start; 43 u_int32_t flow_finish; 44 u_int16_t src_port; 45 u_int16_t dest_port; 46 u_int8_t pad1; 47 u_int8_t tcp_flags; 48 u_int8_t protocol; 49 u_int8_t tos; 50 u_int16_t src_as; 51 u_int16_t dest_as; 52 u_int8_t src_mask; 53 u_int8_t dest_mask; 54 u_int16_t pad2; 55} __packed; 56 57#ifdef _KERNEL 58 59extern int pflow_ok; 60 61struct pflow_softc { 62 struct ifnet sc_if; 63 struct ifnet *sc_pflow_ifp; 64 65 unsigned int sc_count; 66 unsigned int sc_maxcount; 67 u_int64_t sc_gcounter; 68 struct ip_moptions sc_imo; 69#ifdef __FreeBSD__ 70 struct callout sc_tmo; 71#else 72 struct timeout sc_tmo; 73#endif 74 struct in_addr sc_sender_ip; 75 u_int16_t sc_sender_port; 76 struct in_addr sc_receiver_ip; 77 u_int16_t sc_receiver_port; 78 struct mbuf *sc_mbuf; /* current cumulative mbuf */ 79 SLIST_ENTRY(pflow_softc) sc_next; 80}; 81 82extern struct pflow_softc *pflowif; 83 84#endif /* _KERNEL */ 85 86struct pflow_header { 87 u_int16_t version; 88 u_int16_t count; 89 u_int32_t uptime_ms; 90 u_int32_t time_sec; 91 u_int32_t time_nanosec; 92 u_int32_t flow_sequence; 93 u_int8_t engine_type; 94 u_int8_t engine_id; 95 u_int8_t reserved1; 96 u_int8_t reserved2; 97} __packed; 98 99#define PFLOW_HDRLEN sizeof(struct pflow_header) 100 101struct pflowstats { 102 u_int64_t pflow_flows; 103 u_int64_t pflow_packets; 104 u_int64_t pflow_onomem; 105 u_int64_t pflow_oerrors; 106}; 107 108/* 109 * Configuration structure for SIOCSETPFLOW SIOCGETPFLOW 110 */ 111struct pflowreq { 112 struct in_addr sender_ip; 113 struct in_addr receiver_ip; 114 u_int16_t receiver_port; 115 u_int16_t addrmask; 116#define PFLOW_MASK_SRCIP 0x01 117#define PFLOW_MASK_DSTIP 0x02 118#define PFLOW_MASK_DSTPRT 0x04 119}; 120 121#ifdef _KERNEL 122int export_pflow(struct pf_state *); 123int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t); 124#endif /* _KERNEL */ 125 126#endif /* _NET_IF_PFLOW_H_ */ 127