code:
/*-
 * Copyright (c) 2005 Nuno Antunes <nuno.antunes@gmail.com>
 * Copyright (c) 2007 Alexander Motin <mav@freebsd.org>
 * 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 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 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_car.h 174795 2007-12-19 22:50:14Z mav $
 */

#ifndef _NETGRAPH_NG_CAR_H_
#define _NETGRAPH_NG_CAR_H_

#define NG_CAR_NODE_TYPE	"car"
#define NGM_CAR_COOKIE		1173648034

/* Hook names */
#define NG_CAR_HOOK_UPPER	"upper"
#define NG_CAR_HOOK_LOWER	"lower"

/* Per hook statistics counters */
struct ng_car_hookstats {
	u_int64_t passed_pkts;	/* Counter for passed packets */
	u_int64_t droped_pkts;	/* Counter for droped packets */
	u_int64_t green_pkts;	/* Counter for green packets */
	u_int64_t yellow_pkts;	/* Counter for yellow packets */
	u_int64_t red_pkts;	/* Counter for red packets */
	u_int64_t errors;	/* Counter for operation errors */
};
#define NG_CAR_HOOKSTATS	{				\
	  { "passed",		&ng_parse_uint64_type	},	\
	  { "droped",		&ng_parse_uint64_type	},	\
	  { "green",		&ng_parse_uint64_type	},	\
	  { "yellow",		&ng_parse_uint64_type	},	\
	  { "red",		&ng_parse_uint64_type	},	\
	  { "errors",		&ng_parse_uint64_type	},	\
	  { NULL }						\
}

/* Bulk statistics */
struct ng_car_bulkstats {
	struct ng_car_hookstats upstream;
	struct ng_car_hookstats downstream;
};
#define NG_CAR_BULKSTATS(hstatstype) {				\
	  { "upstream",		(hstatstype)		},	\
	  { "downstream",	(hstatstype)		},	\
	  { NULL }						\
}

/* Per hook configuration */
struct ng_car_hookconf {
	u_int64_t cbs;		/* Commited burst size (bytes) */
	u_int64_t ebs;		/* Exceeded/Peak burst size (bytes) */
	u_int64_t cir;		/* Commited information rate (bits/s) */
	u_int64_t pir;		/* Peak information rate (bits/s) */
	u_int8_t green_action;	/* Action for green packets */
	u_int8_t yellow_action;	/* Action for yellow packets */
	u_int8_t red_action;	/* Action for red packets */
	u_int8_t mode;		/* single/double rate, ... */
	u_int8_t opt;		/* color-aware or color-blind */
};
/* Keep this definition in sync with the above structure */
#define NG_CAR_HOOKCONF	{					\
	  { "cbs",		&ng_parse_uint64_type	},	\
	  { "ebs",		&ng_parse_uint64_type	},	\
	  { "cir",		&ng_parse_uint64_type	},	\
	  { "pir",		&ng_parse_uint64_type	},	\
	  { "greenAction",	&ng_parse_uint8_type	},	\
	  { "yellowAction",	&ng_parse_uint8_type	},	\
	  { "redAction",	&ng_parse_uint8_type	},	\
	  { "mode",		&ng_parse_uint8_type	},	\
	  { "opt",		&ng_parse_uint8_type	},	\
	  { NULL }						\
}

#define NG_CAR_CBS_MIN		8192
#define NG_CAR_EBS_MIN		8192
#define NG_CAR_CIR_DFLT		10240

/* possible actions (...Action) */
enum {
    NG_CAR_ACTION_FORWARD = 1,
    NG_CAR_ACTION_DROP,
    NG_CAR_ACTION_MARK,
    NG_CAR_ACTION_SET_TOS
};

/* operation modes (mode) */
enum {
    NG_CAR_SINGLE_RATE = 0,
    NG_CAR_DOUBLE_RATE,
    NG_CAR_RED,
    NG_CAR_SHAPE
};

/* mode options (opt) */
#define NG_CAR_COLOR_AWARE	1
#define NG_CAR_COUNT_PACKETS	2

/* Bulk config */
struct ng_car_bulkconf {
	struct ng_car_hookconf upstream;
	struct ng_car_hookconf downstream;
};
#define NG_CAR_BULKCONF(hconftype) {				\
	  { "upstream",		(hconftype)		},	\
	  { "downstream",	(hconftype)		},	\
	  { NULL }						\
}

/* Commands */
enum {
	NGM_CAR_GET_STATS = 1,		/* Get statistics */
	NGM_CAR_CLR_STATS,		/* Clear statistics */
	NGM_CAR_GETCLR_STATS,		/* Get and clear statistics */
	NGM_CAR_GET_CONF,		/* Get bulk configuration */
	NGM_CAR_SET_CONF,		/* Set bulk configuration */
};

#endif /* _NETGRAPH_NG_CAR_H_ */


code:
/*
 * ng_cisco.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_cisco.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_cisco.h,v 1.6 1999/01/25 01:21:48 archie Exp $
 */

#ifndef _NETGRAPH_NG_CISCO_H_
#define _NETGRAPH_NG_CISCO_H_

/* Node type name and magic cookie */
#define NG_CISCO_NODE_TYPE		"cisco"
#define NGM_CISCO_COOKIE		860707227

/* Hook names */
#define NG_CISCO_HOOK_DOWNSTREAM	"downstream"
#define NG_CISCO_HOOK_INET		"inet"
#define NG_CISCO_HOOK_INET6		"inet6"
#define NG_CISCO_HOOK_APPLETALK		"atalk"
#define NG_CISCO_HOOK_IPX		"ipx"
#define NG_CISCO_HOOK_DEBUG		"debug"

/* Netgraph commands */
enum {
	NGM_CISCO_SET_IPADDR = 1,	/* requires a struct ng_cisco_ipaddr */
	NGM_CISCO_GET_IPADDR,		/* returns a struct ng_cisco_ipaddr */
	NGM_CISCO_GET_STATUS,		/* returns a struct ng_cisco_stat */
};

struct ng_cisco_ipaddr {
	struct in_addr	ipaddr;		/* IP address */
	struct in_addr	netmask;	/* Netmask */
};

/* Keep this in sync with the above structure definition */
#define NG_CISCO_IPADDR_TYPE_INFO	{			\
	  { "ipaddr",		&ng_parse_ipaddr_type	},	\
	  { "netmask",		&ng_parse_ipaddr_type	},	\
	  { NULL }						\
}

struct ng_cisco_stats {
	u_int32_t   seqRetries;		/* # unack'd retries */
	u_int32_t   keepAlivePeriod;	/* in seconds */
};

/* Keep this in sync with the above structure definition */
#define NG_CISCO_STATS_TYPE_INFO	{			\
	  { "seqRetries",	&ng_parse_uint32_type	},	\
	  { "keepAlivePeriod",	&ng_parse_uint32_type	},	\
	  { NULL }						\
}

#endif /* _NETGRAPH_NG_CISCO_H_ */

repo_name: veiledmerc/mira

license: mit


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_deflate.h 165581 2006-12-28 15:44:05Z glebius $
 */

#ifndef _NETGRAPH_NG_DEFLATE_H_
#define _NETGRAPH_NG_DEFLATE_H_

/* Node type name and magic cookie */
#define NG_DEFLATE_NODE_TYPE	"deflate"
#define NGM_DEFLATE_COOKIE	1166642656

/* Hook names */
#define NG_DEFLATE_HOOK_COMP	"comp"		/* compression hook */
#define NG_DEFLATE_HOOK_DECOMP	"decomp"	/* decompression hook */

/* Config struct */
struct ng_deflate_config {
	u_char		enable;			/* node enabled */
	u_char		windowBits;		/* log2(Window size) */
};

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

/* Statistics structure for one direction. */
struct ng_deflate_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_DEFLATE_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_DEFLATE_CONFIG = 1,
	NGM_DEFLATE_RESETREQ,			/* sent either way! */
	NGM_DEFLATE_GET_STATS,
	NGM_DEFLATE_CLR_STATS,
	NGM_DEFLATE_GETCLR_STATS,
};

#endif /* _NETGRAPH_NG_DEFLATE_H_ */


code:
/*-
 * Copyright (c) 2002 Mark Santcroos <marks@ripe.net>
 *
 * 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 ``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 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_device.h 139823 2005-01-07 01:45:51Z imp $
 *
 */

