xref: /freebsd/sys/netgraph/ng_deflate.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
181ccbd95SGleb Smirnoff /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3fe267a55SPedro F. Giffuni  *
481ccbd95SGleb Smirnoff  * Copyright (c) 2006 Alexander Motin <mav@alkar.net>
581ccbd95SGleb Smirnoff  * All rights reserved.
681ccbd95SGleb Smirnoff  *
781ccbd95SGleb Smirnoff  * Redistribution and use in source and binary forms, with or without
881ccbd95SGleb Smirnoff  * modification, are permitted provided that the following conditions
981ccbd95SGleb Smirnoff  * are met:
1081ccbd95SGleb Smirnoff  * 1. Redistributions of source code must retain the above copyright
1181ccbd95SGleb Smirnoff  *    notice unmodified, this list of conditions, and the following
1281ccbd95SGleb Smirnoff  *    disclaimer.
1381ccbd95SGleb Smirnoff  * 2. Redistributions in binary form must reproduce the above copyright
1481ccbd95SGleb Smirnoff  *    notice, this list of conditions and the following disclaimer in the
1581ccbd95SGleb Smirnoff  *    documentation and/or other materials provided with the distribution.
1681ccbd95SGleb Smirnoff  *
1781ccbd95SGleb Smirnoff  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1881ccbd95SGleb Smirnoff  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1981ccbd95SGleb Smirnoff  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2081ccbd95SGleb Smirnoff  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2181ccbd95SGleb Smirnoff  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2281ccbd95SGleb Smirnoff  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2381ccbd95SGleb Smirnoff  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2481ccbd95SGleb Smirnoff  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2581ccbd95SGleb Smirnoff  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2681ccbd95SGleb Smirnoff  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2781ccbd95SGleb Smirnoff  * SUCH DAMAGE.
2881ccbd95SGleb Smirnoff  */
2981ccbd95SGleb Smirnoff 
3081ccbd95SGleb Smirnoff #ifndef _NETGRAPH_NG_DEFLATE_H_
3181ccbd95SGleb Smirnoff #define _NETGRAPH_NG_DEFLATE_H_
3281ccbd95SGleb Smirnoff 
3381ccbd95SGleb Smirnoff /* Node type name and magic cookie */
3481ccbd95SGleb Smirnoff #define NG_DEFLATE_NODE_TYPE	"deflate"
3581ccbd95SGleb Smirnoff #define NGM_DEFLATE_COOKIE	1166642656
3681ccbd95SGleb Smirnoff 
3781ccbd95SGleb Smirnoff /* Hook names */
3881ccbd95SGleb Smirnoff #define NG_DEFLATE_HOOK_COMP	"comp"		/* compression hook */
3981ccbd95SGleb Smirnoff #define NG_DEFLATE_HOOK_DECOMP	"decomp"	/* decompression hook */
4081ccbd95SGleb Smirnoff 
4181ccbd95SGleb Smirnoff /* Config struct */
4281ccbd95SGleb Smirnoff struct ng_deflate_config {
4381ccbd95SGleb Smirnoff 	u_char		enable;			/* node enabled */
4481ccbd95SGleb Smirnoff 	u_char		windowBits;		/* log2(Window size) */
4581ccbd95SGleb Smirnoff };
4681ccbd95SGleb Smirnoff 
4781ccbd95SGleb Smirnoff /* Keep this in sync with the above structure definition. */
4881ccbd95SGleb Smirnoff #define NG_DEFLATE_CONFIG_INFO	{			\
4981ccbd95SGleb Smirnoff 	{ "enable",	&ng_parse_uint8_type	},	\
5081ccbd95SGleb Smirnoff 	{ "windowBits",	&ng_parse_uint8_type	},	\
5181ccbd95SGleb Smirnoff 	{ NULL }					\
5281ccbd95SGleb Smirnoff }
5381ccbd95SGleb Smirnoff 
5481ccbd95SGleb Smirnoff /* Statistics structure for one direction. */
5581ccbd95SGleb Smirnoff struct ng_deflate_stats {
5681ccbd95SGleb Smirnoff 	uint64_t	FramesPlain;
5781ccbd95SGleb Smirnoff 	uint64_t	FramesComp;
5881ccbd95SGleb Smirnoff 	uint64_t	FramesUncomp;
5981ccbd95SGleb Smirnoff 	uint64_t	InOctets;
6081ccbd95SGleb Smirnoff 	uint64_t	OutOctets;
6181ccbd95SGleb Smirnoff 	uint64_t	Errors;
6281ccbd95SGleb Smirnoff };
6381ccbd95SGleb Smirnoff 
6481ccbd95SGleb Smirnoff /* Keep this in sync with the above structure definition. */
6581ccbd95SGleb Smirnoff #define NG_DEFLATE_STATS_INFO	{				\
6681ccbd95SGleb Smirnoff 	{ "FramesPlain",&ng_parse_uint64_type	},	\
6781ccbd95SGleb Smirnoff 	{ "FramesComp",	&ng_parse_uint64_type	},	\
6881ccbd95SGleb Smirnoff 	{ "FramesUncomp", &ng_parse_uint64_type	},	\
6981ccbd95SGleb Smirnoff 	{ "InOctets",	&ng_parse_uint64_type	},	\
7081ccbd95SGleb Smirnoff 	{ "OutOctets",	&ng_parse_uint64_type	},	\
7181ccbd95SGleb Smirnoff 	{ "Errors",	&ng_parse_uint64_type	},	\
7281ccbd95SGleb Smirnoff 	{ NULL }					\
7381ccbd95SGleb Smirnoff }
7481ccbd95SGleb Smirnoff 
7581ccbd95SGleb Smirnoff /* Netgraph commands */
7681ccbd95SGleb Smirnoff enum {
7781ccbd95SGleb Smirnoff 	NGM_DEFLATE_CONFIG = 1,
7881ccbd95SGleb Smirnoff 	NGM_DEFLATE_RESETREQ,			/* sent either way! */
7981ccbd95SGleb Smirnoff 	NGM_DEFLATE_GET_STATS,
8081ccbd95SGleb Smirnoff 	NGM_DEFLATE_CLR_STATS,
8181ccbd95SGleb Smirnoff 	NGM_DEFLATE_GETCLR_STATS,
8281ccbd95SGleb Smirnoff };
8381ccbd95SGleb Smirnoff 
8481ccbd95SGleb Smirnoff #endif /* _NETGRAPH_NG_DEFLATE_H_ */
85