2 * Copyright (C) 2010 by Maxim Ignatenko <gelraen.ua@gmail.com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef _NETGRAPH_NG_PATCH_H_
30 #define _NETGRAPH_NG_PATCH_H_
33 #define NG_PATCH_NODE_TYPE "patch"
35 /* Node type cookie. */
36 #define NGM_PATCH_COOKIE 1262445509
39 #define NG_PATCH_HOOK_IN "in"
40 #define NG_PATCH_HOOK_OUT "out"
42 /* Netgraph commands understood by this node type */
44 NGM_PATCH_SETCONFIG = 1,
48 NGM_PATCH_GETCLR_STATS
53 NG_PATCH_MODE_SET = 1,
54 NG_PATCH_MODE_ADD = 2,
55 NG_PATCH_MODE_SUB = 3,
56 NG_PATCH_MODE_MUL = 4,
57 NG_PATCH_MODE_DIV = 5,
58 NG_PATCH_MODE_NEG = 6,
59 NG_PATCH_MODE_AND = 7,
61 NG_PATCH_MODE_XOR = 9,
62 NG_PATCH_MODE_SHL = 10,
63 NG_PATCH_MODE_SHR = 11
69 uint16_t length; /* 1,2,4 or 8 (bytes) */
73 #define NG_PATCH_OP_TYPE_INFO { \
74 { "value", &ng_parse_uint64_type }, \
75 { "offset", &ng_parse_uint32_type }, \
76 { "length", &ng_parse_uint16_type }, \
77 { "mode", &ng_parse_uint16_type }, \
81 struct ng_patch_config {
84 struct ng_patch_op ops[];
87 #define NG_PATCH_CONFIG_TYPE_INFO { \
88 { "count", &ng_parse_uint32_type }, \
89 { "csum_flags", &ng_parse_uint32_type }, \
90 { "ops", &ng_patch_confarr_type }, \
94 struct ng_patch_stats {
100 #define NG_PATCH_STATS_TYPE_INFO { \
101 { "received", &ng_parse_uint64_type }, \
102 { "patched", &ng_parse_uint64_type }, \
103 { "dropped", &ng_parse_uint64_type }, \
107 #endif /* _NETGRAPH_NG_PATCH_H_ */