#ifndef _NETGRAPH_NG_DEVICE_H_
#define _NETGRAPH_NG_DEVICE_H_

/* Node type name and magic cookie */
#define NG_DEVICE_NODE_TYPE	"device"
#define NGM_DEVICE_COOKIE	1091129178
#define	NG_DEVICE_DEVNAME	"ngd"

/* Netgraph control messages */
enum {
	NGM_DEVICE_GET_DEVNAME,
};

#if 0
/* passing ioctl params */
struct ngd_param_s {
	        void * p;
};
#endif

#endif /* _NETGRAPH_NG_DEVICE_H_ */


code:
/*
 * ng_echo.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_echo.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_echo.h,v 1.3 1999/01/20 00:22:12 archie Exp $
 */

#ifndef _NETGRAPH_NG_ECHO_H_
#define _NETGRAPH_NG_ECHO_H_

/* Node type name and magic cookie */
#define NG_ECHO_NODE_TYPE	"echo"
#define NGM_ECHO_COOKIE		884298942

#endif /* _NETGRAPH_NG_ECHO_H_ */


code:
/*
 * ng_eiface.h
 */

/*-
 * Copyright (c) 1999-2001, 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_eiface.h 215673 2010-11-22 12:32:19Z zec $
 */

#ifndef _NETGRAPH_NG_EIFACE_H_
#define _NETGRAPH_NG_EIFACE_H_

/* Node type name and magic cookie */
#define NG_EIFACE_NODE_TYPE		"eiface"
#define NGM_EIFACE_COOKIE		948105892

/* Interface base name */
#define NG_EIFACE_EIFACE_NAME		"ngeth"

/* My hook names */
#define NG_EIFACE_HOOK_ETHER		"ether"

/* MTU bounds */
#define NG_EIFACE_MTU_MIN		72
#define NG_EIFACE_MTU_MAX		ETHER_MAX_LEN_JUMBO
#define NG_EIFACE_MTU_DEFAULT		1500

/* Netgraph commands */
enum {
	NGM_EIFACE_GET_IFNAME = 1,	/* get the interface name */
	NGM_EIFACE_GET_IFADDRS,		/* returns list of addresses */
	NGM_EIFACE_SET,			/* set ethernet address */
};

#endif /* _NETGRAPH_NG_EIFACE_H_ */


code:
/*-
 * ng_etf.h
 */

/*-
 * Copyright (c) 2001, FreeBSD Incorporated
 * 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.
 *
 * Author: Julian Elischer <julian@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_etf.h 139823 2005-01-07 01:45:51Z imp $
 */

#ifndef _NETGRAPH_NG_ETF_H_
#define _NETGRAPH_NG_ETF_H_

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

/* 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_ETF_COOKIE		983084516

/* Hook names */
#define NG_ETF_HOOK_DOWNSTREAM	"downstream"
#define NG_ETF_HOOK_NOMATCH	"nomatch"

/* Netgraph commands understood by this node type */
enum {
	NGM_ETF_SET_FLAG = 1,
	NGM_ETF_GET_STATUS,
	NGM_ETF_SET_FILTER,

};

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

/*
 * This needs to be kept in sync with the above structure definition
 */
#define NG_ETF_STATS_TYPE_INFO	{				\
	  { "packets_in",	&ng_parse_uint32_type	},	\
	  { "packets_out",	&ng_parse_uint32_type	},	\
	  { NULL }						\
}

/* This structure is returned by the NGM_ETF_GET_STATUS command */
struct ng_etffilter {
	char		matchhook[NG_HOOKSIZ]; /* hook name */
	u_int16_t	ethertype;	/* this ethertype to this hook */
};

/*
 * This needs to be kept in sync with the above structure definition
 */
#define NG_ETF_FILTER_TYPE_INFO	{				\
          { "matchhook",	&ng_parse_hookbuf_type  },	\
	  { "ethertype",	&ng_parse_uint16_type   },	\
	  { NULL }						\
}

#endif /* _NETGRAPH_NG_ETF_H_ */


code:
/*
 * ng_ether.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_ether.h 141910 2005-02-14 12:01:09Z glebius $
 * $Whistle: ng_ether.h,v 1.1 1999/02/02 03:17:22 julian Exp $
 */

#ifndef _NETGRAPH_NG_ETHER_H_
#define _NETGRAPH_NG_ETHER_H_

/* Node type name and magic cookie */
#define NG_ETHER_NODE_TYPE	"ether"
#define NGM_ETHER_COOKIE	917786906

/* Hook names */
#define NG_ETHER_HOOK_LOWER	"lower"		/* connection to raw device */
#define NG_ETHER_HOOK_UPPER	"upper"		/* connection to upper layers */
#define NG_ETHER_HOOK_DIVERT	"divert"	/* alias for lower */
#define NG_ETHER_HOOK_ORPHAN	"orphans"	/* like lower, unknowns only */

/* Netgraph control messages */
enum {
	NGM_ETHER_GET_IFNAME = 1,	/* get the interface name */
	NGM_ETHER_GET_IFINDEX,		/* get the interface global index # */
	NGM_ETHER_GET_ENADDR,		/* get Ethernet address */
	NGM_ETHER_SET_ENADDR,		/* set Ethernet address */
	NGM_ETHER_GET_PROMISC,		/* get node's promiscuous mode bit */
	NGM_ETHER_SET_PROMISC,		/* enable/disable promiscuous mode */
	NGM_ETHER_GET_AUTOSRC,		/* get source address override */
	NGM_ETHER_SET_AUTOSRC,		/* enable/disable src addr override */
	NGM_ETHER_ADD_MULTI,		/* add multicast membership */
	NGM_ETHER_DEL_MULTI,		/* delete multicast membership */
	NGM_ETHER_DETACH,		/* our way to be shut down */
};

#endif /* _NETGRAPH_NG_ETHER_H_ */


code:
/*
 * ng_ether_echo.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_ether_echo.h 186481 2008-12-25 00:01:29Z julian $
 * $Whistle: ng_echo.h,v 1.3 1999/01/20 00:22:12 archie Exp $
 */

#ifndef _NETGRAPH_NG_ETHER_ECHO_H_
#define _NETGRAPH_NG_ETHER_ECHO_H_

/* Node type name and magic cookie */
#define NG_ETHER_ECHO_NODE_TYPE	"ether_echo"
#define NGM_ETHER_ECHO_COOKIE		1230155201

#endif /* _NETGRAPH_NG_ETHER_ECHO_H_ */


code:
/*
 * ng_fec.h
 */

/*-
 * Copyright (c) 2000 Berkeley Software Design, Inc.
 * Copyright (c) 1997, 1998, 1999, 2000
 *	Bill Paul <wpaul@osd.bsdi.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.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by Bill Paul.
 * 4. Neither the name of the author nor the names of any co-contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
 * 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_fec.h 139823 2005-01-07 01:45:51Z imp $
 */
/*-
 * 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>
 *
 * $Whistle: ng_fec.h,v 1.5 1999/01/20 00:22:13 archie Exp $
 */

#ifndef _NETGRAPH_NG_FEC_H_
#define _NETGRAPH_NG_FEC_H_

#define NETISR_FEC			26

/* Node type name and magic cookie */
#define NG_FEC_NODE_TYPE		"fec"
#define NGM_FEC_COOKIE			983566799

/* Interface base name */
#define NG_FEC_FEC_NAME			"fec"
#define NG_FEC_FEC_NAME_MAX		15

/* MTU bounds */
#define NG_FEC_MTU_MIN			72
#define NG_FEC_MTU_MAX			65535
#define NG_FEC_MTU_DEFAULT		1500

/* Special flags for mbufs. */
#define M_FEC_MAC			0x2000
#define M_FEC_INET			0x4000
#define M_FEC_INET6			0x8000

/* Netgraph commands */
enum {
	NGM_FEC_ADD_IFACE,
	NGM_FEC_DEL_IFACE,
	NGM_FEC_SET_MODE_MAC,
	NGM_FEC_SET_MODE_INET,
	NGM_FEC_SET_MODE_INET6
};

struct ng_fec_ifname {
	char    ngif_name[NG_FEC_FEC_NAME_MAX + 1];
};

#endif /* _NETGRAPH_NG_FEC_H_ */


code:
/*
 * ng_frame_relay.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_frame_relay.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_frame_relay.h,v 1.7 1999/01/20 00:22:13 archie Exp $
 */

