1 /* 2 * ng_source.h 3 */ 4 5 /*- 6 * Copyright 2002 Sandvine Inc. 7 * All rights reserved. 8 * 9 * Subject to the following obligations and disclaimer of warranty, use and 10 * redistribution of this software, in source or object code forms, with or 11 * without modifications are expressly permitted by Sandvine Inc.; provided, 12 * however, that: 13 * 1. Any and all reproductions of the source or object code must include the 14 * copyright notice above and the following disclaimer of warranties; and 15 * 2. No rights are granted, in any manner or form, to use Sandvine Inc. 16 * trademarks, including the mark "SANDVINE" on advertising, endorsements, 17 * or otherwise except as such appears in the above copyright notice or in 18 * the software. 19 * 20 * THIS SOFTWARE IS BEING PROVIDED BY SANDVINE "AS IS", AND TO THE MAXIMUM 21 * EXTENT PERMITTED BY LAW, SANDVINE MAKES NO REPRESENTATIONS OR WARRANTIES, 22 * EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, 23 * ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 24 * PURPOSE, OR NON-INFRINGEMENT. SANDVINE DOES NOT WARRANT, GUARANTEE, OR 25 * MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE 26 * USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY 27 * OR OTHERWISE. IN NO EVENT SHALL SANDVINE BE LIABLE FOR ANY DAMAGES 28 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 29 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 30 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH 35 * DAMAGE. 36 * 37 * Author: Dave Chapeskie <dchapeskie@sandvine.com> 38 * 39 * $FreeBSD: src/sys/netgraph/ng_source.h,v 1.9 2007/03/02 01:44:04 emaste Exp $ 40 * $DragonFly: src/sys/netgraph7/ng_source.h,v 1.2 2008/06/26 23:05:35 dillon Exp $ 41 */ 42 43 #ifndef _NETGRAPH_NG_SOURCE_H_ 44 #define _NETGRAPH_NG_SOURCE_H_ 45 46 /* Node type name and magic cookie */ 47 #define NG_SOURCE_NODE_TYPE "source" 48 #define NGM_SOURCE_COOKIE 1110646684 49 50 /* Hook names */ 51 #define NG_SOURCE_HOOK_INPUT "input" 52 #define NG_SOURCE_HOOK_OUTPUT "output" 53 54 /* Statistics structure returned by NGM_SOURCE_GET_STATS */ 55 struct ng_source_stats { 56 uint64_t outOctets; 57 uint64_t outFrames; 58 uint32_t queueOctets; 59 uint32_t queueFrames; 60 uint32_t maxPps; 61 struct timeval startTime; 62 struct timeval endTime; 63 struct timeval elapsedTime; 64 struct timeval lastTime; 65 }; 66 67 extern const struct ng_parse_type ng_source_timeval_type; 68 /* Keep this in sync with the above structure definition */ 69 #define NG_SOURCE_STATS_TYPE_INFO { \ 70 { "outOctets", &ng_parse_uint64_type }, \ 71 { "outFrames", &ng_parse_uint64_type }, \ 72 { "queueOctets", &ng_parse_uint32_type }, \ 73 { "queueFrames", &ng_parse_uint32_type }, \ 74 { "maxPps", &ng_parse_uint32_type }, \ 75 { "startTime", &ng_source_timeval_type }, \ 76 { "endTime", &ng_source_timeval_type }, \ 77 { "elapsedTime", &ng_source_timeval_type }, \ 78 { "lastTime", &ng_source_timeval_type }, \ 79 { NULL } \ 80 } 81 82 /* Packet embedding info for NGM_SOURCE_GET/SET_TIMESTAMP */ 83 struct ng_source_embed_info { 84 uint16_t offset; /* offset from ethernet header */ 85 uint8_t flags; 86 uint8_t spare; 87 }; 88 #define NGM_SOURCE_EMBED_ENABLE 0x01 /* enable embedding */ 89 #define NGM_SOURCE_INC_CNT_PER_LIST 0x02 /* increment once per list */ 90 91 /* Keep this in sync with the above structure definition. */ 92 #define NG_SOURCE_EMBED_TYPE_INFO { \ 93 { "offset", &ng_parse_hint16_type }, \ 94 { "flags", &ng_parse_hint8_type }, \ 95 { NULL } \ 96 } 97 98 /* Packet embedding info for NGM_SOURCE_GET/SET_COUNTER */ 99 #define NG_SOURCE_COUNTERS 4 100 struct ng_source_embed_cnt_info { 101 uint16_t offset; /* offset from ethernet header */ 102 uint8_t flags; /* as above */ 103 uint8_t width; /* in bytes (1, 2, 4) */ 104 uint32_t next_val; 105 uint32_t min_val; 106 uint32_t max_val; 107 int32_t increment; 108 uint8_t index; /* which counter (0..3) */ 109 }; 110 111 /* Keep this in sync with the above structure definition. */ 112 #define NG_SOURCE_EMBED_CNT_TYPE_INFO { \ 113 { "offset", &ng_parse_hint16_type }, \ 114 { "flags", &ng_parse_hint8_type }, \ 115 { "width", &ng_parse_uint8_type }, \ 116 { "next_val", &ng_parse_uint32_type }, \ 117 { "min_val", &ng_parse_uint32_type }, \ 118 { "max_val", &ng_parse_uint32_type }, \ 119 { "increment", &ng_parse_int32_type }, \ 120 { "index", &ng_parse_uint8_type }, \ 121 { NULL } \ 122 } 123 124 /* Netgraph commands */ 125 enum { 126 NGM_SOURCE_GET_STATS = 1, /* get stats */ 127 NGM_SOURCE_CLR_STATS, /* clear stats */ 128 NGM_SOURCE_GETCLR_STATS, /* atomically get and clear stats */ 129 NGM_SOURCE_START, /* start sending queued data */ 130 NGM_SOURCE_STOP, /* stop sending queued data */ 131 NGM_SOURCE_CLR_DATA, /* clear the queued data */ 132 NGM_SOURCE_SETIFACE, /* configure downstream iface */ 133 NGM_SOURCE_SETPPS, /* rate-limiting packets per second */ 134 NGM_SOURCE_SET_TIMESTAMP, /* embed xmit timestamp */ 135 NGM_SOURCE_GET_TIMESTAMP, 136 NGM_SOURCE_SET_COUNTER, /* embed counter */ 137 NGM_SOURCE_GET_COUNTER, 138 }; 139 140 #endif /* _NETGRAPH_NG_SOURCE_H_ */ 141