code:
/*
 * ng_parse.h
 */

/*-
 * Copyright (c) 1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $Whistle: ng_parse.h,v 1.2 1999/11/29 01:43:48 archie Exp $
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_parse.h 151800 2005-10-28 14:41:28Z ru $
 */

#ifndef _NETGRAPH_NG_PARSE_H_
#define _NETGRAPH_NG_PARSE_H_

/*

  This defines a library of routines for converting between various C
  language types in binary form and ASCII strings.  Types are user
  definable.  Several pre-defined types are supplied, for some common
  C types: structures, variable and fixed length arrays, integer types,
  variable and fixed length strings, IP addresses, etc.

  A netgraph node type may provide a list of types that correspond to
  the structures it expects to send and receive in the arguments field
  of a control message.  This allows these messages to be converted
  between their native binary form and the corresponding ASCII form.

  A future use of the ASCII form may be for inter-machine communication
  of control messages, because the ASCII form is machine independent
  whereas the native binary form is not.

  Syntax
  ------

    Structures:

      '{' [ <name>=<value> ... ] '}'

      Omitted fields have their default values by implication.
      The order in which the fields are specified does not matter.

    Arrays:

      '[' [ [index=]<value> ... ] ']'

      Element value may be specified with or without the "<index>=" prefix;
      If omitted, the index after the previous element is used.
      Omitted fields have their default values by implication.

    Strings:

      "foo bar blah\r\n"

      That is, strings are specified just like C strings. The usual
      backslash escapes are accepted.

    Other simple types (integers, IP addresses) have their obvious forms.

  Example
  -------

    Suppose we have a netgraph command that takes as an argument
    a 'struct foo' shown below.  Here is an example of a possible
    value for the structure, and the corresponding ASCII encoding
    of that value:

	Structure			Binary value
	---------			------------

	struct foo {
	    struct in_addr ip;  	01 02 03 04
	    int bar;			00 00 00 00
	    char label[8];		61 62 63 0a 00 00 00 00
	    u_char alen;		03 00
	    short ary[];	  	05 00 00 00 0a 00
	};

	ASCII value
	-----------

	{ ip=1.2.3.4 label="abc\n" alen=3 ary=[ 5 2=10 ] }

    Note that omitted fields and array elements get their default
    values ("bar" and ary[2]), and that the alignment is handled
    automatically (the extra 00 byte after "alen").  Also, since byte
    order and alignment are inherently machine dependent, so is this
    conversion process.  The above example shows an x86 (little
    endian) encoding.  Also the above example is tricky because the
    structure is variable length, depending on 'alen', the number of
    elements in the array 'ary'.

    Here is how one would define a parse type for the above structure,
    subclassing the pre-defined types below.  We construct the type in
    a 'bottom up' fashion, defining each field's type first, then the
    type for the whole structure ('//' comments used to avoid breakage).

    // Super-type info for 'label' field
    struct ng_parse_fixedstring_info foo_label_info = { 8 };

    // Parse type for 'label' field
    struct ng_parse_type foo_label_type = {
	    &ng_parse_fixedstring_type		// super-type
	    &foo_label_info			// super-type info
    };

    #define OFFSETOF(s, e) ((char *)&((s *)0)->e - (char *)((s *)0))

    // Function to compute the length of the array 'ary', which
    // is variable length, depending on the previous field 'alen'.
    // Upon entry 'buf' will be pointing at &ary[0].
    int
    foo_ary_getLength(const struct ng_parse_type *type,
	    const u_char *start, const u_char *buf)
    {
	    const struct foo *f;

	    f = (const struct foo *)(buf - OFFSETOF(struct foo, ary));
	    return f->alen;
    }

    // Super-type info for 'ary' field
    struct ng_parse_array_info foo_ary_info = {
	    &ng_parse_int16_type,		// element type
	    &foo_ary_getLength			// func to get array length
    }

    // Parse type for 'ary' field
    struct ng_parse_type foo_ary_type = {
	    &ng_parse_array_type,		// super-type
	    &foo_ary_info			// super-type info
    };

    // Super-type info for struct foo
    struct ng_parse_struct_field foo_fields[] = {
	    { "ip",	&ng_parse_ipaddr_type	},
	    { "bar",	&ng_parse_int32_type	},
	    { "label",	&foo_label_type		},
	    { "alen",	&ng_parse_uint8_type	},
	    { "ary",	&foo_ary_type		},
	    { NULL }
    };

    // Parse type for struct foo
    struct ng_parse_type foo_type = {
	    &ng_parse_struct_type,		// super-type
	    &foo_fields				// super-type info
    };

  To define a type, you can define it as a sub-type of a predefined
  type as shown above, possibly overriding some of the predefined
  type's methods, or define an entirely new syntax, with the restriction
  that the ASCII representation of your type's value must not contain
  any whitespace or any of these characters: { } [ ] = "

  See ng_ksocket.c for an example of how to do this for 'struct sockaddr'.
  See ng_parse.c to see implementations of the pre-defined types below.

*/

/************************************************************************
			METHODS REQUIRED BY A TYPE
 ************************************************************************/

/*
 * Three methods are required for a type. These may be given explicitly
 * or, if NULL, inherited from the super-type.  The 'getDefault' method
 * is always optional; the others are required if there is no super-type.
 */

struct ng_parse_type;

/*
 * Convert ASCII to binary according to the supplied type.
 *
 * The ASCII characters begin at offset *off in 'string'.  The binary
 * representation is put into 'buf', which has at least *buflen bytes.
 * 'start' points to the first byte output by ng_parse() (ie, start <= buf).
 *
 * Upon return, *buflen contains the length of the new binary data, and
 * *off is updated to point just past the end of the parsed range of
 * characters, or, in the case of an error, to the offending character(s).
 *
 * Return values:
 *	0		Success; *buflen holds the length of the data
 *			and *off points just past the last char parsed.
 *	EALREADY	Field specified twice
 *	ENOENT		Unknown field
 *	E2BIG		Array or character string overflow
 *	ERANGE		Output was longer than *buflen bytes
 *	EINVAL		Parse failure or other invalid content
 *	ENOMEM		Out of memory
 *	EOPNOTSUPP	Mandatory array/structure element missing
 */
typedef	int	ng_parse_t(const struct ng_parse_type *type, const char *string,
			int *off, const u_char *start,
			u_char *buf, int *buflen);

/*
 * Convert binary to ASCII according to the supplied type.
 *
 * The results are put into 'buf', which is at least buflen bytes long.
 * *off points to the current byte in 'data' and should be updated
 * before return to point just past the last byte unparsed.
 *
 * Returns:
 *	0		Success
 *	ERANGE		Output was longer than buflen bytes
 */
typedef	int	ng_unparse_t(const struct ng_parse_type *type,
			const u_char *data, int *off, char *buf, int buflen);

/*
 * Compute the default value according to the supplied type.
 *
 * Store the result in 'buf', which is at least *buflen bytes long.
 * Upon return *buflen contains the length of the output.
 *
 * Returns:
 *	0		Success
 *	ERANGE		Output was longer than *buflen bytes
 *	EOPNOTSUPP	Default value is not specified for this type
 */
typedef	int	ng_getDefault_t(const struct ng_parse_type *type,
			const u_char *start, u_char *buf, int *buflen);

/*
 * Return the alignment requirement of this type.  Zero is same as one.
 */
typedef	int	ng_getAlign_t(const struct ng_parse_type *type);

/************************************************************************
			TYPE DEFINITION
 ************************************************************************/

/*
 * This structure describes a type, which may be a sub-type of another
 * type by pointing to it with 'supertype' and possibly omitting methods.
 * Typically the super-type requires some type-specific info, which is
 * supplied by the 'info' field.
 *
 * The 'private' field is ignored by all of the pre-defined types.
 * Sub-types may use it as they see fit.
 *
 * The 'getDefault' method may always be omitted (even if there is no
 * super-type), which means the value for any item of this type must
 * always be explicitly given.
 */
struct ng_parse_type {
	const struct ng_parse_type *supertype;	/* super-type, if any */
	const void		*info;		/* type-specific info */
	void			*private;	/* client private info */
	ng_parse_t		*parse;		/* parse method */
	ng_unparse_t		*unparse;	/* unparse method */
	ng_getDefault_t		*getDefault;	/* get default value method */
	ng_getAlign_t		*getAlign;	/* get alignment */
};

/************************************************************************
			PRE-DEFINED TYPES
 ************************************************************************/

/*
 * STRUCTURE TYPE
 *
 * This type supports arbitrary C structures.  The normal field alignment
 * rules for the local machine are applied.  Fields are always parsed in
 * field order, no matter what order they are listed in the ASCII string.
 *
 *   Default value:		Determined on a per-field basis
 *   Additional info:		struct ng_parse_struct_field *
 */
extern const struct ng_parse_type ng_parse_struct_type;

/* Each field has a name, type, and optional alignment override. If the
   override is non-zero, the alignment is determined from the field type.
   Note: add an extra struct ng_parse_struct_field with name == NULL
   to indicate the end of the list. */
struct ng_parse_struct_field {
	const char			*name;		/* field name */
	const struct ng_parse_type	*type;		/* field type */
	int				alignment;	/* override alignment */
};

/*
 * FIXED LENGTH ARRAY TYPE
 *
 * This type supports fixed length arrays, having any element type.
 *
 *   Default value:		As returned by getDefault for each index
 *   Additional info:		struct ng_parse_fixedarray_info *
 */
extern const struct ng_parse_type ng_parse_fixedarray_type;

/*
 * Get the default value for the element at index 'index'.  This method
 * may be NULL, in which case the default value is computed from the
 * element type.  Otherwise, it should fill in the default value at *buf
 * (having size *buflen) and update *buflen to the length of the filled-in
 * value before return.  If there is not enough routine return ERANGE.
 */
typedef	int	ng_parse_array_getDefault_t(const struct ng_parse_type *type,
				int index, const u_char *start,
				u_char *buf, int *buflen);

struct ng_parse_fixedarray_info {
	const struct ng_parse_type	*elementType;
	int				length;
	ng_parse_array_getDefault_t	*getDefault;
};