#ifndef _NETGRAPH_NG_FRAME_RELAY_H_
#define _NETGRAPH_NG_FRAME_RELAY_H_

/* Node type name and magic cookie */
#define NG_FRAMERELAY_NODE_TYPE		"frame_relay"
#define NGM_FRAMERELAY_COOKIE		872148478

/* Hook names */
#define NG_FRAMERELAY_HOOK_DEBUG	"debug"
#define NG_FRAMERELAY_HOOK_DOWNSTREAM	"downstream"
#define NG_FRAMERELAY_HOOK_DLCI		"dlci"	/* really just the prefix */

#endif /* _NETGRAPH_NG_FRAME_RELAY_H_ */


code:
/*
 * ng_gif.h
 */

/*-
 * Copyright 2001 The Aerospace Corporation.  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.
 * 3. The name of The Aerospace Corporation may not be used to endorse or
 *    promote products derived from this software.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION ``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 AEROSPACE CORPORATION 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.
 *
 *
 * 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.
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_gif.h 139823 2005-01-07 01:45:51Z imp $
 */

#ifndef _NETGRAPH_NG_GIF_H_
#define _NETGRAPH_NG_GIF_H_

/* Node type name and magic cookie */
#define NG_GIF_NODE_TYPE	"gif"
#define NGM_GIF_COOKIE		994115727

/* Hook names */
#define NG_GIF_HOOK_LOWER	"lower"		/* connection to raw device */
#define NG_GIF_HOOK_DIVERT	"divert"	/* alias for lower */
#define NG_GIF_HOOK_ORPHAN	"orphans"	/* like lower, unknowns only */

/* Netgraph control messages */
enum {
	NGM_GIF_GET_IFNAME = 1,		/* get the interface name */
	NGM_GIF_GET_IFINDEX		/* get the interface global index # */
};

#endif /* _NETGRAPH_NG_GIF_H_ */


code:
/*
 * ng_gif_demux.h
 */

/*-
 * Copyright 2001 The Aerospace Corporation.  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.
 * 3. The name of The Aerospace Corporation may not be used to endorse or
 *    promote products derived from this software.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION ``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 AEROSPACE CORPORATION 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_gif_demux.h 139823 2005-01-07 01:45:51Z imp $
 */

#ifndef _NETGRAPH_NG_GIF_DEMUX_H_
#define _NETGRAPH_NG_GIF_DEMUX_H_

/* Node type name and magic cookie */
#define NG_GIF_DEMUX_NODE_TYPE		"gif_demux"
#define NGM_GIF_DEMUX_COOKIE		995567329

/* Hook names */
#define NG_GIF_DEMUX_HOOK_GIF		"gif"
#define NG_GIF_DEMUX_HOOK_INET		"inet"
#define NG_GIF_DEMUX_HOOK_INET6		"inet6"
#define NG_GIF_DEMUX_HOOK_ATALK		"atalk"
#define NG_GIF_DEMUX_HOOK_IPX		"ipx"
#define NG_GIF_DEMUX_HOOK_ATM		"atm"
#define NG_GIF_DEMUX_HOOK_NATM		"natm"

#endif /* _NETGRAPH_NG_GIF_DEMUX_H_ */


code:
/*
 * ng_hole.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_hole.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_hole.h,v 1.3 1999/01/20 00:22:13 archie Exp $
 */

#ifndef _NETGRAPH_NG_HOLE_H_
#define _NETGRAPH_NG_HOLE_H_

/* Node type name and magic cookie */
#define NG_HOLE_NODE_TYPE	"hole"
#define NGM_HOLE_COOKIE		915433206

/* Statistics structure for one hook. */
struct ng_hole_hookstat {
	uint64_t	frames;
	uint64_t	octets;
};

/* Keep this in sync with the above structure definition. */
#define	NG_HOLE_HOOKSTAT_TYPE_INFO {				\
	{ "frames",	&ng_parse_uint64_type },		\
	{ "octets",	&ng_parse_uint64_type },		\
	{ NULL }						\
}

/* Netgraph commands. */
enum {
	NGM_HOLE_GET_STATS = 1,
	NGM_HOLE_CLR_STATS,
	NGM_HOLE_GETCLR_STATS,
};

#endif /* _NETGRAPH_NG_HOLE_H_ */


code:
/*-
 * Copyright (c) 2004 Ruslan Ermilov
 * 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_hub.h 207680 2010-05-05 22:06:05Z zec $
 */

#ifndef _NETGRAPH_NG_HUB_H_
#define	_NETGRAPH_NG_HUB_H_

/* Node type name and magic cookie. */
#define	NG_HUB_NODE_TYPE	"hub"
#define	NGM_HUB_COOKIE		1082189597

/* Netgraph control messages */
enum {
	NGM_HUB_SET_PERSISTENT = 1,	/* set persistent mode */
};

#endif /* _NETGRAPH_NG_HUB_H_ */


code:
/*
 * ng_iface.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_iface.h 187495 2009-01-20 22:26:09Z mav $
 * $Whistle: ng_iface.h,v 1.5 1999/01/20 00:22:13 archie Exp $
 */

#ifndef _NETGRAPH_NG_IFACE_H_
#define _NETGRAPH_NG_IFACE_H_

/* Node type name and magic cookie */
#define NG_IFACE_NODE_TYPE		"iface"
#define NGM_IFACE_COOKIE		1108312559

/* Interface base name */
#define NG_IFACE_IFACE_NAME		"ng"

/* My hook names */
#define NG_IFACE_HOOK_INET		"inet"
#define NG_IFACE_HOOK_INET6		"inet6"
#define NG_IFACE_HOOK_ATALK		"atalk"	/* AppleTalk phase 2 */
#define NG_IFACE_HOOK_IPX		"ipx"
#define NG_IFACE_HOOK_ATM		"atm"
#define NG_IFACE_HOOK_NATM		"natm"

/* MTU bounds */
#define NG_IFACE_MTU_MIN		72
#define NG_IFACE_MTU_MAX		65535
#define NG_IFACE_MTU_DEFAULT		1500

/* Netgraph commands */
enum {
	NGM_IFACE_GET_IFNAME = 1,
	NGM_IFACE_POINT2POINT,
	NGM_IFACE_BROADCAST,
	NGM_IFACE_GET_IFINDEX,
};

#define	MTAG_NGIF			NGM_IFACE_COOKIE
#define	MTAG_NGIF_CALLED		0 | MTAG_PERSISTENT

#endif /* _NETGRAPH_NG_IFACE_H_ */


code:
/*
 * ng_ip_input.h
 */

/*-
 * Copyright 2001 The Aerospace Corporation.  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.
 * 3.  The name of The Aerospace Corporation may not be used to endorse or
 *     promote products derived from this software.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "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 AEROSPACE CORPORATION 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.
 *
 * 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:		Brooks Davis <brooks@FreeBSD.org>
 * Derived from:	ng_hole.h
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_ip_input.h 139823 2005-01-07 01:45:51Z imp $
 */

#ifndef _NETGRAPH_NG_IP_INPUT_H_
#define _NETGRAPH_NG_IP_INPUT_H_

/* Node type name and magic cookie */
#define NG_IP_INPUT_NODE_TYPE	"ip_input"
#define NGM_IP_INPUT_COOKIE	994874907

#endif /* _NETGRAPH_NG_IP_INPUT_H_ */


code:
/*-
 * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org>
 * 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_ipfw.h 201124 2009-12-28 12:29:13Z luigi $
 */

#ifndef _NG_IPFW_H
#define _NG_IPFW_H
#define NG_IPFW_NODE_TYPE    "ipfw"
#define NGM_IPFW_COOKIE      1105988990
#endif /* _NG_IPFW_H */


code:
/*
 * ng_ksocket.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_ksocket.h 151800 2005-10-28 14:41:28Z ru $
 * $Whistle: ng_ksocket.h,v 1.1 1999/11/16 20:04:40 archie Exp $
 */

#ifndef _NETGRAPH_NG_KSOCKET_H_
#define _NETGRAPH_NG_KSOCKET_H_

#include <sys/socket.h>

/* Node type name and magic cookie */
#define NG_KSOCKET_NODE_TYPE	"ksocket"
#define NGM_KSOCKET_COOKIE	942710669

