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