/*-1* Copyright (c) 2015 Dmitry Vagin <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#ifndef _NETGRAPH_NG_CHECKSUM_H_27#define _NETGRAPH_NG_CHECKSUM_H_2829/* Node type name. */30#define NG_CHECKSUM_NODE_TYPE "checksum"3132/* Node type cookie. */33#define NGM_CHECKSUM_COOKIE 4394199123435/* Hook names */36#define NG_CHECKSUM_HOOK_IN "in"37#define NG_CHECKSUM_HOOK_OUT "out"3839/* Checksum flags */40#define NG_CHECKSUM_CSUM_IPV4 (CSUM_IP|CSUM_TCP|CSUM_UDP)41#define NG_CHECKSUM_CSUM_IPV6 (CSUM_TCP_IPV6|CSUM_UDP_IPV6)4243/* Netgraph commands understood by this node type */44enum {45NGM_CHECKSUM_GETDLT = 1,46NGM_CHECKSUM_SETDLT,47NGM_CHECKSUM_GETCONFIG,48NGM_CHECKSUM_SETCONFIG,49NGM_CHECKSUM_GETCLR_STATS,50NGM_CHECKSUM_GET_STATS,51NGM_CHECKSUM_CLR_STATS,52};5354/* Parsing declarations */5556#define NG_CHECKSUM_CONFIG_TYPE { \57{ "csum_flags", &ng_parse_uint64_type }, \58{ "csum_offload", &ng_parse_uint64_type }, \59{ NULL } \60}6162#define NG_CHECKSUM_STATS_TYPE { \63{ "Received", &ng_parse_uint64_type }, \64{ "Processed", &ng_parse_uint64_type }, \65{ "Dropped", &ng_parse_uint64_type }, \66{ NULL } \67}6869struct ng_checksum_config {70uint64_t csum_flags;71uint64_t csum_offload;72};7374struct ng_checksum_stats {75uint64_t received;76uint64_t processed;77uint64_t dropped;78};7980struct ng_checksum_vlan_header {81u_int16_t tag;82u_int16_t etype;83};8485#endif /* _NETGRAPH_NG_CHECKSUM_H_ */868788