/* For NGM_KSOCKET_SETOPT and NGM_KSOCKET_GETOPT control messages */
struct ng_ksocket_sockopt {
	int32_t		level;		/* second arg of [gs]etsockopt() */
	int32_t		name;		/* third arg of [gs]etsockopt() */
	u_char		value[];	/* fourth arg of [gs]etsockopt() */
};

/* Max length socket option we can return via NGM_KSOCKET_GETOPT
   XXX This should not be necessary, we should dynamically size
   XXX the response. Until then.. */
#define NG_KSOCKET_MAX_OPTLEN	1024

/* Keep this in sync with the above structure definition */
#define NG_KSOCKET_SOCKOPT_INFO(svtype)	{			\
	  { "level",		&ng_parse_int32_type	},	\
	  { "name",		&ng_parse_int32_type	},	\
	  { "value",		(svtype)		},	\
	  { NULL }						\
}

/* For NGM_KSOCKET_ACCEPT control message responses */
struct ng_ksocket_accept {
	u_int32_t	nodeid;		/* node ID of connected ksocket */
	struct sockaddr	addr;		/* peer's address (variable length) */
};

/* Keep this in sync with the above structure definition */
#define	NGM_KSOCKET_ACCEPT_INFO {					\
	  { "nodeid",		&ng_parse_hint32_type		  },	\
	  { "addr",		&ng_ksocket_generic_sockaddr_type },	\
	  { NULL }							\
}

/* Netgraph commands */
enum {
	NGM_KSOCKET_BIND = 1,
	NGM_KSOCKET_LISTEN,
	NGM_KSOCKET_ACCEPT,
	NGM_KSOCKET_CONNECT,
	NGM_KSOCKET_GETNAME,
	NGM_KSOCKET_GETPEERNAME,
	NGM_KSOCKET_SETOPT,
	NGM_KSOCKET_GETOPT,
};

#ifdef _KERNEL

/* Structure for sockaddr tag */
struct sa_tag {
	struct m_tag	tag;
	ng_ID_t		id;
	struct sockaddr	sa;
};

/* Tag information ID's */
#define NG_KSOCKET_TAG_SOCKADDR	1	/* data is struct sockaddr */

#endif /* _KERNEL */
#endif /* _NETGRAPH_NG_KSOCKET_H_ */


code:
/*-
 * Copyright (c) 2001-2002 Packet Design, LLC.
 * 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
 * Packet Design; provided, however, that:
 *
 *    (i)  Any and all reproductions of the source or object code
 *         must include the copyright notice above and the following
 *         disclaimer of warranties; and
 *    (ii) No rights are granted, in any manner or form, to use
 *         Packet Design trademarks, including the mark "PACKET DESIGN"
 *         on advertising, endorsements, or otherwise except as such
 *         appears in the above copyright notice or in the software.
 *
 * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN 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.  PACKET DESIGN 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 PACKET DESIGN 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 PACKET DESIGN IS ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Author: Archie Cobbs <archie@freebsd.org>
 *
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_l2tp.h 139823 2005-01-07 01:45:51Z imp $
 */

#ifndef _NETGRAPH_NG_L2TP_H_
#define _NETGRAPH_NG_L2TP_H_

/* Node type name and magic cookie */
#define NG_L2TP_NODE_TYPE	"l2tp"
#define NGM_L2TP_COOKIE		1091515793

/* Hook names */
#define NG_L2TP_HOOK_CTRL	"ctrl"		/* control channel hook */
#define NG_L2TP_HOOK_LOWER	"lower"		/* hook to lower layers */

/* Session hooks: prefix plus hex session ID, e.g., "session_3e14" */
#define NG_L2TP_HOOK_SESSION_P	"session_"	/* session data hook (prefix) */
#define NG_L2TP_HOOK_SESSION_F	"session_%04x"	/* session data hook (format) */

/* Set intial sequence numbers to not yet enabled node. */
struct ng_l2tp_seq_config {
	u_int16_t	ns;		/* sequence number to send next */
	u_int16_t	nr;		/* sequence number to be recved next */
	u_int16_t	rack;		/* last 'nr' received */
	u_int16_t	xack;		/* last 'nr' sent */
};

/* Keep this in sync with the above structure definition. */
#define	NG_L2TP_SEQ_CONFIG_TYPE_INFO	{			\
	  { "ns",		&ng_parse_uint16_type	},	\
	  { "nr",		&ng_parse_uint16_type	},	\
	  { NULL }						\
}

/* Configuration for a node */
struct ng_l2tp_config {
	u_char		enabled;	/* enables traffic flow */
	u_char		match_id;	/* tunnel id must match 'tunnel_id' */
	u_int16_t	tunnel_id;	/* local tunnel id */
	u_int16_t	peer_id;	/* peer's tunnel id */
	u_int16_t	peer_win;	/* peer's max recv window size */
	u_int16_t	rexmit_max;	/* max retransmits before failure */
	u_int16_t	rexmit_max_to;	/* max delay between retransmits */
};

/* Keep this in sync with the above structure definition */
#define NG_L2TP_CONFIG_TYPE_INFO	{			\
	  { "enabled",		&ng_parse_uint8_type	},	\
	  { "match_id",		&ng_parse_uint8_type	},	\
	  { "tunnel_id",	&ng_parse_hint16_type	},	\
	  { "peer_id",		&ng_parse_hint16_type	},	\
	  { "peer_win",		&ng_parse_uint16_type	},	\
	  { "rexmit_max",	&ng_parse_uint16_type	},	\
	  { "rexmit_max_to",	&ng_parse_uint16_type	},	\
	  { NULL }						\
}

/* Configuration for a session hook */
struct ng_l2tp_sess_config {
	u_int16_t	session_id;	/* local session id */
	u_int16_t	peer_id;	/* peer's session id */
	u_char		control_dseq;	/* whether we control data sequencing */
	u_char		enable_dseq;	/* whether to enable data sequencing */
	u_char		include_length;	/* whether to include length field */
};

/* Keep this in sync with the above structure definition */
#define NG_L2TP_SESS_CONFIG_TYPE_INFO	{			\
	  { "session_id",	&ng_parse_hint16_type	},	\
	  { "peer_id",		&ng_parse_hint16_type	},	\
	  { "control_dseq",	&ng_parse_uint8_type	},	\
	  { "enable_dseq",	&ng_parse_uint8_type	},	\
	  { "include_length",	&ng_parse_uint8_type	},	\
	  { NULL }						\
}

/* Statistics struct */
struct ng_l2tp_stats {
	u_int32_t xmitPackets;		/* number of packets xmit */
	u_int32_t xmitOctets;		/* number of octets xmit */
	u_int32_t xmitZLBs;		/* ack-only packets transmitted */
	u_int32_t xmitDrops;		/* xmits dropped due to full window */
	u_int32_t xmitTooBig;		/* ctrl pkts dropped because too big */
	u_int32_t xmitInvalid;		/* ctrl packets with no session ID */
	u_int32_t xmitDataTooBig;	/* data pkts dropped because too big */
	u_int32_t xmitRetransmits;	/* retransmitted packets */
	u_int32_t recvPackets;		/* number of packets rec'd */
	u_int32_t recvOctets;		/* number of octets rec'd */
	u_int32_t recvRunts;		/* too short packets rec'd */
	u_int32_t recvInvalid;		/* invalid packets rec'd */
	u_int32_t recvWrongTunnel;	/* packets rec'd with wrong tunnel id */
	u_int32_t recvUnknownSID;	/* pkts rec'd with unknown session id */
	u_int32_t recvBadAcks;		/* ctrl pkts rec'd with invalid 'nr' */
	u_int32_t recvOutOfOrder;	/* out of order ctrl pkts rec'd */
	u_int32_t recvDuplicates;	/* duplicate ctrl pkts rec'd */
	u_int32_t recvDataDrops;	/* dup/out of order data pkts rec'd */
	u_int32_t recvZLBs;		/* ack-only packets rec'd */
	u_int32_t memoryFailures;	/* times we couldn't allocate memory */
};