/*
 * VARIABLE LENGTH ARRAY TYPE
 *
 * Same as fixed length arrays, except that the length is determined
 * by a function instead of a constant value.
 *
 *   Default value:		Same as with fixed length arrays
 *   Additional info:		struct ng_parse_array_info *
 */
extern const struct ng_parse_type ng_parse_array_type;

/*
 * Return the length of the array.  If the array is a field in a structure,
 * all prior fields are guaranteed to be filled in already.  Upon entry,
 * 'start' is equal to the first byte parsed in this run, while 'buf' points
 * to the first element of the array to be filled in.
 */
typedef int	ng_parse_array_getLength_t(const struct ng_parse_type *type,
				const u_char *start, const u_char *buf);

struct ng_parse_array_info {
	const struct ng_parse_type	*elementType;
	ng_parse_array_getLength_t	*getLength;
	ng_parse_array_getDefault_t	*getDefault;
};

/*
 * ARBITRARY LENGTH STRING TYPE
 *
 * For arbirary length, NUL-terminated strings.
 *
 *   Default value:		Empty string
 *   Additional info:		None required
 */
extern const struct ng_parse_type ng_parse_string_type;

/*
 * BOUNDED LENGTH STRING TYPE
 *
 * These are strings that have a fixed-size buffer, and always include
 * a terminating NUL character.
 *
 *   Default value:		Empty string
 *   Additional info:		struct ng_parse_fixedstring_info *
 */
extern const struct ng_parse_type ng_parse_fixedstring_type;

struct ng_parse_fixedstring_info {
	int	bufSize;	/* size of buffer (including NUL) */
};

/*
 * EXPLICITLY SIZED STRING TYPE
 *
 * These are strings that have a two byte length field preceding them.
 * Parsed strings are NOT NUL-terminated.
 *
 *   Default value:		Empty string
 *   Additional info:		None
 */
extern const struct ng_parse_type ng_parse_sizedstring_type;

/*
 * COMMONLY USED BOUNDED LENGTH STRING TYPES
 */
extern const struct ng_parse_type ng_parse_nodebuf_type;  /* NG_NODESIZ */
extern const struct ng_parse_type ng_parse_hookbuf_type;  /* NG_HOOKSIZ */
extern const struct ng_parse_type ng_parse_pathbuf_type;  /* NG_PATHSIZ */
extern const struct ng_parse_type ng_parse_typebuf_type;  /* NG_TYPESIZ */
extern const struct ng_parse_type ng_parse_cmdbuf_type;   /* NG_CMDSTRSIZ */

/*
 * INTEGER TYPES
 *
 *   Default value:		0
 *   Additional info:		None required
 */
extern const struct ng_parse_type ng_parse_int8_type;
extern const struct ng_parse_type ng_parse_int16_type;
extern const struct ng_parse_type ng_parse_int32_type;
extern const struct ng_parse_type ng_parse_int64_type;

/* Same thing but unparse as unsigned quantities */
extern const struct ng_parse_type ng_parse_uint8_type;
extern const struct ng_parse_type ng_parse_uint16_type;
extern const struct ng_parse_type ng_parse_uint32_type;
extern const struct ng_parse_type ng_parse_uint64_type;

/* Same thing but unparse as hex quantities, e.g., "0xe7" */
extern const struct ng_parse_type ng_parse_hint8_type;
extern const struct ng_parse_type ng_parse_hint16_type;
extern const struct ng_parse_type ng_parse_hint32_type;
extern const struct ng_parse_type ng_parse_hint64_type;

/*
 * IP ADDRESS TYPE
 *
 *   Default value:		0.0.0.0
 *   Additional info:		None required
 */
extern const struct ng_parse_type ng_parse_ipaddr_type;

/*
 * ETHERNET ADDRESS TYPE
 *
 *   Default value:		None
 *   Additional info:		None required
 */
extern const struct ng_parse_type ng_parse_enaddr_type;

/*
 * VARIABLE LENGTH BYTE ARRAY TYPE
 *
 * The bytes are displayed in hex.  The ASCII form may be either an
 * array of bytes or a string constant, in which case the array is
 * zero-filled after the string bytes.
 *
 *   Default value:		All bytes are zero
 *   Additional info:		ng_parse_array_getLength_t *
 */
extern const struct ng_parse_type ng_parse_bytearray_type;

/*
 * NETGRAPH CONTROL MESSAGE TYPE
 *
 * This is the parse type for a struct ng_mesg.
 *
 *   Default value:		All fields zero
 *   Additional info:		None required
 */
extern const struct ng_parse_type ng_parse_ng_mesg_type;

/************************************************************************
		CONVERSTION AND PARSING ROUTINES
 ************************************************************************/

/* Tokens for parsing structs and arrays */
enum ng_parse_token {
	T_LBRACE,		/* '{' */
	T_RBRACE,		/* '}' */
	T_LBRACKET,		/* '[' */
	T_RBRACKET,		/* ']' */
	T_EQUALS,		/* '=' */
	T_STRING,		/* string in double quotes */
	T_ERROR,		/* error parsing string in double quotes */
	T_WORD,			/* anything else containing no whitespace */
	T_EOF,			/* end of string reached */
};

/*
 * See typedef ng_parse_t for definition
 */
extern int	ng_parse(const struct ng_parse_type *type, const char *string,
			int *off, u_char *buf, int *buflen);

/*
 * See typedef ng_unparse_t for definition (*off assumed to be zero).
 */
extern int	ng_unparse(const struct ng_parse_type *type,
			const u_char *data, char *buf, int buflen);

/*
 * See typedef ng_getDefault_t for definition
 */
extern int	ng_parse_getDefault(const struct ng_parse_type *type,
			u_char *buf, int *buflen);

/*
 * Parse a token: '*startp' is the offset to start looking.  Upon
 * successful return, '*startp' equals the beginning of the token
 * and '*lenp' the length.  If error, '*startp' points at the
 * offending character(s).
 */
extern enum	ng_parse_token ng_parse_get_token(const char *s,
			int *startp, int *lenp);

/*
 * Like above, but specifically for getting a string token and returning
 * the string value.  The string token must be enclosed in double quotes
 * and the normal C backslash escapes are recognized.  The caller must
 * eventually free() the returned result.  Returns NULL if token is
 * not a string token, or parse or other error. Otherwise, *lenp contains
 * the number of characters parsed, and *slenp (if not NULL) contains
 * the actual number of characters in the parsed string.
 */
extern char	*ng_get_string_token(const char *s, int *startp,
			int *lenp, int *slenp);

/*
 * Convert a raw string into a doubly-quoted string including any
 * necessary backslash escapes.  Caller must free the result.
 * Returns NULL if ENOMEM. Normally "slen" should equal strlen(s)
 * unless you want to encode NUL bytes.
 */
extern char	*ng_encode_string(const char *s, int slen);

#endif /* _NETGRAPH_NG_PARSE_H_ */


code:
/*-
 * Copyright (C) 2010 by Maxim Ignatenko <gelraen.ua@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_patch.h 208989 2010-06-10 16:45:30Z ae $
 */

#ifndef _NETGRAPH_NG_PATCH_H_
#define _NETGRAPH_NG_PATCH_H_

/* Node type name. */
#define	NG_PATCH_NODE_TYPE	"patch"

/* Node type cookie. */
#define	NGM_PATCH_COOKIE	1262445509

/* Hook names */
#define	NG_PATCH_HOOK_IN	"in"
#define	NG_PATCH_HOOK_OUT	"out"

/* Netgraph commands understood by this node type */
enum {
	NGM_PATCH_SETCONFIG = 1,
	NGM_PATCH_GETCONFIG,
	NGM_PATCH_GET_STATS,
	NGM_PATCH_CLR_STATS,
	NGM_PATCH_GETCLR_STATS
};

/* Patching modes */
enum {
	NG_PATCH_MODE_SET = 1,
	NG_PATCH_MODE_ADD = 2,
	NG_PATCH_MODE_SUB = 3,
	NG_PATCH_MODE_MUL = 4,
	NG_PATCH_MODE_DIV = 5,
	NG_PATCH_MODE_NEG = 6,
	NG_PATCH_MODE_AND = 7,
	NG_PATCH_MODE_OR = 8,
	NG_PATCH_MODE_XOR = 9,
	NG_PATCH_MODE_SHL = 10,
	NG_PATCH_MODE_SHR = 11
};

struct ng_patch_op {
	uint64_t	value;
	uint32_t	offset;
	uint16_t	length;	/* 1,2,4 or 8 (bytes) */
	uint16_t	mode;
};

#define	NG_PATCH_OP_TYPE_INFO	{	\
		{ "value",	&ng_parse_uint64_type	},	\
		{ "offset",	&ng_parse_uint32_type	},	\
		{ "length",	&ng_parse_uint16_type	},	\
		{ "mode",	&ng_parse_uint16_type	},	\
		{ NULL } \
}

struct ng_patch_config {
	uint32_t	count;
	uint32_t	csum_flags;
	struct ng_patch_op ops[];
};

#define	NG_PATCH_CONFIG_TYPE_INFO	{	\
		{ "count",	&ng_parse_uint32_type	},	\
		{ "csum_flags",	&ng_parse_uint32_type	},	\
		{ "ops",	&ng_patch_confarr_type	},	\
		{ NULL } \
}

struct ng_patch_stats {
	uint64_t	received;
	uint64_t	patched;
	uint64_t	dropped;
};

#define	NG_PATCH_STATS_TYPE_INFO {	\
		{ "received",	&ng_parse_uint64_type	},	\
		{ "patched",	&ng_parse_uint64_type	},	\
		{ "dropped",	&ng_parse_uint64_type	},	\
		{ NULL } \
}

#endif /* _NETGRAPH_NG_PATCH_H_ */

repo_name: veiledmerc/mira

license: mit


code:
/*-
 * Copyright (c) 2004-2008 University of Zagreb
 * Copyright (c) 2007-2008 FreeBSD Foundation
 *
 * This software was developed by the University of Zagreb and the
 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
 * FreeBSD Foundation.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_pipe.h 206360 2010-04-07 16:29:10Z joel $
 */

