Debian Codegraph @

nft/schema/rule.go

raw symbols SCIP
1 /*
2 * This file is part of the go-nft project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Copyright 2021 Red Hat, Inc.
17 *
18 */
19
20 package schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/
21
22 import (
23 "encoding/jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/"
24 "fmtscip-go gomod github.com/golang/go/src go1.16 fmt/"
25 )
26
27 type Rulescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule# struct {
28 Familyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule#Family. string `json:"family"`
29 Tablescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule#Table. string `json:"table"`
30 Chainscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule#Chain. string `json:"chain"`
31 Exprscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule#Expr. []Statementscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement# `json:"expr,omitempty"`
32 Handlescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule#Handle. *int `json:"handle,omitempty"`
33 Indexscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule#Index. *int `json:"index,omitempty"`
34 Commentscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Rule#Comment. string `json:"comment,omitempty"`
35 }
36
37 type Statementscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement# struct {
38 Counterscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#Counter. *Counterscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Counter# `json:"counter,omitempty"`
39 Matchscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#Match. *Matchscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Match# `json:"match,omitempty"`
40 Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#Verdict.
41 Natscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#Nat.
42 }
43
44 type Counterscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Counter# struct {
45 Packetsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Counter#Packets. int `json:"packets"`
46 Bytesscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Counter#Bytes. int `json:"bytes"`
47 }
48
49 type Natscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat# struct {
50 Snatscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Snat. *Snatscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Snat# `json:"snat,omitempty"`
51 Dnatscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Dnat. *Dnatscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Dnat# `json:"dnat,omitempty"`
52 Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Masquerade. *Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade# `json:"masquerade,omitempty"`
53 Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Redirect. *Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect# `json:"redirect,omitempty"`
54 }
55
56 type Snatscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Snat# struct {
57 Addrscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Snat#Addr. *Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"addr,omitempty"`
58 Familyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Snat#Family. *string `json:"family,omitempty"`
59 Portscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Snat#Port. *Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"port,omitempty"`
60 Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Snat#Flags. *Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags# `json:"flags,omitempty"`
61 }
62
63 type Dnatscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Dnat# struct {
64 Addrscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Dnat#Addr. *Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"addr,omitempty"`
65 Familyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Dnat#Family. *string `json:"family,omitempty"`
66 Portscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Dnat#Port. *Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"port,omitempty"`
67 Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Dnat#Flags. *Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags# `json:"flags,omitempty"`
68 }
69
70 const masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/masquerade. = "masquerade"
71
72 type Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade# struct {
73 Enabledscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#Enabled. bool `json:"-"`
74 Portscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#Port. *Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"port,omitempty"`
75 Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#Flags. *Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags# `json:"flags,omitempty"`
76 }
77
78 const redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/redirect. = "redirect"
79
80 type Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect# struct {
81 Enabledscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#Enabled. bool `json:"-"`
82 Portscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#Port. *Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"port,omitempty"`
83 Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#Flags. *Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags# `json:"flags,omitempty"`
84 }
85
86 type Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags# struct {
87 Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#Flags. []string `json:"-"`
88 }
89
90 // NAT Flags
91 const (
92 NATFlagRandomscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/NATFlagRandom. = "random"
93 NATFlagFullyRandomscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/NATFlagFullyRandom. = "fully-random"
94 NATFlagPersistentscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/NATFlagPersistent. = "persistent"
95 )
96
97 type Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict# struct {
98 SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#SimpleVerdict.
99 Jumpscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#Jump. *ToTargetscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/ToTarget# `json:"jump,omitempty"`
100 Gotoscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#Goto. *ToTargetscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/ToTarget# `json:"goto,omitempty"`
101 }
102
103 type SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict# struct {
104 Acceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Accept. bool `json:"-"`
105 Continuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Continue. bool `json:"-"`
106 Dropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Drop. bool `json:"-"`
107 Returnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Return. bool `json:"-"`
108 }
109
110 type ToTargetscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/ToTarget# struct {
111 Targetscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/ToTarget#Target. string `json:"target"`
112 }
113
114 type Matchscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Match# struct {
115 Opscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Match#Op. string `json:"op"`
116 Leftscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Match#Left. Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"left"`
117 Rightscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Match#Right. Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# `json:"right"`
118 }
119
120 type Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression# struct {
121 Stringscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#String. *string `json:"-"`
122 Boolscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Bool. *bool `json:"-"`
123 Float64scip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Float64. *float64 `json:"-"`
124 Payloadscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Payload. *Payloadscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Payload# `json:"payload,omitempty"`
125 // RowData accepts arbitrary data which cannot be composed from the existing schema.
126 // Use `json.RawMessage()` or `[]byte()` for the value.
127 // Example:
128 // `schema.Expression{RowData: json.RawMessage(`{"meta":{"key":"iifname"}}`)}`
129 RowDatascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#RowData. jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.16 `encoding/json`/RawMessage# `json:"-"`
130 }
131
132 type Payloadscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Payload# struct {
133 Protocolscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Payload#Protocol. string `json:"protocol"`
134 Fieldscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Payload#Field. string `json:"field"`
135 }
136
137 // Verdict Operations
138 const (
139 VerdictAcceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictAccept. = "accept"
140 VerdictContinuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictContinue. = "continue"
141 VerdictDropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictDrop. = "drop"
142 VerdictReturnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictReturn. = "return"
143 )
144
145 // Match Operators
146 const (
147 OperANDscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperAND. = "&" // Binary AND
148 OperORscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperOR. = "|" // Binary OR
149 OperXORscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperXOR. = "^" // Binary XOR
150 OperLSHscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperLSH. = "<<" // Left shift
151 OperRSHscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperRSH. = ">>" // Right shift
152 OperEQscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperEQ. = "==" // Equal
153 OperNEQscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperNEQ. = "!=" // Not equal
154 OperLSscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperLS. = "<" // Less than
155 OperGRscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperGR. = ">" // Greater than
156 OperLSEscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperLSE. = "<=" // Less than or equal to
157 OperGREscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperGRE. = ">=" // Greater than or equal to
158 OperINscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/OperIN. = "in" // Perform a lookup, i.e. test if bits on RHS are contained in LHS value
159 )
160
161 // Payload Expressions
162 const (
163 PayloadKeyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadKey. = "payload"
164 // Ethernet
165 PayloadProtocolEtherscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadProtocolEther. = "ether"
166 PayloadFieldEtherDAddrscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldEtherDAddr. = "daddr"
167 PayloadFieldEtherSAddrscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldEtherSAddr. = "saddr"
168 PayloadFieldEtherTypescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldEtherType. = "type"
169
170 // IP (common)
171 PayloadFieldIPVerscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIPVer. = "version"
172 PayloadFieldIPDscpscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIPDscp. = "dscp"
173 PayloadFieldIPEcnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIPEcn. = "ecn"
174 PayloadFieldIPLenscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIPLen. = "length"
175 PayloadFieldIPSAddrscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIPSAddr. = "saddr"
176 PayloadFieldIPDAddrscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIPDAddr. = "daddr"
177
178 // IPv4
179 PayloadProtocolIP4scip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadProtocolIP4. = "ip"
180 PayloadFieldIP4HdrLenscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP4HdrLen. = "hdrlength"
181 PayloadFieldIP4Idscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP4Id. = "id"
182 PayloadFieldIP4FragOffscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP4FragOff. = "frag-off"
183 PayloadFieldIP4Ttlscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP4Ttl. = "ttl"
184 PayloadFieldIP4Protocolscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP4Protocol. = "protocol"
185 PayloadFieldIP4Chksumscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP4Chksum. = "checksum"
186
187 // IPv6
188 PayloadProtocolIP6scip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadProtocolIP6. = "ip6"
189 PayloadFieldIP6FlowLabelscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP6FlowLabel. = "flowlabel"
190 PayloadFieldIP6NextHdrscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP6NextHdr. = "nexthdr"
191 PayloadFieldIP6HopLimitscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PayloadFieldIP6HopLimit. = "hoplimit"
192 )
193
194 func (s Statementscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#) MarshalJSONscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#MarshalJSON().() ([]byte, error) {
195 type _Statement Statementscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#
196 statement := _Statement(s)
197
198 // Convert to a dynamic structure
199 data, err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Marshal().(statement)
200 if err != nil {
201 return nil, err
202 }
203 dynamicStructure := make(map[string]jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.16 `encoding/json`/RawMessage#)
204 if err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().(data, &dynamicStructure); err != nil {
205 return nil, err
206 }
207
208 switch {
209 case s.Acceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Accept.:
210 dynamicStructure[VerdictAcceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictAccept.] = nil
211 case s.Continuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Continue.:
212 dynamicStructure[VerdictContinuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictContinue.] = nil
213 case s.Dropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Drop.:
214 dynamicStructure[VerdictDropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictDrop.] = nil
215 case s.Returnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Return.:
216 dynamicStructure[VerdictReturnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictReturn.] = nil
217 case s.Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Masquerade. != nil && s.Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Masquerade..Enabledscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#Enabled. && s.Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Masquerade..Portscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#Port. == nil && s.Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Masquerade..Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#Flags. == nil:
218 dynamicStructure[masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/masquerade.] = nil
219 case s.Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Redirect. != nil && s.Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Redirect..Enabledscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#Enabled. && s.Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Redirect..Portscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#Port. == nil && s.Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Redirect..Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#Flags. == nil:
220 dynamicStructure[redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/redirect.] = nil
221 }
222
223 data, err = jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Marshal().(dynamicStructure)
224 if err != nil {
225 return nil, err
226 }
227 return data, nil
228 }
229
230 func (s *Statementscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#) UnmarshalJSONscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#UnmarshalJSON().(data []byte) error {
231 type _Statement Statementscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#
232 statement := _Statement{}
233
234 if err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().(data, &statement); err != nil {
235 return err
236 }
237 *s = Statementscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Statement#(statement)
238
239 dynamicStructure := make(map[string]jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.16 `encoding/json`/RawMessage#)
240 if err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().(data, &dynamicStructure); err != nil {
241 return err
242 }
243 _, s.Acceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Accept. = dynamicStructure[VerdictAcceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictAccept.]
244 _, s.Continuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Continue. = dynamicStructure[VerdictContinuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictContinue.]
245 _, s.Dropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Drop. = dynamicStructure[VerdictDropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictDrop.]
246 _, s.Returnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Return. = dynamicStructure[VerdictReturnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/VerdictReturn.]
247
248 if _, masqueradeDefined := dynamicStructure[masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/masquerade.]; s.Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Masquerade. == nil && masqueradeDefined {
249 s.Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Masquerade. = &Masqueradescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#{Enabledscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Masquerade#Enabled.: true}
250 }
251
252 if _, redirectDefined := dynamicStructure[redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/redirect.]; s.Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Redirect. == nil && redirectDefined {
253 s.Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Nat#Redirect. = &Redirectscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#{Enabledscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Redirect#Enabled.: true}
254 }
255
256 return nil
257 }
258
259 func (e Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#) MarshalJSONscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#MarshalJSON().() ([]byte, error) {
260 var dynamicStruct interface{}
261
262 switch {
263 case e.RowDatascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#RowData. != nil:
264 return e.RowDatascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#RowData., nil
265 case e.Stringscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#String. != nil:
266 dynamicStruct = *e.Stringscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#String.
267 case e.Float64scip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Float64. != nil:
268 dynamicStruct = *e.Float64scip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Float64.
269 case e.Boolscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Bool. != nil:
270 dynamicStruct = *e.Boolscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Bool.
271 default:
272 type _Expression Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#
273 dynamicStruct = _Expression(e)
274 }
275
276 return jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Marshal().(dynamicStruct)
277 }
278
279 func (e *Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#) UnmarshalJSONscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#UnmarshalJSON().(data []byte) error {
280 var dynamicStruct interface{}
281 if err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().(data, &dynamicStruct); err != nil {
282 return err
283 }
284
285 switch dynamicStruct.(type) {
286 case string:
287 d := dynamicStruct.(string)
288 e.Stringscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#String. = &d
289 case float64:
290 d := dynamicStruct.(float64)
291 e.Float64scip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Float64. = &d
292 case bool:
293 d := dynamicStruct.(bool)
294 e.Boolscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Bool. = &d
295 case []interface{}:
296 e.RowDatascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#RowData. = data
297 case map[string]interface{}:
298 type _Expression Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#
299 expression := _Expression(*e)
300 if err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().(data, &expression); err != nil {
301 return err
302 }
303 *e = Expressionscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#(expression)
304 default:
305 return fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.16 fmt/Errorf().("unsupported field type in expression: %T(%v)", dynamicStruct, dynamicStruct)
306 }
307
308 if e.Stringscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#String. == nil && e.Float64scip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Float64. == nil && e.Boolscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Bool. == nil && e.Payloadscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#Payload. == nil {
309 e.RowDatascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Expression#RowData. = data
310 }
311
312 return nil
313 }
314
315 func (f Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#) MarshalJSONscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#MarshalJSON().() ([]byte, error) {
316 var dynamicStruct interface{}
317
318 switch flagCount := len(f.Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#Flags.); {
319 case flagCount == 1:
320 dynamicStruct = f.Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#Flags.[0]
321 case flagCount > 1:
322 dynamicStruct = f.Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#Flags.
323 }
324
325 return jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Marshal().(dynamicStruct)
326 }
327
328 func (f *Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#) UnmarshalJSONscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#UnmarshalJSON().(data []byte) error {
329 var dynamicStruct interface{}
330 if err := jsonscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.16 `encoding/json`/Unmarshal().(data, &dynamicStruct); err != nil {
331 return err
332 }
333
334 switch v := dynamicStruct.(type) {
335 case string:
336 f.Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#Flags. = []string{v}
337 case []interface{}:
338 for _, val := range v {
339 stringVal, ok := val.(string)
340 if !ok {
341 return fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.16 fmt/Errorf().("flags values require string type: %T(%v)", dynamicStruct, dynamicStruct)
342 }
343 f.Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#Flags. = append(f.Flagsscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Flags#Flags., stringVal)
344 }
345 default:
346 return fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.16 fmt/Errorf().("flags values require string type: %T(%v)", dynamicStruct, dynamicStruct)
347 }
348
349 return nil
350 }
351
352 func Acceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Accept().() Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict# {
353 return Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#SimpleVerdict.: SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#{Acceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Accept.: true}}
354 }
355
356 func Continuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Continue().() Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict# {
357 return Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#SimpleVerdict.: SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#{Continuescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Continue.: true}}
358 }
359
360 func Dropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Drop().() Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict# {
361 return Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#SimpleVerdict.: SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#{Dropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Drop.: true}}
362 }
363
364 func Returnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Return().() Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict# {
365 return Verdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#{SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Verdict#SimpleVerdict.: SimpleVerdictscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#{Returnscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/SimpleVerdict#Return.: true}}
366 }