/* Keep this in sync with the above structure definition */
#define NG_L2TP_STATS_TYPE_INFO	{			\
	  { "xmitPackets",	&ng_parse_uint32_type	},	\
	  { "xmitOctets",	&ng_parse_uint32_type	},	\
	  { "xmitZLBs",		&ng_parse_uint32_type	},	\
	  { "xmitDrops",	&ng_parse_uint32_type	},	\
	  { "xmitTooBig",	&ng_parse_uint32_type	},	\
	  { "xmitInvalid",	&ng_parse_uint32_type	},	\
	  { "xmitDataTooBig",	&ng_parse_uint32_type	},	\
	  { "xmitRetransmits",	&ng_parse_uint32_type	},	\
	  { "recvPackets",	&ng_parse_uint32_type	},	\
	  { "recvOctets",	&ng_parse_uint32_type	},	\
	  { "recvRunts",	&ng_parse_uint32_type	},	\
	  { "recvInvalid",	&ng_parse_uint32_type	},	\
	  { "recvWrongTunnel",	&ng_parse_uint32_type	},	\
	  { "recvUnknownSID",	&ng_parse_uint32_type	},	\
	  { "recvBadAcks",	&ng_parse_uint32_type	},	\
	  { "recvOutOfOrder",	&ng_parse_uint32_type	},	\
	  { "recvDuplicates",	&ng_parse_uint32_type	},	\
	  { "recvDataDrops",	&ng_parse_uint32_type	},	\
	  { "recvZLBs",		&ng_parse_uint32_type	},	\
	  { "memoryFailures",	&ng_parse_uint32_type	},	\
	  { NULL }						\
}

/* Session statistics struct. */
struct ng_l2tp_session_stats {
	u_int64_t xmitPackets;		/* number of packets xmit */
	u_int64_t xmitOctets;		/* number of octets xmit */
	u_int64_t recvPackets;		/* number of packets received */
	u_int64_t recvOctets;		/* number of octets received */
};

/* Keep this in sync with the above structure definition. */
#define NG_L2TP_SESSION_STATS_TYPE_INFO	{			\
	  { "xmitPackets",	&ng_parse_uint64_type	},	\
	  { "xmitOctets",	&ng_parse_uint64_type	},	\
	  { "recvPackets",	&ng_parse_uint64_type	},	\
	  { "recvOctets",	&ng_parse_uint64_type	},	\
	  { NULL }						\
}

/* Netgraph commands */
enum {
	NGM_L2TP_SET_CONFIG = 1,	/* supply a struct ng_l2tp_config */
	NGM_L2TP_GET_CONFIG,		/* returns a struct ng_l2tp_config */
	NGM_L2TP_SET_SESS_CONFIG,	/* supply struct ng_l2tp_sess_config */
	NGM_L2TP_GET_SESS_CONFIG,	/* supply a session id (u_int16_t) */
	NGM_L2TP_GET_STATS,		/* returns struct ng_l2tp_stats */
	NGM_L2TP_CLR_STATS,		/* clears stats */
	NGM_L2TP_GETCLR_STATS,		/* returns & clears stats */
	NGM_L2TP_GET_SESSION_STATS,	/* returns session stats */
	NGM_L2TP_CLR_SESSION_STATS,	/* clears session stats */
	NGM_L2TP_GETCLR_SESSION_STATS,	/* returns & clears session stats */
	NGM_L2TP_ACK_FAILURE,		/* sent *from* node after ack timeout */
	NGM_L2TP_SET_SEQ		/* supply a struct ng_l2tp_seq_config */
};

#endif /* _NETGRAPH_NG_L2TP_H_ */


code:
/*
 * ng_lmi.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_lmi.h 139823 2005-01-07 01:45:51Z imp $
 * $Whistle: ng_lmi.h,v 1.9 1999/01/20 00:22:13 archie Exp $
 */

#ifndef _NETGRAPH_NG_LMI_H_
#define _NETGRAPH_NG_LMI_H_

/* Node type name and magic cookie */
#define NG_LMI_NODE_TYPE		"lmi"
#define NGM_LMI_COOKIE			867184133

/* My hook names */
#define NG_LMI_HOOK_DEBUG		"debug"
#define NG_LMI_HOOK_ANNEXA		"annexA"
#define NG_LMI_HOOK_ANNEXD		"annexD"
#define NG_LMI_HOOK_GROUPOF4		"group4"
#define NG_LMI_HOOK_AUTO0		"auto0"
#define NG_LMI_HOOK_AUTO1023		"auto1023"

/* Netgraph commands */
enum {
	NGM_LMI_GET_STATUS = 1,
};

#define NGM_LMI_STAT_ARYSIZE		(1024/8)

struct nglmistat {
	u_char  proto[12];	/* Active proto (same as hook name) */
	u_char  hook[12];	/* Active hook */
	u_char  fixed;		/* Set to fixed LMI mode */
	u_char  autod;		/* Currently auto-detecting */
	u_char  seen[NGM_LMI_STAT_ARYSIZE];	/* DLCIs ever seen */
	u_char  up[NGM_LMI_STAT_ARYSIZE];	/* DLCIs currently up */
};

/* Some default values */
#define NG_LMI_KEEPALIVE_RATE		10	/* seconds per keepalive */
#define NG_LMI_POLL_RATE		3	/* faster when AUTO polling */
#define NG_LMI_SEQ_PER_FULL		5	/* keepalives per full status */
#define NG_LMI_LMI_PRIORITY		64	/* priority for LMI data */

#endif /* _NETGRAPH_NG_LMI_H_ */


code:
/*
 * ng_message.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_message.h 193812 2009-06-09 07:07:20Z imp $
 * $Whistle: ng_message.h,v 1.12 1999/01/25 01:17:44 archie Exp $
 */

#ifndef _NETGRAPH_NG_MESSAGE_H_
#define _NETGRAPH_NG_MESSAGE_H_

/* ASCII string size limits */
#define	NG_TYPESIZ	32	/* max type name len (including null) */
#define	NG_HOOKSIZ	32	/* max hook name len (including null) */
#define	NG_NODESIZ	32	/* max node name len (including null) */
#define	NG_PATHSIZ	512	/* max path len (including null) */
#define	NG_CMDSTRSIZ	32	/* max command string (including null) */

#define NG_TEXTRESPONSE 1024	/* allow this length for a text response */

/* A netgraph message */
struct ng_mesg {
	struct	ng_msghdr {
		u_char		version;		/*  == NGM_VERSION */
		u_char		spare;			/* pad to 4 bytes */
		u_int16_t	spare2;
		u_int32_t	arglen;			/* length of data */
		u_int32_t	cmd;			/* command identifier */
		u_int32_t	flags;			/* message status */
		u_int32_t	token;			/* match with reply */
		u_int32_t	typecookie;		/* node's type cookie */
		u_char		cmdstr[NG_CMDSTRSIZ];	/* cmd string + \0 */
	} header;
	char	data[];			/* placeholder for actual data */
};

/* This command is guaranteed to not alter data (or'd into the command). */
#define NGM_READONLY	0x10000000
/* This command is guaranteed to have a reply (or'd into the command). */
#define NGM_HASREPLY	0x20000000

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_NG_MESG_INFO(dtype)	{			\
	  { "version",		&ng_parse_uint8_type	},	\
	  { "spare",		&ng_parse_uint8_type	},	\
	  { "spare2",		&ng_parse_uint16_type	},	\
	  { "arglen",		&ng_parse_uint32_type	},	\
	  { "cmd",		&ng_parse_uint32_type	},	\
	  { "flags",		&ng_parse_hint32_type	},	\
	  { "token",		&ng_parse_uint32_type	},	\
	  { "typecookie",	&ng_parse_uint32_type	},	\
	  { "cmdstr",		&ng_parse_cmdbuf_type	},	\
	  { "data",		(dtype)			},	\
	  { NULL }						\
}

/*
 * Netgraph message header compatibility field
 * Interfaces within the kernel are defined by a different
 * value (see NG_ABI_VERSION in netgraph.h)
 */
#define NG_VERSION	8

/* Flags field flags */
#define NGF_ORIG	0x00000000	/* the msg is the original request */
#define NGF_RESP	0x00000001	/* the message is a response */

/* Type of a unique node ID. */
#define ng_ID_t uint32_t

/*
 * Here we describe the "generic" messages that all nodes inherently
 * understand. With the exception of NGM_TEXT_STATUS, these are handled
 * automatically by the base netgraph code.
 */

/* Generic message type cookie */
#define NGM_GENERIC_COOKIE	1137070366

/* Generic messages defined for this type cookie. */
enum {
	NGM_SHUTDOWN	= 1,	/* Shut down node. */
	NGM_MKPEER	= 2,	/* Create and attach a peer node. */
	NGM_CONNECT	= 3,	/* Connect two nodes. */
	NGM_NAME	= 4,	/* Give a node a name. */
	NGM_RMHOOK	= 5,	/* Break a connection between two nodes. */