#ifndef _NETGRAPH_PIPE_H_
#define _NETGRAPH_PIPE_H_

/* Node type name and magic cookie */
#define NG_PIPE_NODE_TYPE	"pipe"
#define NGM_PIPE_COOKIE		200708191

/* Hook names */
#define NG_PIPE_HOOK_UPPER	"upper"
#define NG_PIPE_HOOK_LOWER	"lower"

#define MAX_FSIZE 16384	/* Largest supported frame size, in bytes, for BER */
#define MAX_OHSIZE 256	/* Largest supported dummy-framing size, in bytes */

/* Statistics structure for one hook */
struct ng_pipe_hookstat {
	u_int64_t		fwd_octets;
	u_int64_t		fwd_frames;
	u_int64_t		in_disc_octets;
	u_int64_t		in_disc_frames;
	u_int64_t		out_disc_octets;
	u_int64_t		out_disc_frames;
};

/* Keep this in sync with the above structure definition */
#define NG_PIPE_HOOKSTAT_INFO	{					\
	{ "FwdOctets",		&ng_parse_uint64_type	},		\
	{ "FwdFrames",		&ng_parse_uint64_type	},		\
	{ "queueDropOctets",	&ng_parse_uint64_type	},		\
	{ "queueDropFrames",	&ng_parse_uint64_type	},		\
	{ "delayDropOctets",	&ng_parse_uint64_type	},		\
	{ "delayDropFrames",	&ng_parse_uint64_type	},		\
	{ NULL },							\
}

/* Statistics structure returned by NGM_PIPE_GET_STATS */
struct ng_pipe_stats {
	struct ng_pipe_hookstat	downstream;
	struct ng_pipe_hookstat	upstream;
};

/* Keep this in sync with the above structure definition */
#define NG_PIPE_STATS_INFO(hstype)	{				\
	{ "downstream",		(hstype) },				\
	{ "upstream",		(hstype) },				\
	{ NULL },							\
}

/* Runtime structure for one hook */
struct ng_pipe_hookrun {
	u_int32_t		fifo_queues;
	u_int32_t		qin_octets;
	u_int32_t		qin_frames;
	u_int32_t		qout_octets;
	u_int32_t		qout_frames;
};

/* Keep this in sync with the above structure definition */
#define NG_PIPE_HOOKRUN_INFO	{					\
	{ "queues",		&ng_parse_uint32_type	},		\
	{ "queuedOctets",	&ng_parse_uint32_type	},		\
	{ "queuedFrames",	&ng_parse_uint32_type	},		\
	{ "delayedOctets",	&ng_parse_uint32_type	},		\
	{ "delayedFrames",	&ng_parse_uint32_type	},		\
	{ NULL },							\
}

/* Runtime structure returned by NGM_PIPE_GET_RUN */
struct ng_pipe_run {
	struct ng_pipe_hookrun	downstream;
	struct ng_pipe_hookrun	upstream;
};

/* Keep this in sync with the above structure definition */
#define NG_PIPE_RUN_INFO(hstype)	{				\
	{ "downstream",		(hstype) },				\
	{ "upstream",		(hstype) },				\
	{ NULL },							\
}

/* Config structure for one hook */
struct ng_pipe_hookcfg {
	u_int64_t		bandwidth;
	u_int64_t		ber;
	u_int32_t		qin_size_limit;
	u_int32_t		qout_size_limit;
	u_int32_t		duplicate;
	u_int32_t		fifo;
	u_int32_t		drr;
	u_int32_t		wfq;
	u_int32_t		droptail;
	u_int32_t		drophead;
};

/* Keep this in sync with the above structure definition */
#define NG_PIPE_HOOKCFG_INFO	{					\
	{ "bandwidth",		&ng_parse_uint64_type	},		\
	{ "BER",		&ng_parse_uint64_type	},		\
	{ "queuelen",		&ng_parse_uint32_type	},		\
	{ "delaylen",		&ng_parse_uint32_type	},		\
	{ "duplicate",		&ng_parse_uint32_type	},		\
	{ "fifo",		&ng_parse_uint32_type	},		\
	{ "drr",		&ng_parse_uint32_type	},		\
	{ "wfq",		&ng_parse_uint32_type	},		\
	{ "droptail",		&ng_parse_uint32_type	},		\
	{ "drophead",		&ng_parse_uint32_type	},		\
	{ NULL },							\
}

/* Config structure returned by NGM_PIPE_GET_CFG */
struct ng_pipe_cfg {
	u_int64_t		bandwidth;
	u_int64_t		delay;
	u_int32_t		header_offset;
	u_int32_t		overhead;
	struct ng_pipe_hookcfg	downstream;
	struct ng_pipe_hookcfg	upstream;
};

/* Keep this in sync with the above structure definition */
#define NG_PIPE_CFG_INFO(hstype)	{				\
	{ "bandwidth",		&ng_parse_uint64_type	},		\
	{ "delay",		&ng_parse_uint64_type	},		\
	{ "header_offset",	&ng_parse_uint32_type	},		\
	{ "overhead",		&ng_parse_uint32_type	},		\
	{ "downstream",		(hstype)		},		\
	{ "upstream",		(hstype)		},		\
	{ NULL },							\
}

/* Netgraph commands */
enum {
	NGM_PIPE_GET_STATS=1,		/* get stats */
	NGM_PIPE_CLR_STATS,		/* clear stats */
	NGM_PIPE_GETCLR_STATS,		/* atomically get and clear stats */
	NGM_PIPE_GET_RUN,		/* get current runtime status */
	NGM_PIPE_GET_CFG,		/* get configurable parameters */
	NGM_PIPE_SET_CFG,		/* set configurable parameters */
};

#endif /* _NETGRAPH_PIPE_H_ */


code:
/*
 * ng_ppp.h
 */

/*-
 * Copyright (c) 1996-2000 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_ppp.h 171688 2007-08-01 20:49:35Z mav $
 * $Whistle: ng_ppp.h,v 1.8 1999/01/25 02:40:02 archie Exp $
 */

#ifndef _NETGRAPH_NG_PPP_H_
#define _NETGRAPH_NG_PPP_H_

/* Node type name and magic cookie */
#define NG_PPP_NODE_TYPE	"ppp"
#define NGM_PPP_COOKIE		940897795

/* 64bit stats presence flag */
#define NG_PPP_STATS64

/* Maximum number of supported links */
#define NG_PPP_MAX_LINKS	16

/* Pseudo-link number representing the multi-link bundle */
#define NG_PPP_BUNDLE_LINKNUM	0xffff

/* Max allowable link latency (miliseconds) and bandwidth (bytes/second/10) */
#define NG_PPP_MAX_LATENCY	1000		/* 1 second */
#define NG_PPP_MAX_BANDWIDTH	125000		/* 10 Mbits / second */

/* Hook names */
#define NG_PPP_HOOK_BYPASS	"bypass"	/* unknown protocols */
#define NG_PPP_HOOK_COMPRESS	"compress"	/* outgoing compression */
#define NG_PPP_HOOK_DECOMPRESS	"decompress"	/* incoming decompression */
#define NG_PPP_HOOK_ENCRYPT	"encrypt"	/* outgoing encryption */
#define NG_PPP_HOOK_DECRYPT	"decrypt"	/* incoming decryption */
#define NG_PPP_HOOK_VJC_IP	"vjc_ip"	/* VJC raw IP */
#define NG_PPP_HOOK_VJC_COMP	"vjc_vjcomp"	/* VJC compressed TCP */
#define NG_PPP_HOOK_VJC_UNCOMP	"vjc_vjuncomp"	/* VJC uncompressed TCP */
#define NG_PPP_HOOK_VJC_VJIP	"vjc_vjip"	/* VJC uncompressed IP */
#define NG_PPP_HOOK_INET	"inet"		/* IP packet data */
#define NG_PPP_HOOK_ATALK	"atalk"		/* AppleTalk packet data */
#define NG_PPP_HOOK_IPX		"ipx"		/* IPX packet data */
#define NG_PPP_HOOK_IPV6	"ipv6"		/* IPv6 packet data */

#define NG_PPP_HOOK_LINK_PREFIX	"link"		/* append decimal link number */

/* Compress hook operation modes */
enum {
	NG_PPP_COMPRESS_NONE = 0,	/* compression disabled */
	NG_PPP_COMPRESS_SIMPLE,		/* original operation mode */
	NG_PPP_COMPRESS_FULL,		/* compressor returns proto */
};

/* Decompress hook operation modes */
enum {
	NG_PPP_DECOMPRESS_NONE = 0,	/* decompression disabled */
	NG_PPP_DECOMPRESS_SIMPLE,	/* original operation mode */
	NG_PPP_DECOMPRESS_FULL,		/* forward any packet to decompressor */
};

/* Netgraph commands */
enum {
	NGM_PPP_SET_CONFIG = 1,		/* takes struct ng_ppp_node_conf */
	NGM_PPP_GET_CONFIG,		/* returns ng_ppp_node_conf */
	NGM_PPP_GET_MP_STATE,		/* returns ng_ppp_mp_state */
	NGM_PPP_GET_LINK_STATS,		/* takes link #, returns stats struct */
	NGM_PPP_CLR_LINK_STATS,		/* takes link #, clears link stats */
	NGM_PPP_GETCLR_LINK_STATS,	/* takes link #, returns & clrs stats */
	NGM_PPP_GET_LINK_STATS64,	/* takes link #, returns stats64 struct */
	NGM_PPP_GETCLR_LINK_STATS64,	/* takes link #, returns stats64 & clrs */
};

/* Multi-link sequence number state (for debugging) */
struct ng_ppp_mp_state {
	int32_t		rseq[NG_PPP_MAX_LINKS];	/* highest rec'd MP seq # */
	int32_t		mseq;			/* min rseq[i] */
	int32_t		xseq;			/* next xmit MP seq # */
};

/* Keep this in sync with the above structure definition */
#define NG_PPP_MP_STATE_TYPE_INFO(atype)	{		\
	  { "rseq",	(atype)			},		\
	  { "mseq",	&ng_parse_hint32_type	},		\
	  { "xseq",	&ng_parse_hint32_type	},		\
	  { NULL }						\
}

