1303612Sjulian/*-
2303612Sjulian * Copyright (c) 2015 Dmitry Vagin <daemon.hammer@ya.ru>
3303612Sjulian * All rights reserved.
4303612Sjulian *
5303612Sjulian * Redistribution and use in source and binary forms, with or without
6303612Sjulian * modification, are permitted provided that the following conditions
7303612Sjulian * are met:
8303612Sjulian * 1. Redistributions of source code must retain the above copyright
9303612Sjulian *    notice, this list of conditions and the following disclaimer.
10303612Sjulian * 2. Redistributions in binary form must reproduce the above copyright
11303612Sjulian *    notice, this list of conditions and the following disclaimer in the
12303612Sjulian *    documentation and/or other materials provided with the distribution.
13303612Sjulian *
14303612Sjulian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15303612Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16303612Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17303612Sjulian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18303612Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19303612Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20303612Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21303612Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22303612Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23303612Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24303612Sjulian * SUCH DAMAGE.
25303612Sjulian *
26303612Sjulian * $FreeBSD: stable/11/sys/netgraph/ng_checksum.h 309385 2016-12-02 05:36:37Z julian $
27303612Sjulian */
28303612Sjulian
29303612Sjulian#ifndef _NETGRAPH_NG_CHECKSUM_H_
30303612Sjulian#define _NETGRAPH_NG_CHECKSUM_H_
31303612Sjulian
32303612Sjulian/* Node type name. */
33303612Sjulian#define	NG_CHECKSUM_NODE_TYPE	"checksum"
34303612Sjulian
35303612Sjulian/* Node type cookie. */
36303612Sjulian#define	NGM_CHECKSUM_COOKIE	439419912
37303612Sjulian
38303612Sjulian/* Hook names */
39303612Sjulian#define	NG_CHECKSUM_HOOK_IN	"in"
40303612Sjulian#define	NG_CHECKSUM_HOOK_OUT	"out"
41303612Sjulian
42303612Sjulian/* Checksum flags */
43303612Sjulian#define NG_CHECKSUM_CSUM_IPV4	(CSUM_IP|CSUM_TCP|CSUM_UDP)
44303612Sjulian#define NG_CHECKSUM_CSUM_IPV6	(CSUM_TCP_IPV6|CSUM_UDP_IPV6)
45303612Sjulian
46303612Sjulian/* Netgraph commands understood by this node type */
47303612Sjulianenum {
48303612Sjulian	NGM_CHECKSUM_GETDLT = 1,
49303612Sjulian	NGM_CHECKSUM_SETDLT,
50303612Sjulian	NGM_CHECKSUM_GETCONFIG,
51303612Sjulian	NGM_CHECKSUM_SETCONFIG,
52303612Sjulian	NGM_CHECKSUM_GETCLR_STATS,
53303612Sjulian	NGM_CHECKSUM_GET_STATS,
54303612Sjulian	NGM_CHECKSUM_CLR_STATS,
55303612Sjulian};
56303612Sjulian
57303612Sjulian/* Parsing declarations */
58303612Sjulian
59303612Sjulian#define	NG_CHECKSUM_CONFIG_TYPE {				\
60303612Sjulian	{ "csum_flags",		&ng_parse_uint64_type	},	\
61303612Sjulian	{ "csum_offload",	&ng_parse_uint64_type	},	\
62303612Sjulian	{ NULL }						\
63303612Sjulian}
64303612Sjulian
65303612Sjulian#define	NG_CHECKSUM_STATS_TYPE {				\
66303612Sjulian	{ "Received",		&ng_parse_uint64_type	},	\
67303612Sjulian	{ "Processed",		&ng_parse_uint64_type	},	\
68303612Sjulian	{ "Dropped",		&ng_parse_uint64_type	},	\
69303612Sjulian	{ NULL }					\
70303612Sjulian}
71303612Sjulian
72303612Sjulianstruct ng_checksum_config {
73303612Sjulian	uint64_t	csum_flags;
74303612Sjulian	uint64_t	csum_offload;
75303612Sjulian};
76303612Sjulian
77303612Sjulianstruct ng_checksum_stats {
78303612Sjulian	uint64_t	received;
79303612Sjulian	uint64_t	processed;
80303612Sjulian	uint64_t	dropped;
81303612Sjulian};
82303612Sjulian
83303612Sjulianstruct ng_checksum_vlan_header {
84303612Sjulian	u_int16_t tag;
85303612Sjulian	u_int16_t etype;
86303612Sjulian};
87303612Sjulian
88303612Sjulian#endif /* _NETGRAPH_NG_CHECKSUM_H_ */
89