	/* Get nodeinfo for target. */
	NGM_NODEINFO	= (6|NGM_READONLY|NGM_HASREPLY),
	/* Get list of hooks on node. */
	NGM_LISTHOOKS	= (7|NGM_READONLY|NGM_HASREPLY),
	/* List globally named nodes. */
	NGM_LISTNAMES	= (8|NGM_READONLY|NGM_HASREPLY),
	/* List all nodes. */
	NGM_LISTNODES	= (9|NGM_READONLY|NGM_HASREPLY),
	/* List installed node types. */
	NGM_LISTTYPES	= (10|NGM_READONLY|NGM_HASREPLY),
	/* (optional) Get text status. */
	NGM_TEXT_STATUS	= (11|NGM_READONLY|NGM_HASREPLY),
	/* Convert struct ng_mesg to ASCII. */
	NGM_BINARY2ASCII= (12|NGM_READONLY|NGM_HASREPLY),
	/* Convert ASCII to struct ng_mesg. */
	NGM_ASCII2BINARY= (13|NGM_READONLY|NGM_HASREPLY),
	/* (optional) Get/set text config. */
	NGM_TEXT_CONFIG	= 14,
};

/*
 * Flow control and intra node control messages.
 * These are routed between nodes to allow flow control and to allow
 * events to be passed around the graph.
 * There will be some form of default handling for these but I
 * do not yet know what it is..
 */

/* Generic message type cookie */
#define NGM_FLOW_COOKIE	851672669 /* temp for debugging */

/* Upstream messages */
#define NGM_LINK_IS_UP		32	/* e.g. carrier found - no data */
#define NGM_LINK_IS_DOWN	33	/* carrier lost, includes queue state */
#define NGM_HIGH_WATER_PASSED	34	/* includes queue state */
#define NGM_LOW_WATER_PASSED	35	/* includes queue state */
#define NGM_SYNC_QUEUE_STATE	36	/* sync response from sending packet */

/* Downstream messages */
#define NGM_DROP_LINK		41	/* drop DTR, etc. - stay in the graph */
#define NGM_RAISE_LINK		42	/* if you previously dropped it */
#define NGM_FLUSH_QUEUE		43	/* no data */
#define NGM_GET_BANDWIDTH	(44|NGM_READONLY)	/* either real or measured */
#define NGM_SET_XMIT_Q_LIMITS	45	/* includes queue state */
#define NGM_GET_XMIT_Q_LIMITS	(46|NGM_READONLY)	/* returns queue state */
#define NGM_MICROMANAGE		47	/* We want sync. queue state
						reply for each packet sent */