/* Per-link config structure */
struct ng_ppp_link_conf {
	u_char		enableLink;	/* enable this link */
	u_char		enableProtoComp;/* enable protocol field compression */
	u_char		enableACFComp;	/* enable addr/ctrl field compression */
	u_int16_t	mru;		/* peer MRU */
	u_int32_t	latency;	/* link latency (in milliseconds) */
	u_int32_t	bandwidth;	/* link bandwidth (in bytes/sec/10) */
};

/* Keep this in sync with the above structure definition */
#define NG_PPP_LINK_TYPE_INFO	{				\
	  { "enableLink",	&ng_parse_uint8_type	},	\
	  { "enableProtoComp",	&ng_parse_uint8_type	},	\
	  { "enableACFComp",	&ng_parse_uint8_type	},	\
	  { "mru",		&ng_parse_uint16_type	},	\
	  { "latency",		&ng_parse_uint32_type	},	\
	  { "bandwidth",	&ng_parse_uint32_type	},	\
	  { NULL }						\
}

/* Bundle config structure */
struct ng_ppp_bund_conf {
	u_int16_t	mrru;			/* multilink peer MRRU */
	u_char		enableMultilink;	/* enable multilink */
	u_char		recvShortSeq;		/* recv multilink short seq # */
	u_char		xmitShortSeq;		/* xmit multilink short seq # */
	u_char		enableRoundRobin;	/* xmit whole packets */
	u_char		enableIP;		/* enable IP data flow */
	u_char		enableIPv6;		/* enable IPv6 data flow */
	u_char		enableAtalk;		/* enable AppleTalk data flow */
	u_char		enableIPX;		/* enable IPX data flow */
	u_char		enableCompression;	/* enable PPP compression */
	u_char		enableDecompression;	/* enable PPP decompression */
	u_char		enableEncryption;	/* enable PPP encryption */
	u_char		enableDecryption;	/* enable PPP decryption */
	u_char		enableVJCompression;	/* enable VJ compression */
	u_char		enableVJDecompression;	/* enable VJ decompression */
};

/* Keep this in sync with the above structure definition */
#define NG_PPP_BUND_TYPE_INFO	{					\
	  { "mrru",			&ng_parse_uint16_type	},	\
	  { "enableMultilink",		&ng_parse_uint8_type	},	\
	  { "recvShortSeq",		&ng_parse_uint8_type	},	\
	  { "xmitShortSeq",		&ng_parse_uint8_type	},	\
	  { "enableRoundRobin",		&ng_parse_uint8_type	},	\
	  { "enableIP",			&ng_parse_uint8_type	},	\
	  { "enableIPv6",		&ng_parse_uint8_type	},	\
	  { "enableAtalk",		&ng_parse_uint8_type	},	\
	  { "enableIPX",		&ng_parse_uint8_type	},	\
	  { "enableCompression",	&ng_parse_uint8_type	},	\
	  { "enableDecompression",	&ng_parse_uint8_type	},	\
	  { "enableEncryption",		&ng_parse_uint8_type	},	\
	  { "enableDecryption",		&ng_parse_uint8_type	},	\
	  { "enableVJCompression",	&ng_parse_uint8_type	},	\
	  { "enableVJDecompression",	&ng_parse_uint8_type	},	\
	  { NULL }							\
}

/* Total node config structure */
struct ng_ppp_node_conf {
	struct ng_ppp_bund_conf	bund;
	struct ng_ppp_link_conf	links[NG_PPP_MAX_LINKS];
};

/* Keep this in sync with the above structure definition */
#define NG_PPP_CONFIG_TYPE_INFO(bctype, arytype)	{	\
	  { "bund",		(bctype)	},		\
	  { "links",		(arytype)	},		\
	  { NULL }						\
}

/* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
struct ng_ppp_link_stat {
	u_int32_t xmitFrames;		/* xmit frames on link */
	u_int32_t xmitOctets;		/* xmit octets on link */
	u_int32_t recvFrames;		/* recv frames on link */
	u_int32_t recvOctets;		/* recv octets on link */
	u_int32_t badProtos;		/* frames rec'd with bogus protocol */
	u_int32_t runts;		/* Too short MP fragments */
	u_int32_t dupFragments;		/* MP frames with duplicate seq # */
	u_int32_t dropFragments;	/* MP fragments we had to drop */
};

/* Keep this in sync with the above structure definition */
#define NG_PPP_STATS_TYPE_INFO	{				\
	  { "xmitFrames",	&ng_parse_uint32_type	},	\
	  { "xmitOctets",	&ng_parse_uint32_type	},	\
	  { "recvFrames",	&ng_parse_uint32_type	},	\
	  { "recvOctets",	&ng_parse_uint32_type	},	\
	  { "badProtos",	&ng_parse_uint32_type	},	\
	  { "runts",		&ng_parse_uint32_type	},	\
	  { "dupFragments",	&ng_parse_uint32_type	},	\
	  { "dropFragments",	&ng_parse_uint32_type	},	\
	  { NULL }						\
}

/* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
struct ng_ppp_link_stat64 {
	u_int64_t xmitFrames;		/* xmit frames on link */
	u_int64_t xmitOctets;		/* xmit octets on link */
	u_int64_t recvFrames;		/* recv frames on link */
	u_int64_t recvOctets;		/* recv octets on link */
	u_int64_t badProtos;		/* frames rec'd with bogus protocol */
	u_int64_t runts;		/* Too short MP fragments */
	u_int64_t dupFragments;		/* MP frames with duplicate seq # */
	u_int64_t dropFragments;	/* MP fragments we had to drop */
};

/* Keep this in sync with the above structure definition */
#define NG_PPP_STATS64_TYPE_INFO	{			\
	  { "xmitFrames",	&ng_parse_uint64_type	},	\
	  { "xmitOctets",	&ng_parse_uint64_type	},	\
	  { "recvFrames",	&ng_parse_uint64_type	},	\
	  { "recvOctets",	&ng_parse_uint64_type	},	\
	  { "badProtos",	&ng_parse_uint64_type	},	\
	  { "runts",		&ng_parse_uint64_type	},	\
	  { "dupFragments",	&ng_parse_uint64_type	},	\
	  { "dropFragments",	&ng_parse_uint64_type	},	\
	  { NULL }						\
}

#endif /* _NETGRAPH_NG_PPP_H_ */


code:
/*
 * ng_pppoe.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Julian Elischer <julian@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_pppoe.h 189315 2009-03-03 18:47:33Z ed $
 * $Whistle: ng_pppoe.h,v 1.7 1999/10/16 10:16:43 julian Exp $
 */

#ifndef _NETGRAPH_NG_PPPOE_H_
#define _NETGRAPH_NG_PPPOE_H_

/********************************************************************
 * Netgraph hook constants etc.
 ********************************************************************/
/* Node type name. This should be unique among all netgraph node types */
#define NG_PPPOE_NODE_TYPE	"pppoe"

#define NGM_PPPOE_COOKIE		1089893072

#define	PPPOE_SERVICE_NAME_SIZE		64 /* for now */

/* Hook names */
#define NG_PPPOE_HOOK_ETHERNET	"ethernet"
#define NG_PPPOE_HOOK_DEBUG	"debug"

/* Mode names */
#define	NG_PPPOE_STANDARD	"standard"
#define	NG_PPPOE_3COM		"3Com"
#define	NG_PPPOE_NONSTANDARD	NG_PPPOE_3COM
#define	NG_PPPOE_DLINK		"D-Link"

/**********************************************************************
 * Netgraph commands understood by this node type.
 * FAIL, SUCCESS, CLOSE and ACNAME are sent by the node rather than received.
 ********************************************************************/
enum cmd {
	NGM_PPPOE_SET_FLAG = 1,
	NGM_PPPOE_CONNECT  = 2,	/* Client, Try find this service */
	NGM_PPPOE_LISTEN   = 3,	/* Server, Await a request for this service */
	NGM_PPPOE_OFFER    = 4,	/* Server, hook X should respond (*) */
	NGM_PPPOE_SUCCESS  = 5,	/* State machine connected */
	NGM_PPPOE_FAIL     = 6,	/* State machine could not connect */
	NGM_PPPOE_CLOSE    = 7,	/* Session closed down */
	NGM_PPPOE_SERVICE  = 8,	/* additional Service to advertise (in PADO) */
	NGM_PPPOE_ACNAME   = 9,	/* AC_NAME for informational purposes */
	NGM_PPPOE_GET_STATUS = 10, /* data in/out */
	NGM_PPPOE_SESSIONID  = 11,  /* Session_ID for informational purposes */
	NGM_PPPOE_SETMODE  = 12, /* set to standard or compat modes */
	NGM_PPPOE_GETMODE  = 13, /* see current mode */
	NGM_PPPOE_SETENADDR = 14, /* set Ethernet address */
};

/***********************
 * Structures passed in the various netgraph command messages.
 ***********************/
/* This structure is returned by the NGM_PPPOE_GET_STATUS command */
struct ngpppoestat {
	u_int   packets_in;	/* packets in from ethernet */
	u_int   packets_out;	/* packets out towards ethernet */
};

/* Keep this in sync with the above structure definition */
#define NG_PPPOESTAT_TYPE_INFO	{				\
	  { "packets_in",	&ng_parse_uint_type	},	\
	  { "packets_out",	&ng_parse_uint_type	},	\
	  { NULL }						\
}

/*
 * When this structure is accepted by the NGM_PPPOE_CONNECT command :
 * The data field is MANDATORY.
 * The session sends out a PADI request for the named service.
 *
 *
 * When this structure is accepted by the NGM_PPPOE_LISTEN command.
 * If no service is given this is assumed to accept ALL PADI requests.
 * This may at some time take a regexp expression, but not yet.
 * Matching PADI requests will be passed up the named hook.
 *
 *
 * When this structure is accepted by the NGM_PPPOE_OFFER command:
 * The AC-NAme field is set from that given and a PADI
 * packet is expected to arrive from the session control daemon, on the
 * named hook. The session will then issue the appropriate PADO
 * and begin negotiation.
 */
