Debian Codegraph @

nft/chain.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 nftscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/
21
22 import (
23 "github.com/networkplumbing/go-nft/nft/schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/"
24 )
25
26 type ChainTypescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainType# string
27 type ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook# string
28 type ChainPolicyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainPolicy# string
29
30 // Chain Types
31 const (
32 TypeFilterscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/TypeFilter. ChainTypescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainType# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.TypeFilterscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/TypeFilter.
33 TypeNATscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/TypeNAT. ChainTypescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainType# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.TypeNATscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/TypeNAT.
34 TypeRoutescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/TypeRoute. ChainTypescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainType# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.TypeRoutescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/TypeRoute.
35 )
36
37 // Chain Hooks
38 const (
39 HookPreRoutingscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/HookPreRouting. ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.HookPreRoutingscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/HookPreRouting.
40 HookInputscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/HookInput. ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.HookInputscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/HookInput.
41 HookOutputscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/HookOutput. ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.HookOutputscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/HookOutput.
42 HookForwardscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/HookForward. ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.HookForwardscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/HookForward.
43 HookPostRoutingscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/HookPostRouting. ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.HookPostRoutingscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/HookPostRouting.
44 HookIngressscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/HookIngress. ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.HookIngressscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/HookIngress.
45 )
46
47 // Chain Policies
48 const (
49 PolicyAcceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/PolicyAccept. ChainPolicyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainPolicy# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.PolicyAcceptscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PolicyAccept.
50 PolicyDropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/PolicyDrop. ChainPolicyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainPolicy# = schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.PolicyDropscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/PolicyDrop.
51 )
52
53 // NewRegularChain returns a new schema chain structure for a regular chain.
54 func NewRegularChainscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/NewRegularChain().(table *schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.Tablescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Table#, name string) *schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain# {
55 return NewChainscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/NewChain().(table, name, nil, nil, nil, nil)
56 }
57
58 // NewChain returns a new schema chain structure for a base chain.
59 // For base chains, all arguments are required except the policy.
60 // Missing arguments will cause an error once the config is applied.
61 func NewChainscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/NewChain().(table *schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.Tablescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Table#, name string, ctype *ChainTypescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainType#, hook *ChainHookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainHook#, prio *int, policy *ChainPolicyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft`/ChainPolicy#) *schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain# {
62 c := &schemascip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/.Chainscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#{
63 Familyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#Family.: table.Familyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Table#Family.,
64 Tablescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#Table.: table.Namescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Table#Name.,
65 Namescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#Name.: name,
66 }
67
68 if ctype != nil {
69 c.Typescip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#Type. = string(*ctype)
70 }
71 if hook != nil {
72 c.Hookscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#Hook. = string(*hook)
73 }
74 if prio != nil {
75 c.Prioscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#Prio. = prio
76 }
77 if policy != nil {
78 c.Policyscip-go gomod github.com/networkplumbing/go-nft . `github.com/networkplumbing/go-nft/nft/schema`/Chain#Policy. = string(*policy)
79 }
80
81 return c
82 }