|
| 1 | +//go:build freebsd || linux |
| 2 | +// +build freebsd linux |
| 3 | + |
| 4 | +/* |
| 5 | + Copyright The containerd Authors. |
| 6 | +
|
| 7 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + you may not use this file except in compliance with the License. |
| 9 | + You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | + Unless required by applicable law or agreed to in writing, software |
| 14 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + See the License for the specific language governing permissions and |
| 17 | + limitations under the License. |
| 18 | +*/ |
| 19 | + |
| 20 | +package netutil |
| 21 | + |
| 22 | +// bridgeConfig describes the bridge plugin |
| 23 | +type bridgeConfig struct { |
| 24 | + PluginType string `json:"type"` |
| 25 | + BrName string `json:"bridge,omitempty"` |
| 26 | + IsGW bool `json:"isGateway,omitempty"` |
| 27 | + IsDefaultGW bool `json:"isDefaultGateway,omitempty"` |
| 28 | + ForceAddress bool `json:"forceAddress,omitempty"` |
| 29 | + IPMasq bool `json:"ipMasq,omitempty"` |
| 30 | + MTU int `json:"mtu,omitempty"` |
| 31 | + HairpinMode bool `json:"hairpinMode,omitempty"` |
| 32 | + PromiscMode bool `json:"promiscMode,omitempty"` |
| 33 | + Vlan int `json:"vlan,omitempty"` |
| 34 | + IPAM map[string]interface{} `json:"ipam"` |
| 35 | +} |
| 36 | + |
| 37 | +func newBridgePlugin(bridgeName string) *bridgeConfig { |
| 38 | + return &bridgeConfig{ |
| 39 | + PluginType: "bridge", |
| 40 | + BrName: bridgeName, |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +func (*bridgeConfig) GetPluginType() string { |
| 45 | + return "bridge" |
| 46 | +} |
| 47 | + |
| 48 | +// portMapConfig describes the portmapping plugin |
| 49 | +type portMapConfig struct { |
| 50 | + PluginType string `json:"type"` |
| 51 | + Capabilities map[string]bool `json:"capabilities"` |
| 52 | +} |
| 53 | + |
| 54 | +func newPortMapPlugin() *portMapConfig { |
| 55 | + return &portMapConfig{ |
| 56 | + PluginType: "portmap", |
| 57 | + Capabilities: map[string]bool{ |
| 58 | + "portMappings": true, |
| 59 | + }, |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +func (*portMapConfig) GetPluginType() string { |
| 64 | + return "portmap" |
| 65 | +} |
| 66 | + |
| 67 | +// firewallConfig describes the firewall plugin |
| 68 | +type firewallConfig struct { |
| 69 | + PluginType string `json:"type"` |
| 70 | + Backend string `json:"backend,omitempty"` |
| 71 | +} |
| 72 | + |
| 73 | +func newFirewallPlugin() *firewallConfig { |
| 74 | + return &firewallConfig{ |
| 75 | + PluginType: "firewall", |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +func (*firewallConfig) GetPluginType() string { |
| 80 | + return "firewall" |
| 81 | +} |
| 82 | + |
| 83 | +// tuningConfig describes the tuning plugin |
| 84 | +type tuningConfig struct { |
| 85 | + PluginType string `json:"type"` |
| 86 | +} |
| 87 | + |
| 88 | +func newTuningPlugin() *tuningConfig { |
| 89 | + return &tuningConfig{ |
| 90 | + PluginType: "tuning", |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +func (*tuningConfig) GetPluginType() string { |
| 95 | + return "tuning" |
| 96 | +} |
| 97 | + |
| 98 | +// https://github.com/containernetworking/plugins/blob/v1.0.1/plugins/ipam/host-local/backend/allocator/config.go#L47-L56 |
| 99 | +type hostLocalIPAMConfig struct { |
| 100 | + Type string `json:"type"` |
| 101 | + Routes []IPAMRoute `json:"routes,omitempty"` |
| 102 | + ResolveConf string `json:"resolveConf,omitempty"` |
| 103 | + DataDir string `json:"dataDir,omitempty"` |
| 104 | + Ranges [][]IPRange `json:"ranges,omitempty"` |
| 105 | +} |
| 106 | + |
| 107 | +func newHostLocalIPAMConfig() *hostLocalIPAMConfig { |
| 108 | + return &hostLocalIPAMConfig{ |
| 109 | + Type: "host-local", |
| 110 | + } |
| 111 | +} |
0 commit comments