struct ngpppoe_init_data {
	char		hook[NG_HOOKSIZ];	/* hook to monitor on */
	u_int16_t	data_len;		/* Length of the service name */
	char		data[];			/* init data goes here */
};

/* Keep this in sync with the above structure definition */
#define NG_PPPOE_INIT_DATA_TYPE_INFO	{		\
	  { "hook",	&ng_parse_hookbuf_type	},	\
	  { "data",	&ng_parse_sizedstring_type },	\
	  { NULL }					\
}

/*
 * This structure is used by the asychronous success and failure messages.
 * (to report which hook has failed or connected). The message is sent
 * to whoever requested the connection. (close may use this too).
 */
struct ngpppoe_sts {
	char	hook[NG_HOOKSIZ];	/* hook associated with event session */
};

/* Keep this in sync with the above structure definition */
#define NG_PPPOE_STS_TYPE_INFO		{		\
	  { "hook",	&ng_parse_hookbuf_type	},	\
	  { NULL }					\
}

/********************************************************************
 * Constants and definitions specific to pppoe
 ********************************************************************/

#define PPPOE_TIMEOUT_LIMIT 64
#define PPPOE_OFFER_TIMEOUT 16
#define PPPOE_INITIAL_TIMEOUT 2

/* Codes to identify message types */
#define PADI_CODE	0x09
#define PADO_CODE	0x07
#define PADR_CODE	0x19
#define PADS_CODE	0x65
#define PADT_CODE	0xa7

/* Tag identifiers */
#if BYTE_ORDER == BIG_ENDIAN
#define PTT_EOL		(0x0000)
#define PTT_SRV_NAME	(0x0101)
#define PTT_AC_NAME	(0x0102)
#define PTT_HOST_UNIQ	(0x0103)
#define PTT_AC_COOKIE	(0x0104)
#define PTT_VENDOR 	(0x0105)
#define PTT_RELAY_SID	(0x0110)
#define PTT_SRV_ERR     (0x0201)
#define PTT_SYS_ERR  	(0x0202)
#define PTT_GEN_ERR  	(0x0203)

#define ETHERTYPE_PPPOE_DISC	0x8863	/* pppoe discovery packets     */
#define ETHERTYPE_PPPOE_SESS	0x8864	/* pppoe session packets       */
#define ETHERTYPE_PPPOE_3COM_DISC 0x3c12 /* pppoe discovery packets 3com? */
#define ETHERTYPE_PPPOE_3COM_SESS 0x3c13 /* pppoe session packets   3com? */
#else
#define PTT_EOL		(0x0000)
#define PTT_SRV_NAME	(0x0101)
#define PTT_AC_NAME	(0x0201)
#define PTT_HOST_UNIQ	(0x0301)
#define PTT_AC_COOKIE	(0x0401)
#define PTT_VENDOR 	(0x0501)
#define PTT_RELAY_SID	(0x1001)
#define PTT_SRV_ERR     (0x0102)
#define PTT_SYS_ERR  	(0x0202)
#define PTT_GEN_ERR  	(0x0302)

#define ETHERTYPE_PPPOE_DISC	0x6388	/* pppoe discovery packets     */
#define ETHERTYPE_PPPOE_SESS	0x6488	/* pppoe session packets       */
#define ETHERTYPE_PPPOE_3COM_DISC 0x123c /* pppoe discovery packets 3com? */
#define ETHERTYPE_PPPOE_3COM_SESS 0x133c /* pppoe session packets   3com? */
#endif

struct pppoe_tag {
	u_int16_t tag_type;
	u_int16_t tag_len;
}__packed;

struct pppoe_hdr{
	u_int8_t ver:4;
	u_int8_t type:4;
	u_int8_t code;
	u_int16_t sid;
	u_int16_t length;
}__packed;

struct pppoe_full_hdr {
	struct  ether_header eh;
	struct pppoe_hdr ph;
}__packed;

union	packet {
	struct pppoe_full_hdr	pkt_header;
	u_int8_t	bytes[2048];
};

struct datatag {
        struct pppoe_tag hdr;
	u_int8_t        data[PPPOE_SERVICE_NAME_SIZE];
};

/*
 * Define the order in which we will place tags in packets
 * this may be ignored
 */
/* for PADI */
#define TAGI_SVC 0
#define TAGI_HUNIQ 1
/* for PADO */
#define TAGO_ACNAME 0
#define TAGO_SVC 1
#define TAGO_COOKIE 2
#define TAGO_HUNIQ 3
/* for PADR */
#define TAGR_SVC 0
#define TAGR_HUNIQ 1
#define TAGR_COOKIE 2
/* for PADS */
#define TAGS_ACNAME 0
#define TAGS_SVC 1
#define TAGS_COOKIE 2
#define TAGS_HUNIQ 3
/* for PADT */

#endif /* _NETGRAPH_NG_PPPOE_H_ */


code:
/*
 * ng_pptpgre.h
 */

/*-
 * Copyright (c) 1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_pptpgre.h 177587 2008-03-24 22:55:22Z mav $
 * $Whistle: ng_pptpgre.h,v 1.3 1999/12/08 00:11:36 archie Exp $
 */

#ifndef _NETGRAPH_NG_PPTPGRE_H_
#define _NETGRAPH_NG_PPTPGRE_H_

/* Node type name and magic cookie */
#define NG_PPTPGRE_NODE_TYPE	"pptpgre"
#define NGM_PPTPGRE_COOKIE	1082548365

/* Hook names */
#define NG_PPTPGRE_HOOK_UPPER	"upper"		/* to upper layers */
#define NG_PPTPGRE_HOOK_LOWER	"lower"		/* to lower layers */

/* Session hooks: prefix plus hex session ID, e.g., "session_3e14" */
#define NG_PPTPGRE_HOOK_SESSION_P	"session_"
#define NG_PPTPGRE_HOOK_SESSION_F	"session_%04x"

/* Configuration for a session */
struct ng_pptpgre_conf {
	u_char		enabled;	/* enables traffic flow */
	u_char		enableDelayedAck;/* enables delayed acks */
	u_char		enableAlwaysAck;/* always include ack with data */
	u_char		enableWindowing;/* enable windowing algorithm */
	u_int16_t	cid;		/* my call id */
	u_int16_t	peerCid;	/* peer call id */
	u_int16_t	recvWin;	/* peer recv window size */
	u_int16_t	peerPpd;	/* peer packet processing delay
					   (in units of 1/10 of a second) */
};

/* Keep this in sync with the above structure definition */
#define NG_PPTPGRE_CONF_TYPE_INFO	{			\
	  { "enabled",		&ng_parse_uint8_type	},	\
	  { "enableDelayedAck",	&ng_parse_uint8_type	},	\
	  { "enableAlwaysAck",	&ng_parse_uint8_type	},	\
	  { "enableWindowing",	&ng_parse_uint8_type	},	\
	  { "cid",		&ng_parse_hint16_type	},	\
	  { "peerCid",		&ng_parse_hint16_type	},	\
	  { "recvWin",		&ng_parse_uint16_type	},	\
	  { "peerPpd",		&ng_parse_uint16_type	},	\
	  { NULL }						\
}

/* Statistics struct */
struct ng_pptpgre_stats {
	u_int32_t xmitPackets;		/* number of GRE packets xmit */
	u_int32_t xmitOctets;		/* number of GRE octets xmit */
	u_int32_t xmitLoneAcks;		/* ack-only packets transmitted */
	u_int32_t xmitDrops;		/* xmits dropped due to full window */
	u_int32_t xmitTooBig;		/* xmits dropped because too big */
	u_int32_t recvPackets;		/* number of GRE packets rec'd */
	u_int32_t recvOctets;		/* number of GRE octets rec'd */
	u_int32_t recvRunts;		/* too short packets rec'd */
	u_int32_t recvBadGRE;		/* bogus packets rec'd (bad GRE hdr) */
	u_int32_t recvBadAcks;		/* bogus ack's rec'd in GRE header */
	u_int32_t recvBadCID;		/* pkts with unknown call ID rec'd */
	u_int32_t recvOutOfOrder;	/* packets rec'd out of order */
	u_int32_t recvDuplicates;	/* packets rec'd with duplicate seq # */
	u_int32_t recvLoneAcks;		/* ack-only packets rec'd */
	u_int32_t recvAckTimeouts;	/* times peer failed to ack in time */
	u_int32_t memoryFailures;	/* times we couldn't allocate memory */
};

/* Keep this in sync with the above structure definition */
#define NG_PPTPGRE_STATS_TYPE_INFO	{			\
	  { "xmitPackets",	&ng_parse_uint32_type	},	\
	  { "xmitOctets",	&ng_parse_uint32_type	},	\
	  { "xmitLoneAcks",	&ng_parse_uint32_type	},	\
	  { "xmitDrops",	&ng_parse_uint32_type	},	\
	  { "xmitTooBig",	&ng_parse_uint32_type	},	\
	  { "recvPackets",	&ng_parse_uint32_type	},	\
	  { "recvOctets",	&ng_parse_uint32_type	},	\
	  { "recvRunts",	&ng_parse_uint32_type	},	\
	  { "recvBadGRE",	&ng_parse_uint32_type	},	\
	  { "recvBadAcks",	&ng_parse_uint32_type	},	\
	  { "recvBadCID",	&ng_parse_uint32_type	},	\
	  { "recvOutOfOrder",	&ng_parse_uint32_type	},	\
	  { "recvDuplicates",	&ng_parse_uint32_type	},	\
	  { "recvLoneAcks",	&ng_parse_uint32_type	},	\
	  { "recvAckTimeouts",	&ng_parse_uint32_type	},	\
	  { "memoryFailures",	&ng_parse_uint32_type	},	\
	  { NULL }						\
}

/* Netgraph commands */
enum {
	NGM_PPTPGRE_SET_CONFIG = 1,	/* supply a struct ng_pptpgre_conf */
	NGM_PPTPGRE_GET_CONFIG,		/* returns a struct ng_pptpgre_conf */
	NGM_PPTPGRE_GET_STATS,		/* returns struct ng_pptpgre_stats */
	NGM_PPTPGRE_CLR_STATS,		/* clears stats */
	NGM_PPTPGRE_GETCLR_STATS,	/* returns & clears stats */
};

