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.; 12 provided, 13 * however, that: 14 * 1. Any and all reproductions of the source or object code must include 15 the 16 * copyright notice above and the following disclaimer of warranties; 17 and 18 * 2. No rights are granted, in any manner or form, to use Sandvine Inc. 19 * trademarks, including the mark "SANDVINE" on advertising, 20 endorsements, 21 * or otherwise except as such appears in the above copyright notice or 22 in 23 * the software. 24 * 25 * THIS SOFTWARE IS BEING PROVIDED BY SANDVINE "AS IS", AND TO THE MAXIMUM 26 * EXTENT PERMITTED BY LAW, SANDVINE MAKES NO REPRESENTATIONS OR 27 WARRANTIES, 28 * EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, INCLUDING WITHOUT 29 LIMITATION, 30 * ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 31 PARTICULAR 32 * PURPOSE, OR NON-INFRINGEMENT. SANDVINE DOES NOT WARRANT, GUARANTEE, OR 33 * MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE 34 * USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY 35 * OR OTHERWISE. IN NO EVENT SHALL SANDVINE BE LIABLE FOR ANY DAMAGES 36 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 37 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 38 EXEMPLARY, 39 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 40 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 41 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 42 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 43 * THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH 44 * DAMAGE. 45 * 46 * Author: Dave Chapeskie <dchapeskie@sandvine.com> 47 * 48 * $FreeBSD$ 49 */ 50 51 #ifndef _NETGRAPH_NG_SOURCE_H_ 52 #define _NETGRAPH_NG_SOURCE_H_ 53 54 /* Node type name and magic cookie */ 55 #define NG_SOURCE_NODE_TYPE "source" 56 #define NGM_SOURCE_COOKIE 1034346805 57 58 /* Hook names */ 59 #define NG_SOURCE_HOOK_INPUT "input" 60 #define NG_SOURCE_HOOK_OUTPUT "output" 61 62 /* Statistics structure returned by NGM_SOURCE_GET_STATS */ 63 struct ng_source_stats { 64 u_int64_t outOctets; 65 u_int64_t outFrames; 66 u_int32_t queueOctets; 67 u_int32_t queueFrames; 68 struct timeval startTime; 69 struct timeval endTime; 70 struct timeval elapsedTime; 71 }; 72 73 extern const struct ng_parse_type ng_source_timeval_type; 74 /* Keep this in sync with the above structure definition */ 75 #define NG_SOURCE_STATS_TYPE_INFO { \ 76 { "outOctets", &ng_parse_uint64_type }, \ 77 { "outFrames", &ng_parse_uint64_type }, \ 78 { "queueOctets", &ng_parse_uint32_type }, \ 79 { "queueFrames", &ng_parse_uint32_type }, \ 80 { "startTime", &ng_source_timeval_type }, \ 81 { "endTime", &ng_source_timeval_type }, \ 82 { "elapsedTime", &ng_source_timeval_type }, \ 83 { NULL } \ 84 } 85 86 /* Netgraph commands */ 87 enum { 88 NGM_SOURCE_GET_STATS = 1, /* get stats */ 89 NGM_SOURCE_CLR_STATS, /* clear stats */ 90 NGM_SOURCE_GETCLR_STATS, /* atomically get and clear stats */ 91 NGM_SOURCE_START, /* start sending queued data */ 92 NGM_SOURCE_STOP, /* stop sending queued data */ 93 NGM_SOURCE_CLR_DATA, /* clear the queued data */ 94 NGM_SOURCE_START_NOW, /* start on non-ether output */ 95 }; 96 97 #endif /* _NETGRAPH_NG_SOURCE_H_ */ 98