#define NGM_SET_FLOW_MANAGER	48	/* send flow control here */
/* Structure used for NGM_MKPEER */
struct ngm_mkpeer {
	char	type[NG_TYPESIZ];		/* peer type */
	char	ourhook[NG_HOOKSIZ];		/* hook name */
	char	peerhook[NG_HOOKSIZ];		/* peer hook name */
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_MKPEER_INFO()	{			\
	  { "type",		&ng_parse_typebuf_type	},	\
	  { "ourhook",		&ng_parse_hookbuf_type	},	\
	  { "peerhook",		&ng_parse_hookbuf_type	},	\
	  { NULL }						\
}

/* Structure used for NGM_CONNECT */
struct ngm_connect {
	char	path[NG_PATHSIZ];		/* peer path */
	char	ourhook[NG_HOOKSIZ];		/* hook name */
	char	peerhook[NG_HOOKSIZ];		/* peer hook name */
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_CONNECT_INFO()	{			\
	  { "path",		&ng_parse_pathbuf_type	},	\
	  { "ourhook",		&ng_parse_hookbuf_type	},	\
	  { "peerhook",		&ng_parse_hookbuf_type	},	\
	  { NULL }						\
}

/* Structure used for NGM_NAME */
struct ngm_name {
	char	name[NG_NODESIZ];			/* node name */
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_NAME_INFO()	{				\
	  { "name",		&ng_parse_nodebuf_type	},	\
	  { NULL }						\
}

/* Structure used for NGM_RMHOOK */
struct ngm_rmhook {
	char	ourhook[NG_HOOKSIZ];		/* hook name */
};

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

/* Structure used for NGM_NODEINFO */
struct nodeinfo {
	char		name[NG_NODESIZ];	/* node name (if any) */
        char    	type[NG_TYPESIZ];	/* peer type */
	ng_ID_t		id;			/* unique identifier */
	u_int32_t	hooks;			/* number of active hooks */
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_NODEINFO_INFO()	{			\
	  { "name",		&ng_parse_nodebuf_type	},	\
	  { "type",		&ng_parse_typebuf_type	},	\
	  { "id",		&ng_parse_hint32_type	},	\
	  { "hooks",		&ng_parse_uint32_type	},	\
	  { NULL }						\
}

/* Structure used for NGM_LISTHOOKS */
struct linkinfo {
	char		ourhook[NG_HOOKSIZ];	/* hook name */
	char		peerhook[NG_HOOKSIZ];	/* peer hook */
	struct nodeinfo	nodeinfo;
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_LINKINFO_INFO(nitype)	{		\
	  { "ourhook",		&ng_parse_hookbuf_type	},	\
	  { "peerhook",		&ng_parse_hookbuf_type	},	\
	  { "nodeinfo",		(nitype)		},	\
	  { NULL }						\
}

struct hooklist {
	struct nodeinfo nodeinfo;		/* node information */
	struct linkinfo link[];			/* info about each hook */
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_HOOKLIST_INFO(nitype,litype)	{		\
	  { "nodeinfo",		(nitype)		},	\
	  { "linkinfo",		(litype)		},	\
	  { NULL }						\
}

/* Structure used for NGM_LISTNAMES/NGM_LISTNODES */
struct namelist {
	u_int32_t	numnames;
	struct nodeinfo	nodeinfo[];
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_LISTNODES_INFO(niarraytype)	{		\
	  { "numnames",		&ng_parse_uint32_type	},	\
	  { "nodeinfo",		(niarraytype)		},	\
	  { NULL }						\
}

/* Structure used for NGM_LISTTYPES */
struct typeinfo {
	char		type_name[NG_TYPESIZ];	/* name of type */
	u_int32_t	numnodes;		/* number alive */
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_TYPEINFO_INFO()		{		\
	  { "typename",		&ng_parse_typebuf_type	},	\
	  { "numnodes",		&ng_parse_uint32_type	},	\
	  { NULL }						\
}

struct typelist {
	u_int32_t	numtypes;
	struct typeinfo	typeinfo[];
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_TYPELIST_INFO(tiarraytype)	{		\
	  { "numtypes",		&ng_parse_uint32_type	},	\
	  { "typeinfo",		(tiarraytype)		},	\
	  { NULL }						\
}

struct ngm_bandwidth {
	u_int64_t	nominal_in;
	u_int64_t	seen_in;
	u_int64_t	nominal_out;
	u_int64_t	seen_out;
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_BANDWIDTH_INFO()	{			\
	  { "nominal_in",	&ng_parse_uint64_type	},	\
	  { "seen_in",		&ng_parse_uint64_type	},	\
	  { "nominal_out",	&ng_parse_uint64_type	},	\
	  { "seen_out",		&ng_parse_uint64_type	},	\
	  { NULL }						\
}

/*
 * Information about a node's 'output' queue.
 * This is NOT the netgraph input queueing mechanism,
 * but rather any queue the node may implement internally
 * This has to consider ALTQ if we are to work with it.
 * As far as I can see, ALTQ counts PACKETS, not bytes.
 * If ALTQ has several queues and one has passed a watermark
 * we should have the priority of that queue be real (and not -1)
 * XXX ALTQ stuff is just an idea.....
 */
struct ngm_queue_state {
	u_int queue_priority; /* maybe only low-pri is full. -1 = all*/
	u_int	max_queuelen_bytes;
	u_int	max_queuelen_packets;
	u_int	low_watermark;
	u_int	high_watermark;
	u_int	current;
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_QUEUE_INFO()	{				\
	  { "max_queuelen_bytes", &ng_parse_uint_type	},	\
	  { "max_queuelen_packets", &ng_parse_uint_type	},	\
	  { "high_watermark",	&ng_parse_uint_type	},	\
	  { "low_watermark",	&ng_parse_uint_type	},	\
	  { "current",		&ng_parse_uint_type	},	\
	  { NULL }						\
}

/* Tell a node who to send async flow control info to. */
struct flow_manager {
	ng_ID_t		id;			/* unique identifier */
};

/* Keep this in sync with the above structure definition */
#define NG_GENERIC_FLOW_MANAGER_INFO()	{			\
	  { "id",		&ng_parse_hint32_type	},	\
	  { NULL }						\
}

/*
 * For netgraph nodes that are somehow associated with file descriptors
 * (e.g., a device that has a /dev entry and is also a netgraph node),
 * we define a generic ioctl for requesting the corresponding nodeinfo
 * structure and for assigning a name (if there isn't one already).
 *
 * For these to you need to also #include <sys/ioccom.h>.
 */

#define NGIOCGINFO	_IOR('N', 40, struct nodeinfo)	/* get node info */
#define NGIOCSETNAME	_IOW('N', 41, struct ngm_name)	/* set node name */

#ifdef _KERNEL
/*
 * Allocate and initialize a netgraph message "msg" with "len"
 * extra bytes of argument. Sets "msg" to NULL if fails.
 * Does not initialize token.
 */
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how)			\
	do {								\
	  (msg) = malloc(sizeof(struct ng_mesg)				\
	    + (len), M_NETGRAPH_MSG, (how) | M_ZERO);			\
	  if ((msg) == NULL)						\
	    break;							\
	  (msg)->header.version = NG_VERSION;				\
	  (msg)->header.typecookie = (cookie);				\
	  (msg)->header.cmd = (cmdid);					\
	  (msg)->header.arglen = (len);					\
	  strncpy((msg)->header.cmdstr, #cmdid,				\
	    sizeof((msg)->header.cmdstr) - 1);				\
	} while (0)

/*
 * Allocate and initialize a response "rsp" to a message "msg"
 * with "len" extra bytes of argument. Sets "rsp" to NULL if fails.
 */
#define NG_MKRESPONSE(rsp, msg, len, how)				\
	do {								\
	  (rsp) = malloc(sizeof(struct ng_mesg)				\
	    + (len), M_NETGRAPH_MSG, (how) | M_ZERO);			\
	  if ((rsp) == NULL)						\
	    break;							\
	  (rsp)->header.version = NG_VERSION;				\
	  (rsp)->header.arglen = (len);					\
	  (rsp)->header.token = (msg)->header.token;			\
	  (rsp)->header.typecookie = (msg)->header.typecookie;		\
	  (rsp)->header.cmd = (msg)->header.cmd;			\
	  bcopy((msg)->header.cmdstr, (rsp)->header.cmdstr,		\
	    sizeof((rsp)->header.cmdstr));				\
	  (rsp)->header.flags |= NGF_RESP;				\
	} while (0)

/*
 * Make a copy of message. Sets "copy" to NULL if fails.
 */
#define	NG_COPYMESSAGE(copy, msg, how)					\
	do {								\
	  (copy) = malloc(sizeof(struct ng_mesg)			\
	    + (msg)->header.arglen, M_NETGRAPH_MSG, (how) | M_ZERO);	\
	  if ((copy) == NULL)						\
	    break;							\
	  (copy)->header.version = NG_VERSION;				\
	  (copy)->header.arglen = (msg)->header.arglen;			\
	  (copy)->header.token = (msg)->header.token;			\
	  (copy)->header.typecookie = (msg)->header.typecookie;		\
	  (copy)->header.cmd = (msg)->header.cmd;			\
	  (copy)->header.flags = (msg)->header.flags;			\
	  bcopy((msg)->header.cmdstr, (copy)->header.cmdstr,		\
	    sizeof((copy)->header.cmdstr));				\
	  if ((msg)->header.arglen > 0)					\
	    bcopy((msg)->data, (copy)->data, (msg)->header.arglen);	\
	} while (0)

#endif /* _KERNEL */

#endif /* _NETGRAPH_NG_MESSAGE_H_ */


code:
/*
 * ng_mppc.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>
 *
 * $Whistle: ng_mppc.h,v 1.3 2000/02/12 01:17:22 archie Exp $
 * $FreeBSD: release/9.0.0/sys/netgraph/ng_mppc.h 139823 2005-01-07 01:45:51Z imp $
 */

#ifndef _NETGRAPH_NG_MPPC_H_
#define _NETGRAPH_NG_MPPC_H_

/* Node type name and magic cookie */
#define NG_MPPC_NODE_TYPE	"mppc"
#define NGM_MPPC_COOKIE		942886745

/* Hook names */
#define NG_MPPC_HOOK_COMP	"comp"		/* compression hook */
#define NG_MPPC_HOOK_DECOMP	"decomp"	/* decompression hook */

/* Length of MPPE key */
#define MPPE_KEY_LEN		16

/* Max expansion due to MPPC header and compression algorithm */
#define MPPC_MAX_BLOWUP(n)	((n) * 9 / 8 + 26)

/* MPPC/MPPE PPP negotiation bits */
#define MPPC_BIT		0x00000001	/* mppc compression bits */
#define MPPE_40			0x00000020	/* use 40 bit key */
#define MPPE_56			0x00000080	/* use 56 bit key */
#define MPPE_128		0x00000040	/* use 128 bit key */
#define MPPE_BITS		0x000000e0	/* mppe encryption bits */
#define MPPE_STATELESS		0x01000000	/* use stateless mode */
#define MPPC_VALID_BITS		0x010000e1	/* possibly valid bits */

/* Config struct (per-direction) */
struct ng_mppc_config {
	u_char		enable;			/* enable */
	u_int32_t	bits;			/* config bits */
	u_char		startkey[MPPE_KEY_LEN];	/* start key */
};

/* Netgraph commands */
enum {
	NGM_MPPC_CONFIG_COMP = 1,
	NGM_MPPC_CONFIG_DECOMP,
	NGM_MPPC_RESETREQ,			/* sent either way! */
};

#endif /* _NETGRAPH_NG_MPPC_H_ */


code:
/*-
 * Copyright 2005, Gleb Smirnoff <glebius@FreeBSD.org>
 * 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_nat.h 176791 2008-03-04 11:10:54Z mav $
 */

#define NG_NAT_NODE_TYPE    "nat"
#define NGM_NAT_COOKIE      1107718711

#define	NG_NAT_HOOK_IN	"in"
#define	NG_NAT_HOOK_OUT	"out"

/* Arguments for NGM_NAT_SET_MODE message */
struct ng_nat_mode {
	uint32_t	flags;
	uint32_t	mask;
};

/* Keep this in sync with the above structure definition */
#define NG_NAT_MODE_INFO {				\
	  { "flags",	&ng_parse_uint32_type	},	\
	  { "mask",	&ng_parse_uint32_type	},	\
	  { NULL }					\
}

#define NG_NAT_LOG			0x01
#define NG_NAT_DENY_INCOMING		0x02
#define NG_NAT_SAME_PORTS		0x04
#define NG_NAT_UNREGISTERED_ONLY	0x10
#define NG_NAT_RESET_ON_ADDR_CHANGE	0x20
#define NG_NAT_PROXY_ONLY		0x40
#define NG_NAT_REVERSE			0x80

#define NG_NAT_DESC_LENGTH	64
#define NG_NAT_REDIRPROTO_ADDR	(IPPROTO_MAX + 3) 	/* LibAlias' LINK_ADDR, also unused in in.h */

/* Arguments for NGM_NAT_REDIRECT_PORT message */
struct ng_nat_redirect_port {
	struct in_addr	local_addr;
	struct in_addr	alias_addr;
	struct in_addr	remote_addr;
	uint16_t	local_port;
	uint16_t	alias_port;
	uint16_t	remote_port;
	uint8_t		proto;
	char		description[NG_NAT_DESC_LENGTH];
};

/* Keep this in sync with the above structure definition */
#define NG_NAT_REDIRECT_PORT_TYPE_INFO(desctype) {		\
	  { "local_addr",	&ng_parse_ipaddr_type	},	\
	  { "alias_addr",	&ng_parse_ipaddr_type	},	\
	  { "remote_addr",	&ng_parse_ipaddr_type	},	\
	  { "local_port",	&ng_parse_uint16_type	},	\
	  { "alias_port",	&ng_parse_uint16_type	},	\
	  { "remote_port",	&ng_parse_uint16_type	},	\
	  { "proto",		&ng_parse_uint8_type	},	\
	  { "description",	(desctype)		},	\
	  { NULL }						\
}

/* Arguments for NGM_NAT_REDIRECT_ADDR message */
struct ng_nat_redirect_addr {
	struct in_addr	local_addr;
	struct in_addr	alias_addr;
	char		description[NG_NAT_DESC_LENGTH];
};

/* Keep this in sync with the above structure definition */
#define NG_NAT_REDIRECT_ADDR_TYPE_INFO(desctype) {		\
	  { "local_addr",	&ng_parse_ipaddr_type	},	\
	  { "alias_addr",	&ng_parse_ipaddr_type	},	\
	  { "description",	(desctype)		},	\
	  { NULL }						\
}

/* Arguments for NGM_NAT_REDIRECT_PROTO message */
struct ng_nat_redirect_proto {
	struct in_addr	local_addr;
	struct in_addr	alias_addr;
	struct in_addr	remote_addr;
	uint8_t		proto;
	char		description[NG_NAT_DESC_LENGTH];
};

/* Keep this in sync with the above structure definition */
#define NG_NAT_REDIRECT_PROTO_TYPE_INFO(desctype) {		\
	  { "local_addr",	&ng_parse_ipaddr_type	},	\
	  { "alias_addr",	&ng_parse_ipaddr_type	},	\
	  { "remote_addr",	&ng_parse_ipaddr_type	},	\
	  { "proto",		&ng_parse_uint8_type	},	\
	  { "description",	(desctype)		},	\
	  { NULL }						\
}

/* Arguments for NGM_NAT_ADD_SERVER message */
struct ng_nat_add_server {
	uint32_t	id;
	struct in_addr	addr;
	uint16_t	port;
};

/* Keep this in sync with the above structure definition */
#define NG_NAT_ADD_SERVER_TYPE_INFO {				\
	  { "id",		&ng_parse_uint32_type	},	\
	  { "addr",		&ng_parse_ipaddr_type	},	\
	  { "port",		&ng_parse_uint16_type	},	\
	  { NULL }						\
}

/* List entry of array returned in NGM_NAT_LIST_REDIRECTS message */
struct ng_nat_listrdrs_entry {
	uint32_t	id;		/* Anything except zero */
	struct in_addr	local_addr;
	struct in_addr	alias_addr;
	struct in_addr	remote_addr;
	uint16_t	local_port;
	uint16_t	alias_port;
	uint16_t	remote_port;
	uint16_t	proto;		/* Valid proto or NG_NAT_REDIRPROTO_ADDR */
	uint16_t	lsnat;		/* LSNAT servers count */
	char		description[NG_NAT_DESC_LENGTH];
};

/* Keep this in sync with the above structure definition */
#define NG_NAT_LISTRDRS_ENTRY_TYPE_INFO(desctype) {			\
	  { "id",		&ng_parse_uint32_type	},	\
	  { "local_addr",	&ng_parse_ipaddr_type	},	\
	  { "alias_addr",	&ng_parse_ipaddr_type	},	\
	  { "remote_addr",	&ng_parse_ipaddr_type	},	\
	  { "local_port",	&ng_parse_uint16_type	},	\
	  { "alias_port",	&ng_parse_uint16_type	},	\
	  { "remote_port",	&ng_parse_uint16_type	},	\
	  { "proto",		&ng_parse_uint16_type	},	\
	  { "lsnat",		&ng_parse_uint16_type	},	\
	  { "description",	(desctype)		},	\
	  { NULL }						\
}

/* Structure returned by NGM_NAT_LIST_REDIRECTS */
struct ng_nat_list_redirects {
	uint32_t		total_count;
	struct ng_nat_listrdrs_entry redirects[];
};

/* Keep this in sync with the above structure definition */
#define NG_NAT_LIST_REDIRECTS_TYPE_INFO(redirtype) {		\
	  { "total_count",	&ng_parse_uint32_type	},	\
	  { "redirects",	(redirtype)		},	\
	  { NULL }						\
}

enum {
	NGM_NAT_SET_IPADDR = 1,
	NGM_NAT_SET_MODE,
	NGM_NAT_SET_TARGET,
	NGM_NAT_REDIRECT_PORT,
	NGM_NAT_REDIRECT_ADDR,
	NGM_NAT_REDIRECT_PROTO,
	NGM_NAT_REDIRECT_DYNAMIC,
	NGM_NAT_REDIRECT_DELETE,
	NGM_NAT_ADD_SERVER,
	NGM_NAT_LIST_REDIRECTS,
	NGM_NAT_PROXY_RULE,
};


code:
/*
 * ng_one2many.h
 */

/*-
 * Copyright (c) 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_one2many.h 219127 2011-03-01 13:10:56Z ae $
 */

#ifndef _NETGRAPH_NG_ONE2MANY_H_
#define _NETGRAPH_NG_ONE2MANY_H_

/* Node type name and magic cookie */
#define NG_ONE2MANY_NODE_TYPE		"one2many"
#define NGM_ONE2MANY_COOKIE		1100897444

/* Hook names */
#define NG_ONE2MANY_HOOK_ONE		"one"
#define NG_ONE2MANY_HOOK_MANY_PREFIX	"many"	 /* append decimal integer */
#define NG_ONE2MANY_HOOK_MANY_FMT	"many%d" /* for use with printf(3) */

/* Maximum number of supported "many" links */
#define NG_ONE2MANY_MAX_LINKS		64

/* Link number used to indicate the "one" hook */
#define NG_ONE2MANY_ONE_LINKNUM		(-1)

/* Algorithms for outgoing packet distribution (XXX only one so far) */
#define NG_ONE2MANY_XMIT_ROUNDROBIN	1	/* round-robin delivery */
#define NG_ONE2MANY_XMIT_ALL		2	/* send packets to all many hooks */
#define	NG_ONE2MANY_XMIT_FAILOVER	3	/* send packets to first active "many" */

/* Algorithms for detecting link failure (XXX only one so far) */
#define NG_ONE2MANY_FAIL_MANUAL		1	/* use enabledLinks[] array */
#define NG_ONE2MANY_FAIL_NOTIFY		2	/* listen to flow control msgs */

/* Node configuration structure */
struct ng_one2many_config {
	u_int32_t	xmitAlg;		/* how to distribute packets */
	u_int32_t	failAlg;		/* how to detect link failure */
	u_char		enabledLinks[NG_ONE2MANY_MAX_LINKS];
};

/* Keep this in sync with the above structure definition */
#define NG_ONE2MANY_CONFIG_TYPE_INFO(atype)	{		\
	  { "xmitAlg",		&ng_parse_uint32_type	},	\
	  { "failAlg",		&ng_parse_uint32_type	},	\
	  { "enabledLinks",	(atype)			},	\
	  { NULL }						\
}

/* Statistics structure (one for each link) */
struct ng_one2many_link_stats {
	u_int64_t	recvOctets;	/* total octets rec'd on link */
	u_int64_t	recvPackets;	/* total pkts rec'd on link */
	u_int64_t	xmitOctets;	/* total octets xmit'd on link */
	u_int64_t	xmitPackets;	/* total pkts xmit'd on link */
	u_int64_t	memoryFailures;	/* times couldn't get mem or mbuf */
};

/* Keep this in sync with the above structure definition */
#define NG_ONE2MANY_LINK_STATS_TYPE_INFO	{		\
	  { "recvOctets",	&ng_parse_uint64_type	},	\
	  { "recvPackets",	&ng_parse_uint64_type	},	\
	  { "xmitOctets",	&ng_parse_uint64_type	},	\
	  { "xmitPackets",	&ng_parse_uint64_type	},	\
	  { "memoryFailures",	&ng_parse_uint64_type	},	\
	  { NULL }						\
}

/* Netgraph control messages */
enum {
	NGM_ONE2MANY_SET_CONFIG,	/* set configuration */
	NGM_ONE2MANY_GET_CONFIG,	/* get configuration */
	NGM_ONE2MANY_GET_STATS,		/* get link stats */
	NGM_ONE2MANY_CLR_STATS,		/* clear link stats */
	NGM_ONE2MANY_GETCLR_STATS,	/* atomically get & clear link stats */
};

#endif /* _NETGRAPH_NG_ONE2MANY_H_ */