#endif /* _NETGRAPH_NG_PPTPGRE_H_ */


code:
/*-
 * Copyright (c) 2006 Alexander Motin <mav@alkar.net>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice unmodified, this list of conditions, and the following
 *    disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_pred1.h 165619 2006-12-29 09:54:32Z glebius $
 */

#ifndef _NETGRAPH_NG_PRED1_H_
#define _NETGRAPH_NG_PRED1_H_

/* Node type name and magic cookie */
#define NG_PRED1_NODE_TYPE	"pred1"
#define NGM_PRED1_COOKIE	1166902612

/* Hook names */
#define NG_PRED1_HOOK_COMP	"comp"		/* compression hook */
#define NG_PRED1_HOOK_DECOMP	"decomp"	/* decompression hook */

/* Config struct */
struct ng_pred1_config {
	u_char		enable;			/* node enabled */
};

/* Keep this in sync with the above structure definition. */
#define NG_PRED1_CONFIG_INFO	{			\
	{ "enable",	&ng_parse_uint8_type	},	\
	{ NULL }					\
}

/* Statistics structure for one direction. */
struct ng_pred1_stats {
	uint64_t	FramesPlain;
	uint64_t	FramesComp;
	uint64_t	FramesUncomp;
	uint64_t	InOctets;
	uint64_t	OutOctets;
	uint64_t	Errors;
};

/* Keep this in sync with the above structure definition. */
#define NG_PRED1_STATS_INFO	{				\
	{ "FramesPlain",&ng_parse_uint64_type	},	\
	{ "FramesComp",	&ng_parse_uint64_type	},	\
	{ "FramesUncomp", &ng_parse_uint64_type	},	\
	{ "InOctets",	&ng_parse_uint64_type	},	\
	{ "OutOctets",	&ng_parse_uint64_type	},	\
	{ "Errors",	&ng_parse_uint64_type	},	\
	{ NULL }					\
}

/* Netgraph commands */
enum {
	NGM_PRED1_CONFIG = 1,
	NGM_PRED1_RESETREQ,			/* sent either way! */
	NGM_PRED1_GET_STATS,
	NGM_PRED1_CLR_STATS,
	NGM_PRED1_GETCLR_STATS,
};

#endif /* _NETGRAPH_NG_PRED1_H_ */


code:
/*
 * ng_rfc1490.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_rfc1490.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_rfc1490.h,v 1.7 1999/01/20 00:54:15 archie Exp $
 */

#ifndef _NETGRAPH_NG_RFC1490_H_
#define _NETGRAPH_NG_RFC1490_H_

/* Node type name */
#define NG_RFC1490_NODE_TYPE		"rfc1490"
#define NGM_RFC1490_COOKIE		1086947474

/* Hook names */
#define NG_RFC1490_HOOK_DOWNSTREAM	"downstream"
#define NG_RFC1490_HOOK_INET		"inet"
#define NG_RFC1490_HOOK_PPP		"ppp"
#define NG_RFC1490_HOOK_ETHERNET	"ethernet"

/* Netgraph commands */
enum {
	NGM_RFC1490_SET_ENCAP,		/* sets encapsulation method */
	NGM_RFC1490_GET_ENCAP,		/* gets current encapsulation method */
};

#endif /* _NETGRAPH_NG_RFC1490_H_ */


code:
/*
 * ng_sample.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Julian Elischer <julian@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_sample.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_sample.h,v 1.3 1999/01/20 00:22:14 archie Exp $
 */

#ifndef _NETGRAPH_NG_SAMPLE_H_
#define _NETGRAPH_NG_SAMPLE_H_

/* Node type name. This should be unique among all netgraph node types */
#define NG_XXX_NODE_TYPE	"sample"

/* Node type cookie. Should also be unique. This value MUST change whenever
   an incompatible change is made to this header file, to insure consistency.
   The de facto method for generating cookies is to take the output of the
   date command: date -u +'%s' */
#define NGM_XXX_COOKIE		915491374

/* Number of active DLCI's we can handle */
#define	XXX_NUM_DLCIS		16

/* Hook names */
#define NG_XXX_HOOK_DLCI_LEADIN	"dlci"
#define NG_XXX_HOOK_DOWNSTREAM	"downstream"
#define NG_XXX_HOOK_DEBUG	"debug"

/* Netgraph commands understood by this node type */
enum {
	NGM_XXX_SET_FLAG = 1,
	NGM_XXX_GET_STATUS,
};

/* This structure is returned by the NGM_XXX_GET_STATUS command */
struct ngxxxstat {
	u_int32_t   packets_in;		/* packets in from downstream */
	u_int32_t   packets_out;	/* packets out towards downstream */
};

/*
 * This is used to define the 'parse type' for a struct ngxxxstat, which
 * is bascially a description of how to convert a binary struct ngxxxstat
 * to an ASCII string and back.  See ng_parse.h for more info.
 *
 * This needs to be kept in sync with the above structure definition
 */
#define NG_XXX_STATS_TYPE_INFO	{				\
	  { "packets_in",	&ng_parse_uint32_type	},	\
	  { "packets_out",	&ng_parse_uint32_type	},	\
	  { NULL }						\
}

#endif /* _NETGRAPH_NG_SAMPLE_H_ */


code:
/*
 * ng_socket.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Julian Elischer <julian@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_socket.h 163462 2006-10-17 11:03:55Z glebius $
 * $Whistle: ng_socket.h,v 1.5 1999/01/20 00:22:14 archie Exp $
 */

#ifndef _NETGRAPH_NG_SOCKET_H_
#define _NETGRAPH_NG_SOCKET_H_

/* Netgraph node type name and cookie */
#define	NG_SOCKET_NODE_TYPE	"socket"
#define	NGM_SOCKET_COOKIE	851601233

/* Netgraph socket(2) constants */
#define	NG_DATA			1
#define	NG_CONTROL		2

/* Commands */
enum {
	NGM_SOCK_CMD_NOLINGER = 1,	/* close the socket with last hook */
	NGM_SOCK_CMD_LINGER		/* Keep socket even if 0 hooks */
};

/* Netgraph version of struct sockaddr */
struct sockaddr_ng {
	unsigned char	sg_len;		/* total length */
	sa_family_t	sg_family;	/* address family */
	char		sg_data[14];	/* actually longer; address value */
};

#endif /* _NETGRAPH_NG_SOCKET_H_ */


code:
/*
 * netgraph.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Julian Elischer <julian@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_socketvar.h 205083 2010-03-12 15:04:59Z glebius $
 * $Whistle: ng_socketvar.h,v 1.1 1999/01/20 21:35:39 archie Exp $
 */

#ifndef _NETGRAPH_NG_SOCKETVAR_H_
#define _NETGRAPH_NG_SOCKETVAR_H_

/* Netgraph protocol control block for each socket */
struct ngpcb {
	struct socket	 *ng_socket;	/* the socket */
	struct ngsock	 *sockdata;	/* netgraph info */
	LIST_ENTRY(ngpcb) socks;	/* linked list of sockets */
	int		  type;		/* NG_CONTROL or NG_DATA */
};

/* Per-node private data */
struct ngsock {
	struct ng_node	*node;		/* the associated netgraph node */
	struct ngpcb	*datasock;	/* optional data socket */
	struct ngpcb	*ctlsock;	/* optional control socket */
	int    flags;
	int    refs;
	struct mtx	mtx;		/* mtx to wait on */
	int		error;		/* place to store error */
	ng_ID_t		node_id;	/* a hint for netstat(1) to find the node */
};
#define	NGS_FLAG_NOLINGER	1	/* close with last hook */

#endif /* _NETGRAPH_NG_SOCKETVAR_H_ */


code:
/*
 * ng_source.h
 */

/*-
 * Copyright 2002 Sandvine Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Sandvine Inc.; provided,
 * however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Sandvine Inc.
 *    trademarks, including the mark "SANDVINE" on advertising, endorsements,
 *    or otherwise except as such appears in the above copyright notice or in
 *    the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY SANDVINE "AS IS", AND TO THE MAXIMUM
 * EXTENT PERMITTED BY LAW, SANDVINE MAKES NO REPRESENTATIONS OR WARRANTIES,
 * EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, INCLUDING WITHOUT LIMITATION,
 * ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT.  SANDVINE DOES NOT WARRANT, GUARANTEE, OR
 * MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE
 * USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY
 * OR OTHERWISE.  IN NO EVENT SHALL SANDVINE BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF SANDVINE IS ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
 * Author: Dave Chapeskie
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_source.h 209730 2010-07-06 16:55:39Z emaste $
 */

#ifndef _NETGRAPH_NG_SOURCE_H_
#define _NETGRAPH_NG_SOURCE_H_

/* Node type name and magic cookie */
#define NG_SOURCE_NODE_TYPE	"source"
#define NGM_SOURCE_COOKIE	1110646684

/* Hook names */
#define NG_SOURCE_HOOK_INPUT	"input"
#define NG_SOURCE_HOOK_OUTPUT	"output"

/* Statistics structure returned by NGM_SOURCE_GET_STATS */
struct ng_source_stats {
	uint64_t	outOctets;
	uint64_t	outFrames;
	uint32_t	queueOctets;
	uint32_t	queueFrames;
	uint32_t	maxPps;
	struct timeval	startTime;
	struct timeval	endTime;
	struct timeval	elapsedTime;
	struct timeval	lastTime;
};

extern const struct ng_parse_type ng_source_timeval_type;
/* Keep this in sync with the above structure definition */
#define NG_SOURCE_STATS_TYPE_INFO	{			\
	  { "outOctets",	&ng_parse_uint64_type	},	\
	  { "outFrames",	&ng_parse_uint64_type	},	\
	  { "queueOctets",	&ng_parse_uint32_type	},	\
	  { "queueFrames",	&ng_parse_uint32_type	},	\
	  { "maxPps",		&ng_parse_uint32_type	},	\
	  { "startTime",	&ng_source_timeval_type },	\
	  { "endTime",		&ng_source_timeval_type },	\
	  { "elapsedTime",	&ng_source_timeval_type },	\
	  { "lastTime",		&ng_source_timeval_type },	\
	  { NULL }						\
}

/* Packet embedding info for NGM_SOURCE_GET/SET_TIMESTAMP */
struct ng_source_embed_info {
	uint16_t	offset;		/* offset from ethernet header */
	uint8_t		flags;
	uint8_t		spare;
};
#define NGM_SOURCE_EMBED_ENABLE		0x01	/* enable embedding */
#define	NGM_SOURCE_INC_CNT_PER_LIST	0x02	/* increment once per list */

/* Keep this in sync with the above structure definition. */
#define NG_SOURCE_EMBED_TYPE_INFO {				\
	{ "offset",		&ng_parse_hint16_type	},	\
	{ "flags",		&ng_parse_hint8_type	},	\
	{ NULL }						\
}

/* Packet embedding info for NGM_SOURCE_GET/SET_COUNTER */
#define	NG_SOURCE_COUNTERS	4
struct ng_source_embed_cnt_info {
	uint16_t	offset;		/* offset from ethernet header */
	uint8_t		flags;		/* as above */
	uint8_t		width;		/* in bytes (1, 2, 4) */
	uint32_t	next_val;
	uint32_t	min_val;
	uint32_t	max_val;
	int32_t		increment;
	uint8_t		index;		/* which counter (0..3) */
};

/* Keep this in sync with the above structure definition. */
#define NG_SOURCE_EMBED_CNT_TYPE_INFO {				\
	{ "offset",		&ng_parse_hint16_type	}, 	\
	{ "flags",		&ng_parse_hint8_type	},	\
	{ "width",		&ng_parse_uint8_type	},	\
	{ "next_val",		&ng_parse_uint32_type	},	\
	{ "min_val",		&ng_parse_uint32_type	},	\
	{ "max_val",		&ng_parse_uint32_type	},	\
	{ "increment",		&ng_parse_int32_type	},	\
	{ "index",		&ng_parse_uint8_type	},	\
	{ NULL }						\
}

/* Netgraph commands */
enum {
	NGM_SOURCE_GET_STATS = 1,	/* get stats */
	NGM_SOURCE_CLR_STATS,		/* clear stats */
	NGM_SOURCE_GETCLR_STATS,	/* atomically get and clear stats */
	NGM_SOURCE_START,		/* start sending queued data */
	NGM_SOURCE_STOP,		/* stop sending queued data */
	NGM_SOURCE_CLR_DATA,		/* clear the queued data */
	NGM_SOURCE_SETIFACE,		/* configure downstream iface */
	NGM_SOURCE_SETPPS,		/* rate-limiting packets per second */
	NGM_SOURCE_SET_TIMESTAMP,	/* embed xmit timestamp */
	NGM_SOURCE_GET_TIMESTAMP,
	NGM_SOURCE_SET_COUNTER,		/* embed counter */
	NGM_SOURCE_GET_COUNTER,
};

#endif /* _NETGRAPH_NG_SOURCE_H_ */


code:
/*-
 *
 * Copyright (c) 1999-2000, Vitaly V Belekhov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice unmodified, this list of conditions, and the following
 *    disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_split.h 151676 2005-10-25 20:56:12Z ru $
 *
 */

#ifndef _NETGRAPH_NG_SPLIT_H_
#define _NETGRAPH_NG_SPLIT_H_

/* Node type name and magic cookie */
#define NG_SPLIT_NODE_TYPE	"split"
#define NGM_SPLIT_COOKIE	949409402

/* My hook names */
#define NG_SPLIT_HOOK_MIXED	"mixed"	/* Mixed stream (in/out) */
#define NG_SPLIT_HOOK_OUT	"out"	/* Output to outhook (sending out) */
#define NG_SPLIT_HOOK_IN	"in"	/* Input from inhook (recieving) */

#endif /* _NETGRAPH_NG_SPLIT_H_ */


code:
/*
 * ng_sppp.h Netgraph to Sppp module.
 */

/*-
 * Copyright (C) 2002-2004 Cronyx Engineering.
 * Copyright (C) 2002-2004 Roman Kurakin <rik@cronyx.ru>
 *
 * This software is distributed with NO WARRANTIES, not even the implied
 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Authors grant any other persons or organisations a permission to use,
 * modify and redistribute this software in source and binary forms,
 * as long as this message is kept with the software, all derivative
 * works or modified versions.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_sppp.h 141197 2005-02-03 13:03:31Z ru $
 * Cronyx Id: ng_sppp.h,v 1.1.2.6 2004/03/01 15:17:21 rik Exp $
 */

#ifndef _NETGRAPH_SPPP_H_
#define _NETGRAPH_SPPP_H_

/* Node type name and magic cookie */
#define NG_SPPP_NODE_TYPE		"sppp"
#define NGM_SPPP_COOKIE			1040804655

/* Interface base name */
#define NG_SPPP_IFACE_NAME		"sppp"

/* My hook names */
#define NG_SPPP_HOOK_DOWNSTREAM		"downstream"

/* Netgraph commands */
enum {
	NGM_SPPP_GET_IFNAME = 1,	/* returns struct ng_sppp_ifname */
};

#endif /* _NETGRAPH_SPPP_H_ */


code:
/*-
 * Copyright (c) 2006 Vadim Goncharov <vadimnuclight@tpu.ru>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice unmodified, this list of conditions, and the following
 *    disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_tag.h 159979 2006-06-27 12:45:28Z glebius $
 */

#ifndef _NETGRAPH_NG_TAG_H_
#define _NETGRAPH_NG_TAG_H_

/* Node type name and magic cookie. */
#define NG_TAG_NODE_TYPE	"tag"
#define NGM_TAG_COOKIE		1149771193

/*
 * The types of tag_cookie, tag_len and tag_id in structures below
 * must be the same as corresponding members m_tag_cookie, m_tag_len
 * and m_tag_id in struct m_tag (defined in <sys/mbuf.h>).
 */

/* Tag match structure for every (input) hook. */
struct ng_tag_hookin {
	char		thisHook[NG_HOOKSIZ];		/* name of hook */
	char		ifMatch[NG_HOOKSIZ];		/* match dest hook */
	char		ifNotMatch[NG_HOOKSIZ];		/* !match dest hook */
	uint8_t		strip;				/* strip tag if found */
	uint32_t	tag_cookie;			/* ABI/Module ID */
	uint16_t	tag_id;				/* tag ID */
	uint16_t	tag_len;			/* length of data */
	uint8_t		tag_data[0];			/* tag data */
};

/* Tag set structure for every (output) hook. */
struct ng_tag_hookout {
	char		thisHook[NG_HOOKSIZ];		/* name of hook */
	uint32_t	tag_cookie;			/* ABI/Module ID */
	uint16_t	tag_id;				/* tag ID */
	uint16_t	tag_len;			/* length of data */
	uint8_t		tag_data[0];			/* tag data */
};

#define NG_TAG_HOOKIN_SIZE(taglen)	\
	(sizeof(struct ng_tag_hookin) + (taglen))

#define NG_TAG_HOOKOUT_SIZE(taglen)	\
	(sizeof(struct ng_tag_hookout) + (taglen))

/* Keep this in sync with the above structures definitions. */
#define NG_TAG_HOOKIN_TYPE_INFO(tdtype)	{		\
	  { "thisHook",		&ng_parse_hookbuf_type	},	\
	  { "ifMatch",		&ng_parse_hookbuf_type	},	\
	  { "ifNotMatch",	&ng_parse_hookbuf_type	},	\
	  { "strip",		&ng_parse_uint8_type	},	\
	  { "tag_cookie",	&ng_parse_uint32_type	},	\
	  { "tag_id",		&ng_parse_uint16_type	},	\
	  { "tag_len",		&ng_parse_uint16_type	},	\
	  { "tag_data",		(tdtype)		},	\
	  { NULL }						\
}

#define NG_TAG_HOOKOUT_TYPE_INFO(tdtype)	{		\
	  { "thisHook",		&ng_parse_hookbuf_type	},	\
	  { "tag_cookie",	&ng_parse_uint32_type	},	\
	  { "tag_id",		&ng_parse_uint16_type	},	\
	  { "tag_len",		&ng_parse_uint16_type	},	\
	  { "tag_data",		(tdtype)		},	\
	  { NULL }						\
}

#ifdef NG_TAG_DEBUG

/* Statistics structure for one hook. */
struct ng_tag_hookstat {
	uint64_t	recvFrames;
	uint64_t	recvOctets;
	uint64_t	recvMatchFrames;
	uint64_t	recvMatchOctets;
	uint64_t	xmitFrames;
	uint64_t	xmitOctets;
};

/* Keep this in sync with the above structure definition. */
#define NG_TAG_HOOKSTAT_TYPE_INFO	{			\
	  { "recvFrames",	&ng_parse_uint64_type	},	\
	  { "recvOctets",	&ng_parse_uint64_type	},	\
	  { "recvMatchFrames",	&ng_parse_uint64_type	},	\
	  { "recvMatchOctets",	&ng_parse_uint64_type	},	\
	  { "xmitFrames",	&ng_parse_uint64_type	},	\
	  { "xmitOctets",	&ng_parse_uint64_type	},	\
	  { NULL }						\
}

#endif /* NG_TAG_DEBUG */

/* Netgraph commands. */
enum {
	NGM_TAG_SET_HOOKIN = 1,		/* supply a struct ng_tag_hookin */
	NGM_TAG_GET_HOOKIN,		/* returns a struct ng_tag_hookin */
	NGM_TAG_SET_HOOKOUT,		/* supply a struct ng_tag_hookout */
	NGM_TAG_GET_HOOKOUT,		/* returns a struct ng_tag_hookout */
#ifdef NG_TAG_DEBUG
	NGM_TAG_GET_STATS,		/* supply name as char[NG_HOOKSIZ] */
	NGM_TAG_CLR_STATS,		/* supply name as char[NG_HOOKSIZ] */
	NGM_TAG_GETCLR_STATS,		/* supply name as char[NG_HOOKSIZ] */
#endif
};

#endif /* _NETGRAPH_NG_TAG_H_ */


code:
/*-
 * ng_tcpmss.h
 *
 * Copyright (c) 2004, Alexey Popov <lollypop@flexuser.ru>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice unmodified, this list of conditions, and the following
 *    disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_tcpmss.h 147231 2005-06-10 08:02:34Z glebius $
 */

#ifndef _NETGRAPH_TCPMSS_H_
#define _NETGRAPH_TCPMSS_H_

/* Node type name and magic cookie */
#define NG_TCPMSS_NODE_TYPE	"tcpmss"
#define NGM_TCPMSS_COOKIE	1097623478

/* Statistics structure for one hook. */
struct ng_tcpmss_hookstat {
	uint64_t	Octets;
	uint64_t	Packets;
	uint16_t	maxMSS;
	uint64_t	SYNPkts;
	uint64_t	FixedPkts;
};

/* Keep this in sync with the above structure definition. */
#define NG_TCPMSS_HOOKSTAT_INFO	{			\
	{ "Octets",	&ng_parse_uint64_type	},	\
	{ "Packets",	&ng_parse_uint64_type	},	\
	{ "maxMSS",	&ng_parse_uint16_type	},	\
	{ "SYNPkts",	&ng_parse_uint64_type	},	\
	{ "FixedPkts",	&ng_parse_uint64_type	},	\
	{ NULL }					\
}

/* Structure for NGM_TCPMSS_CONFIG. */
struct ng_tcpmss_config {
	char		inHook[NG_HOOKSIZ];
	char		outHook[NG_HOOKSIZ];
	uint16_t	maxMSS;
};

/* Keep this in sync with the above structure definition. */
#define NG_TCPMSS_CONFIG_INFO {				\
	{ "inHook",	&ng_parse_hookbuf_type	},	\
	{ "outHook",	&ng_parse_hookbuf_type	},	\
	{ "maxMSS",	&ng_parse_uint16_type	},	\
	{ NULL }					\
}

/* Netgraph commands */
enum {
	NGM_TCPMSS_GET_STATS = 1,	/* Get stats. */
	NGM_TCPMSS_CLR_STATS,		/* Clear stats. */
	NGM_TCPMSS_GETCLR_STATS,	/* "Atomically" get and clear stats. */
	NGM_TCPMSS_CONFIG		/* Set configuration. */
};

#endif /* _NETGRAPH_TCPMSS_H_ */


code:
/*
 * ng_tee.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_tee.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_tee.h,v 1.2 1999/01/20 00:22:14 archie Exp $
 */

#ifndef _NETGRAPH_NG_TEE_H_
#define _NETGRAPH_NG_TEE_H_

/* Node type name and magic cookie */
#define NG_TEE_NODE_TYPE	"tee"
#define NGM_TEE_COOKIE		916107047

/* Hook names */
#define NG_TEE_HOOK_RIGHT	"right"
#define NG_TEE_HOOK_LEFT	"left"
#define NG_TEE_HOOK_RIGHT2LEFT	"right2left"
#define NG_TEE_HOOK_LEFT2RIGHT	"left2right"

/* Statistics structure for one hook */
struct ng_tee_hookstat {
	u_int64_t	inOctets;
	u_int64_t	inFrames;
	u_int64_t	outOctets;
	u_int64_t	outFrames;
};

/* Keep this in sync with the above structure definition */
#define NG_TEE_HOOKSTAT_INFO	{				\
	  { "inOctets",		&ng_parse_uint64_type	},	\
	  { "inFrames",		&ng_parse_uint64_type	},	\
	  { "outOctets",	&ng_parse_uint64_type	},	\
	  { "outFrames",	&ng_parse_uint64_type	},	\
	  { NULL }						\
}

/* Statistics structure returned by NGM_TEE_GET_STATS */
struct ng_tee_stats {
	struct ng_tee_hookstat	right;
	struct ng_tee_hookstat	left;
	struct ng_tee_hookstat	right2left;
	struct ng_tee_hookstat	left2right;
};

/* Keep this in sync with the above structure definition */
#define NG_TEE_STATS_INFO(hstype)	{			\
	  { "right",		(hstype)		},	\
	  { "left",		(hstype)		},	\
	  { "right2left",	(hstype)		},	\
	  { "left2right",	(hstype)		},	\
	  { NULL }						\
}

/* Netgraph commands */
enum {
	NGM_TEE_GET_STATS = 1,		/* get stats */
	NGM_TEE_CLR_STATS,		/* clear stats */
	NGM_TEE_GETCLR_STATS,		/* atomically get and clear stats */
};

#endif /* _NETGRAPH_NG_TEE_H_ */


code:
/*
 * ng_tty.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_tty.h 184760 2008-11-08 02:05:41Z mav $
 * $Whistle: ng_tty.h,v 1.7 1999/01/20 00:22:15 archie Exp $
 */

#ifndef _NETGRAPH_NG_TTY_H_
#define _NETGRAPH_NG_TTY_H_

/* Node type name and magic cookie */
#define NG_TTY_NODE_TYPE	"tty"
#define NGM_TTY_COOKIE		1226109660

/* Default hot char */
#define NG_TTY_DFL_HOTCHAR	0x7e	/* PPP flag byte */

/* Hook names */
#define NG_TTY_HOOK		"hook"

/* Netgraph commands */
enum {
	NGM_TTY_GET_HOTCHAR = 1,
	NGM_TTY_SET_HOTCHAR,
	NGM_TTY_SET_TTY,
};

#endif /* _NETGRAPH_NG_TTY_H_ */


code:
/*
 * ng_vjc.h
 */

/*-
 * Copyright (c) 1996-1999 Whistle Communications, Inc.
 * All rights reserved.
 *
 * Subject to the following obligations and disclaimer of warranty, use and
 * redistribution of this software, in source or object code forms, with or
 * without modifications are expressly permitted by Whistle Communications;
 * provided, however, that:
 * 1. Any and all reproductions of the source or object code must include the
 *    copyright notice above and the following disclaimer of warranties; and
 * 2. No rights are granted, in any manner or form, to use Whistle
 *    Communications, Inc. trademarks, including the mark "WHISTLE
 *    COMMUNICATIONS" on advertising, endorsements, or otherwise except as
 *    such appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_vjc.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_vjc.h,v 1.6 1999/01/25 02:40:22 archie Exp $
 */

#ifndef _NETGRAPH_NG_VJC_H_
#define _NETGRAPH_NG_VJC_H_

 /* Node type name and magic cookie */
#define NG_VJC_NODE_TYPE	"vjc"
#define NGM_VJC_COOKIE		868219210

 /* Hook names */
#define NG_VJC_HOOK_IP		"ip"		/* normal IP traffic */
#define NG_VJC_HOOK_VJCOMP	"vjcomp"	/* compressed TCP */
#define NG_VJC_HOOK_VJUNCOMP	"vjuncomp"	/* uncompressed TCP */
#define NG_VJC_HOOK_VJIP	"vjip"		/* uncompressed IP */

 /* Minimum and maximum number of compression channels */
#define NG_VJC_MIN_CHANNELS	4
#define NG_VJC_MAX_CHANNELS	16

 /* Configure struct */
struct ngm_vjc_config {
	u_char	enableComp;	/* Enable compression */
	u_char	enableDecomp;	/* Enable decompression */
	u_char	maxChannel;	/* Number of compression channels - 1 */
	u_char	compressCID;	/* OK to compress outgoing CID's */
};

/* Keep this in sync with the above structure definition */
#define NG_VJC_CONFIG_TYPE_INFO	{				\
	  { "enableComp",	&ng_parse_uint8_type	},	\
	  { "enableDecomp",	&ng_parse_uint8_type	},	\
	  { "maxChannel",	&ng_parse_uint8_type	},	\
	  { "compressCID",	&ng_parse_uint8_type	},	\
	  { NULL }						\
}

 /* Netgraph commands */
enum {
	NGM_VJC_SET_CONFIG,	/* Supply a struct ngm_vjc_config */
	NGM_VJC_GET_CONFIG,	/* Returns a struct ngm_vjc_config */
	NGM_VJC_GET_STATE,	/* Returns current struct slcompress */
	NGM_VJC_CLR_STATS,	/* Clears statistics counters */
	NGM_VJC_RECV_ERROR,	/* Indicate loss of incoming frame */
};

#endif /* _NETGRAPH_NG_VJC_H_ */


code:
/*-
 * Copyright (c) 2003 IPNET Internet Communication Company
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * Author: Ruslan Ermilov <ru@FreeBSD.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_vlan.h 151800 2005-10-28 14:41:28Z ru $
 */

#ifndef _NETGRAPH_NG_VLAN_H_
#define	_NETGRAPH_NG_VLAN_H_

/* Node type name and magic cookie. */
#define	NG_VLAN_NODE_TYPE	"vlan"
#define	NGM_VLAN_COOKIE		1068486472

/* Hook names. */
#define	NG_VLAN_HOOK_DOWNSTREAM	"downstream"
#define	NG_VLAN_HOOK_NOMATCH	"nomatch"

/* Netgraph commands. */
enum {
	NGM_VLAN_ADD_FILTER = 1,
	NGM_VLAN_DEL_FILTER,
	NGM_VLAN_GET_TABLE
};

/* For NGM_VLAN_ADD_FILTER control message. */
struct ng_vlan_filter {
	char		hook[NG_HOOKSIZ];
	u_int16_t	vlan;
};

/* Keep this in sync with the above structure definition.  */
#define	NG_VLAN_FILTER_FIELDS	{				\
	{ "hook",	&ng_parse_hookbuf_type  },		\
	{ "vlan",	&ng_parse_uint16_type   },		\
	{ NULL }						\
}

/* Structure returned by NGM_VLAN_GET_TABLE. */
struct ng_vlan_table {
	u_int32_t	n;
	struct ng_vlan_filter filter[];
};

/* Keep this in sync with the above structure definition. */
#define	NG_VLAN_TABLE_FIELDS	{				\
	{ "n",		&ng_parse_uint32_type },		\
	{ "filter",	&ng_vlan_table_array_type },		\
	{ NULL }						\
}

#endif /* _NETGRAPH_NG_VLAN_H_ */