diff --git a/examples/vpp_proxy/main.go b/examples/vpp_proxy/main.go index c5b693a488..3a7737e1a0 100644 --- a/examples/vpp_proxy/main.go +++ b/examples/vpp_proxy/main.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,16 +27,13 @@ import ( "git.fd.io/govpp.git/proxy" "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" + "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009" + interfaces "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/interface" + "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2009/vpe" ) -// TODO update example for VPP >=20.05 -// (changed govpp's api.Channel for api.Connection in binapi NewServiceClient creation) - // VPP version used in the example. -const vppVersion = vpp2001.Version +const vppVersion = vpp2009.Version var ( address = flag.String("addr", ":9191", "agent address") @@ -100,9 +97,9 @@ func proxyBinapi(client *proxy.Client) { log.Printf("Version: %+v", version) // List interfaces - stream, err := interfaceSvc.DumpSwInterface(context.Background(), &interfaces.SwInterfaceDump{}) + stream, err := interfaceSvc.SwInterfaceDump(context.Background(), &interfaces.SwInterfaceDump{}) if err != nil { - log.Fatalln("DumpSwInterface failed:", err) + log.Fatalln("SwInterfaceDump failed:", err) } log.Printf("dumping interfaces") for { diff --git a/go.mod b/go.mod index af56902240..fd9a503817 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module go.ligato.io/vpp-agent/v3 go 1.13 require ( - git.fd.io/govpp.git v0.3.6-0.20210601140839-da95997338b7 + git.fd.io/govpp.git v0.3.6-0.20210810100027-c0da1f2999a6 github.com/Shopify/sarama v1.20.1 // indirect github.com/alecthomas/jsonschema v0.0.0-20200217214135-7152f22193c9 github.com/alicebob/miniredis v2.5.0+incompatible // indirect diff --git a/go.sum b/go.sum index b3b202fd14..0cbe00796c 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -git.fd.io/govpp.git v0.3.6-0.20210601140839-da95997338b7 h1:IPy+QyEmQxFbVRFolJ4ofP+ZLN4HfzmK+QCPycmaINc= -git.fd.io/govpp.git v0.3.6-0.20210601140839-da95997338b7/go.mod h1:OCVd4W8SH+666KRQoMj6PM+oipLDZAHhqMz9B1TGbgI= +git.fd.io/govpp.git v0.3.6-0.20210810100027-c0da1f2999a6 h1:dZPJ0JRnoHevxdXhonJG9MtkYD6qXitFMr7gAONwLks= +git.fd.io/govpp.git v0.3.6-0.20210810100027-c0da1f2999a6/go.mod h1:OCVd4W8SH+666KRQoMj6PM+oipLDZAHhqMz9B1TGbgI= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= diff --git a/plugins/govppmux/plugin_impl_govppmux.go b/plugins/govppmux/plugin_impl_govppmux.go index c97abc4fb2..381c38d7ce 100644 --- a/plugins/govppmux/plugin_impl_govppmux.go +++ b/plugins/govppmux/plugin_impl_govppmux.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -41,7 +41,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp" "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi" - _ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2101" diff --git a/plugins/govppmux/vppcalls/vpp2001/vpe_vppcalls.go b/plugins/govppmux/vppcalls/vpp2001/vpe_vppcalls.go deleted file mode 100644 index 38fd18794e..0000000000 --- a/plugins/govppmux/vppcalls/vpp2001/vpe_vppcalls.go +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "fmt" - "strings" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memclnt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" -) - -// Ping sends VPP control ping. -func (h *VpeHandler) Ping(ctx context.Context) error { - _, err := h.vpe.ControlPing(ctx, new(vpe.ControlPing)) - return err -} - -// GetVersion retrieves version info from VPP. -func (h *VpeHandler) GetVersion(ctx context.Context) (*vppcalls.VersionInfo, error) { - version, err := h.vpe.ShowVersion(ctx, new(vpe.ShowVersion)) - if err != nil { - return nil, err - } - info := &vppcalls.VersionInfo{ - Program: strings.TrimRight(version.Program, "\x00"), - Version: strings.TrimRight(version.Version, "\x00"), - BuildDate: strings.TrimRight(version.BuildDate, "\x00"), - BuildDirectory: strings.TrimRight(version.BuildDirectory, "\x00"), - } - return info, nil -} - -// GetSession retrieves session info from VPP. -func (h *VpeHandler) GetSession(ctx context.Context) (*vppcalls.SessionInfo, error) { - pong, err := h.vpe.ControlPing(ctx, new(vpe.ControlPing)) - if err != nil { - return nil, err - } - info := &vppcalls.SessionInfo{ - PID: pong.VpePID, - ClientIdx: pong.ClientIndex, - } - - systime, err := h.vpe.ShowVpeSystemTime(ctx, new(vpe.ShowVpeSystemTime)) - if err != nil { - // TODO: log returned error as warning? - } else { - info.Uptime = float64(systime.VpeSystemTime) - } - return info, nil -} - -// GetModules retrieves module info from VPP. -func (h *VpeHandler) GetModules(ctx context.Context) ([]vppcalls.APIModule, error) { - versions, err := h.memclnt.APIVersions(ctx, new(memclnt.APIVersions)) - if err != nil { - return nil, err - } - var modules []vppcalls.APIModule - for _, v := range versions.APIVersions { - modules = append(modules, vppcalls.APIModule{ - Name: strings.TrimSuffix(strings.TrimRight(v.Name, "\x00"), ".api"), - Major: v.Major, - Minor: v.Minor, - Patch: v.Patch, - }) - } - return modules, nil -} - -func (h *VpeHandler) GetPlugins(ctx context.Context) ([]vppcalls.PluginInfo, error) { - const ( - pluginPathPrefix = "Plugin path is:" - pluginNameSuffix = "_plugin.so" - ) - - out, err := h.RunCli(ctx, "show plugins") - if err != nil { - return nil, err - } - - lines := strings.Split(out, "\n") - if len(lines) == 0 { - return nil, fmt.Errorf("empty output for 'show plugins'") - } - pluginPathLine := strings.TrimSpace(lines[0]) - if !strings.HasPrefix(pluginPathLine, pluginPathPrefix) { - return nil, fmt.Errorf("unexpected output for 'show plugins'") - } - pluginPath := strings.TrimSpace(strings.TrimPrefix(pluginPathLine, pluginPathPrefix)) - if len(pluginPath) == 0 { - return nil, fmt.Errorf("plugin path not found in output for 'show plugins'") - } - - var plugins []vppcalls.PluginInfo - for _, line := range lines { - fields := strings.Fields(line) - if len(fields) < 3 { - continue - } - var i int - if _, err := fmt.Sscanf(fields[0], "%d.", &i); err != nil { - continue - } - if i <= 0 { - continue - } - plugin := vppcalls.PluginInfo{ - Name: strings.TrimSuffix(fields[1], pluginNameSuffix), - Path: fields[1], - Version: fields[2], - Description: strings.Join(fields[3:], " "), - } - plugins = append(plugins, plugin) - } - - return plugins, nil -} - -func (h *VpeHandler) GetThreads(ctx context.Context) ([]vppcalls.ThreadInfo, error) { - resp, err := h.vpe.ShowThreads(ctx, &vpe.ShowThreads{}) - if err != nil { - return nil, err - } - threads := make([]vppcalls.ThreadInfo, len(resp.ThreadData)) - for i, thread := range resp.ThreadData { - threads[i] = vppcalls.ThreadInfo{ - Name: string(thread.Name), - ID: thread.ID, - Type: string(thread.Type), - PID: thread.PID, - Core: thread.Core, - CPUID: thread.CPUID, - CPUSocket: thread.CPUSocket, - } - } - return threads, nil -} - -// RunCli sends CLI command to VPP and returns response. -func (h *VpeHandler) RunCli(ctx context.Context, cmd string) (string, error) { - resp, err := h.vpe.CliInband(ctx, &vpe.CliInband{ - Cmd: cmd, - }) - if err != nil { - return "", errors.Wrapf(err, "VPP CLI command '%s' failed", cmd) - } - return resp.Reply, nil -} diff --git a/plugins/govppmux/vppcalls/vpp2001/vppcalls_handler.go b/plugins/govppmux/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 2b4d25f512..0000000000 --- a/plugins/govppmux/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - - "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memclnt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" -) - -func init() { - msgs := vpp.Messages( - vpe.AllMessages, - memclnt.AllMessages, - ) - vppcalls.AddVersion(vpp2001.Version, msgs.AllMessages(), func(client vpp.Client) vppcalls.VppCoreAPI { - ch, _ := client.NewAPIChannel() - return NewVpeHandler(ch) - }) -} - -type VpeHandler struct { - memclnt memclnt.RPCService - vpe vpe.RPCService -} - -func NewVpeHandler(ch govppapi.Channel) vppcalls.VppCoreAPI { - return &VpeHandler{ - memclnt: memclnt.NewServiceClient(ch), - vpe: vpe.NewServiceClient(ch), - } -} diff --git a/plugins/telemetry/telemetry.go b/plugins/telemetry/telemetry.go index ef82851dc1..bc20504aae 100644 --- a/plugins/telemetry/telemetry.go +++ b/plugins/telemetry/telemetry.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -39,7 +39,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" "go.ligato.io/vpp-agent/v3/proto/ligato/configurator" - _ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2101" diff --git a/plugins/telemetry/vppcalls/vpp2001/telemetry_vppcalls.go b/plugins/telemetry/vppcalls/vpp2001/telemetry_vppcalls.go deleted file mode 100644 index 35300593f7..0000000000 --- a/plugins/telemetry/vppcalls/vpp2001/telemetry_vppcalls.go +++ /dev/null @@ -1,314 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "fmt" - "regexp" - "strconv" - "strings" - - govppapi "git.fd.io/govpp.git/api" - - "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls" -) - -func (h *TelemetryHandler) GetSystemStats(context.Context) (*govppapi.SystemStats, error) { - return nil, nil -} - -var ( - // Regular expression to parse output from `show memory` - memoryRe = regexp.MustCompile( - `Thread\s+(\d+)\s+(\w+).?\s+` + - `virtual memory start 0x[0-9a-f]+, size ([\dkmg\.]+), ([\dkmg\.]+) pages, page size ([\dkmg\.]+)\s+` + - `(?:page information not available.*\s+)*` + - `(?:(?:\s+(?:numa [\d]+|not mapped|unknown): [\dkmg\.]+ pages, [\dkmg\.]+\s+)*\s+)*` + - `\s+total: ([\dkmgKMG\.]+), used: ([\dkmgKMG\.]+), free: ([\dkmgKMG\.]+), trimmable: ([\dkmgKMG\.]+)\s+` + - `free chunks (\d+)\s+free fastbin blks (\d+)\s+max total allocated\s+([\dkmgKMG\.]+)`, - ) -) - -// GetMemory retrieves `show memory` info. -func (h *TelemetryHandler) GetMemory(ctx context.Context) (*vppcalls.MemoryInfo, error) { - input, err := h.vpe.RunCli(context.TODO(), "show memory main-heap verbose") - if err != nil { - return nil, err - } - - threadMatches := memoryRe.FindAllStringSubmatch(input, -1) - - if len(threadMatches) == 0 && input != "" { - return nil, fmt.Errorf("invalid memory input: %q", input) - } - - var threads []vppcalls.MemoryThread - for _, matches := range threadMatches { - fields := matches[1:] - if len(fields) != 12 { - return nil, fmt.Errorf("invalid memory data %v for thread: %q", fields, matches[0]) - } - id, err := strconv.ParseUint(fields[0], 10, 64) - if err != nil { - return nil, err - } - thread := &vppcalls.MemoryThread{ - ID: uint(id), - Name: fields[1], - Size: strToUint64(fields[2]), - Pages: strToUint64(fields[3]), - PageSize: strToUint64(fields[4]), - Total: strToUint64(fields[5]), - Used: strToUint64(fields[6]), - Free: strToUint64(fields[7]), - Trimmable: strToUint64(fields[8]), - FreeChunks: strToUint64(fields[9]), - FreeFastbinBlks: strToUint64(fields[10]), - MaxTotalAlloc: strToUint64(fields[11]), - } - threads = append(threads, *thread) - } - - info := &vppcalls.MemoryInfo{ - Threads: threads, - } - - return info, nil -} - -func (h *TelemetryHandler) GetInterfaceStats(context.Context) (*govppapi.InterfaceStats, error) { - return nil, nil -} - -var ( - // Regular expression to parse output from `show node counters` - nodeCountersRe = regexp.MustCompile(`^\s+(\d+)\s+([\w-\/]+)\s+(.+)$`) -) - -// GetNodeCounters retrieves node counters info. -func (h *TelemetryHandler) GetNodeCounters(ctx context.Context) (*vppcalls.NodeCounterInfo, error) { - data, err := h.vpe.RunCli(context.TODO(), "show node counters") - if err != nil { - return nil, err - } - - var counters []vppcalls.NodeCounter - - for i, line := range strings.Split(string(data), "\n") { - // Skip empty lines - if strings.TrimSpace(line) == "" { - continue - } - // Check first line - if i == 0 { - fields := strings.Fields(line) - // Verify header - if len(fields) != 3 || fields[0] != "Count" { - return nil, fmt.Errorf("invalid header for `show node counters` received: %q", line) - } - continue - } - - // Parse lines using regexp - matches := nodeCountersRe.FindStringSubmatch(line) - if len(matches)-1 != 3 { - return nil, fmt.Errorf("parsing failed for `show node counters` line: %q", line) - } - fields := matches[1:] - - counters = append(counters, vppcalls.NodeCounter{ - Value: strToUint64(fields[0]), - Node: fields[1], - Name: fields[2], - }) - } - - info := &vppcalls.NodeCounterInfo{ - Counters: counters, - } - - return info, nil -} - -var ( - // Regular expression to parse output from `show runtime` - runtimeRe = regexp.MustCompile(`(?:-+\n)?(?:Thread (\d+) (\w+)(?: \(lcore \d+\))?\n)?` + - `Time ([0-9\.e-]+), average vectors/node ([0-9\.e-]+), last (\d+) main loops ([0-9\.e-]+) per node ([0-9\.e-]+)\s+` + - `vector rates in ([0-9\.e-]+), out ([0-9\.e-]+), drop ([0-9\.e-]+), punt ([0-9\.e-]+)\n` + - `\s+Name\s+State\s+Calls\s+Vectors\s+Suspends\s+Clocks\s+Vectors/Call\s+(?:Perf Ticks\s+)?` + - `((?:[\w-:\.]+\s+\w+(?:[ -]\w+)*\s+\d+\s+\d+\s+\d+\s+[0-9\.e-]+\s+[0-9\.e-]+\s+)+)`) - runtimeItemsRe = regexp.MustCompile(`([\w-:\.]+)\s+(\w+(?:[ -]\w+)*)\s+(\d+)\s+(\d+)\s+(\d+)\s+([0-9\.e-]+)\s+([0-9\.e-]+)\s+`) -) - -// GetRuntimeInfo retrieves how runtime info. -func (h *TelemetryHandler) GetRuntimeInfo(ctx context.Context) (*vppcalls.RuntimeInfo, error) { - input, err := h.vpe.RunCli(context.TODO(), "show runtime") - if err != nil { - return nil, err - } - - threadMatches := runtimeRe.FindAllStringSubmatch(input, -1) - - if len(threadMatches) == 0 && input != "" { - return nil, fmt.Errorf("invalid runtime input: %q", input) - } - - var threads []vppcalls.RuntimeThread - for _, matches := range threadMatches { - fields := matches[1:] - if len(fields) != 12 { - return nil, fmt.Errorf("invalid runtime data for thread (len=%v): %q", len(fields), matches[0]) - } - thread := vppcalls.RuntimeThread{ - ID: uint(strToUint64(fields[0])), - Name: fields[1], - Time: strToFloat64(fields[2]), - AvgVectorsPerNode: strToFloat64(fields[3]), - LastMainLoops: strToUint64(fields[4]), - VectorsPerMainLoop: strToFloat64(fields[5]), - VectorLengthPerNode: strToFloat64(fields[6]), - VectorRatesIn: strToFloat64(fields[7]), - VectorRatesOut: strToFloat64(fields[8]), - VectorRatesDrop: strToFloat64(fields[9]), - VectorRatesPunt: strToFloat64(fields[10]), - } - - itemMatches := runtimeItemsRe.FindAllStringSubmatch(fields[11], -1) - for _, matches := range itemMatches { - fields := matches[1:] - if len(fields) != 7 { - return nil, fmt.Errorf("invalid runtime data for thread item: %q", matches[0]) - } - thread.Items = append(thread.Items, vppcalls.RuntimeItem{ - Name: fields[0], - State: fields[1], - Calls: strToUint64(fields[2]), - Vectors: strToUint64(fields[3]), - Suspends: strToUint64(fields[4]), - Clocks: strToFloat64(fields[5]), - VectorsPerCall: strToFloat64(fields[6]), - }) - } - - threads = append(threads, thread) - } - - info := &vppcalls.RuntimeInfo{ - Threads: threads, - } - - return info, nil -} - -var ( - // Regular expression to parse output from `show buffers` - buffersRe = regexp.MustCompile( - `^(\w+(?:[ \-]\w+)*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\dkmg\.]+)\s+([\dkmg\.]+)\s+([\dkmg\.]+)\s+([\dkmg\.]+)(?:\s+)?$`, - ) -) - -// GetBuffersInfo retrieves buffers info from VPP. -func (h *TelemetryHandler) GetBuffersInfo(ctx context.Context) (*vppcalls.BuffersInfo, error) { - data, err := h.vpe.RunCli(context.TODO(), "show buffers") - if err != nil { - return nil, err - } - - var items []vppcalls.BuffersItem - - for i, line := range strings.Split(string(data), "\n") { - // Skip empty lines - if strings.TrimSpace(line) == "" { - continue - } - // Check first line - if i == 0 { - fields := strings.Fields(line) - // Verify header - if len(fields) != 11 || fields[0] != "Pool" { - return nil, fmt.Errorf("invalid header for `show buffers` received: %q", line) - } - continue - } - - // Parse lines using regexp - matches := buffersRe.FindStringSubmatch(line) - if len(matches)-1 != 9 { - return nil, fmt.Errorf("parsing failed (%d matches) for `show buffers` line: %q", len(matches), line) - } - fields := matches[1:] - - items = append(items, vppcalls.BuffersItem{ - //ThreadID: uint(strToUint64(fields[0])), - Name: fields[0], - Index: uint(strToUint64(fields[1])), - Size: strToUint64(fields[3]), - Alloc: strToUint64(fields[7]), - Free: strToUint64(fields[5]), - //NumAlloc: strToUint64(fields[6]), - //NumFree: strToUint64(fields[7]), - }) - } - - info := &vppcalls.BuffersInfo{ - Items: items, - } - - return info, nil -} - -// GetThreads retrieves info about the VPP threads -func (h *TelemetryHandler) GetThreads(ctx context.Context) (*vppcalls.ThreadsInfo, error) { - threads, err := h.vpe.GetThreads(ctx) - if err != nil { - return nil, err - } - var items []vppcalls.ThreadsItem - for _, thread := range threads { - items = append(items, vppcalls.ThreadsItem{ - Name: thread.Name, - ID: thread.ID, - Type: thread.Type, - PID: thread.PID, - CPUID: thread.CPUID, - Core: thread.Core, - CPUSocket: thread.CPUSocket, - }) - } - return &vppcalls.ThreadsInfo{ - Items: items, - }, err -} - -func strToFloat64(s string) float64 { - // Replace 'k' (thousands) with 'e3' to make it parsable with strconv - s = strings.Replace(s, "k", "e3", 1) - s = strings.Replace(s, "K", "e3", 1) - s = strings.Replace(s, "m", "e6", 1) - s = strings.Replace(s, "M", "e6", 1) - s = strings.Replace(s, "g", "e9", 1) - s = strings.Replace(s, "G", "e9", 1) - - num, err := strconv.ParseFloat(s, 10) - if err != nil { - return 0 - } - return num -} - -func strToUint64(s string) uint64 { - return uint64(strToFloat64(s)) -} diff --git a/plugins/telemetry/vppcalls/vpp2001/telemetry_vppcalls_test.go b/plugins/telemetry/vppcalls/vpp2001/telemetry_vppcalls_test.go deleted file mode 100644 index add752e144..0000000000 --- a/plugins/telemetry/vppcalls/vpp2001/telemetry_vppcalls_test.go +++ /dev/null @@ -1,524 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "context" - "testing" - - . "github.com/onsi/gomega" - - "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" -) - -func TestGetBuffers(t *testing.T) { - ctx, handler := testSetup(t) - defer ctx.TeardownTestCtx() - - const reply = `Pool Name Index NUMA Size Data Size Total Avail Cached Used -default-numa-0 0 0 2304 2048 17290 17290 0 0 ` - ctx.MockVpp.MockReply(&vpe.CliInbandReply{ - Reply: reply, - }) - - info, err := handler.GetBuffersInfo(context.TODO()) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(info.Items).To(HaveLen(1)) - Expect(info.Items[0]).To(Equal(vppcalls.BuffersItem{ - //ThreadID: 0, - Name: "default-numa-0", - Index: 0, - Size: 2304, - Alloc: 0, - Free: 17290, - //NumAlloc: 256, - //NumFree: 19, - })) - /*Expect(info.Items[1]).To(Equal(vppcalls.BuffersItem{ - ThreadID: 0, - Name: "lacp-ethernet", - Index: 1, - Size: 256, - Alloc: 1130000, - Free: 27000, - NumAlloc: 512, - NumFree: 12, - })) - Expect(info.Items[2]).To(Equal(vppcalls.BuffersItem{ - ThreadID: 0, - Name: "marker-ethernet", - Index: 2, - Size: 256, - Alloc: 1110000000, - Free: 0, - NumAlloc: 0, - NumFree: 0, - }))*/ -} - -func TestGetRuntime(t *testing.T) { - tests := []struct { - name string - reply string - threadCount int - itemCount int - itemIdx int - item vppcalls.RuntimeItem - }{ - { - name: "19.08", - reply: `Time 84714.7, average vectors/node 0.00, last 128 main loops 0.00 per node 0.00 - vector rates in 0.0000e0, out 0.0000e0, drop 0.0000e0, punt 0.0000e0 - Name State Calls Vectors Suspends Clocks Vectors/Call -acl-plugin-fa-cleaner-process event wait 6 5 1 1.10e4 0.00 -api-rx-from-ring active 0 0 7870 8.63e5 0.00 -avf-process event wait 0 0 1 4.53e3 0.00 -bfd-process event wait 0 0 1 7.01e3 0.00 -bond-process event wait 0 0 1 2.95e3 0.00 -cdp-process any wait 0 0 1 5.46e3 0.00 -dhcp-client-process any wait 0 0 847 6.63e3 0.00 -dhcp6-client-cp-process any wait 0 0 1 1.52e3 0.00 -dhcp6-pd-client-cp-process any wait 0 0 1 1.71e3 0.00 -dhcp6-pd-reply-publisher-proce event wait 0 0 1 9.73e2 0.00 -dhcp6-reply-publisher-process event wait 0 0 1 9.12e2 0.00 -dns-resolver-process any wait 0 0 85 8.98e3 0.00 -fib-walk any wait 0 0 42247 1.08e4 0.00 -flow-report-process any wait 0 0 1 1.33e3 0.00 -flowprobe-timer-process any wait 0 0 1 5.18e3 0.00 -gbp-scanner event wait 0 0 1 5.17e3 0.00 -igmp-timer-process event wait 0 0 1 6.53e3 0.00 -ikev2-manager-process any wait 0 0 84353 7.84e3 0.00 -ioam-export-process any wait 0 0 1 1.64e3 0.00 -ip-neighbor-scan-process any wait 0 0 1412 9.65e3 0.00 -ip-route-resolver-process any wait 0 0 847 6.12e3 0.00 -ip4-reassembly-expire-walk any wait 0 0 8464 6.92e3 0.00 -ip6-icmp-neighbor-discovery-ev any wait 0 0 84353 8.58e3 0.00 -ip6-reassembly-expire-walk any wait 0 0 8464 6.67e3 0.00 -l2fib-mac-age-scanner-process event wait 0 0 1 1.98e3 0.00 -lacp-process event wait 0 0 1 1.58e5 0.00 -lisp-retry-service any wait 0 0 42247 1.08e4 0.00 -lldp-process event wait 0 0 1 8.76e4 0.00 -memif-process event wait 0 0 1 9.34e3 0.00 -nat-det-expire-walk done 1 0 0 2.92e3 0.00 -nat-ha-process event wait 0 0 1 4.12e3 0.00 -nat64-expire-walk event wait 0 0 1 2.41e3 0.00 -nsh-md2-ioam-export-process any wait 0 0 1 1.10e4 0.00 -perfmon-periodic-process event wait 0 0 1 3.61e7 0.00 -rd-cp-process any wait 0 0 1 1.55e3 0.00 -send-dhcp6-client-message-proc any wait 0 0 1 2.22e3 0.00 -send-dhcp6-pd-client-message-p any wait 0 0 1 1.43e3 0.00 -send-rs-process any wait 0 0 1 1.49e3 0.00 -startup-config-process done 1 0 1 5.68e3 0.00 -statseg-collector-process time wait 0 0 8464 2.79e5 0.00 -udp-ping-process any wait 0 0 1 6.96e3 0.00 -unix-cli-127.0.0.1:mdns done 2 0 4 2.14e9 0.00 -unix-epoll-input polling 20325059 0 0 1.13e7 0.00 -vhost-user-process any wait 0 0 1 3.73e3 0.00 -vhost-user-send-interrupt-proc any wait 0 0 1 1.28e3 0.00 -vpe-link-state-process event wait 0 0 1 9.63e2 0.00 -vpe-oam-process any wait 0 0 41419 9.59e3 0.00 -vxlan-gpe-ioam-export-process any wait 0 0 1 1.60e3 0.00 -wildcard-ip4-arp-publisher-pro event wait 0 0 1 1.44e3 0.00 -`, - threadCount: 1, - itemCount: 49, - item: vppcalls.RuntimeItem{ - Name: "acl-plugin-fa-cleaner-process", - State: "event wait", - Calls: 6, - Vectors: 5, - Suspends: 1, - Clocks: 1.10e4, - VectorsPerCall: 0, - }, - }, - { - name: "one thread", - reply: `Time 3151.2, average vectors/node 1.00, last 128 main loops 0.00 per node 0.00 - vector rates in 2.8561e-3, out 0.0000e0, drop 4.4428e-3, punt 0.0000e0 - Name State Calls Vectors Suspends Clocks Vectors/Call Perf Ticks -acl-plugin-fa-cleaner-process event wait 0 0 1 5.14e3 0.00 -af-packet-input interrupt wa 9 9 0 1.55e5 1.00 -api-rx-from-ring any wait 0 0 4735 4.72e6 0.00 -avf-process event wait 0 0 1 4.52e3 0.00 -bfd-process event wait 0 0 1 6.59e3 0.00 -bond-process event wait 0 0 1 2.07e3 0.00 -cdp-process any wait 0 0 1 4.43e3 0.00 -dhcp-client-process any wait 0 0 32 8.73e3 0.00 -dhcp6-client-cp-process any wait 0 0 1 1.94e3 0.00 -dhcp6-pd-client-cp-process any wait 0 0 1 1.73e3 0.00 -dhcp6-pd-reply-publisher-proce event wait 0 0 1 1.01e3 0.00 -dhcp6-reply-publisher-process event wait 0 0 1 8.75e2 0.00 -dns-resolver-process any wait 0 0 4 2.11e4 0.00 -error-drop active 14 14 0 1.29e5 1.00 -ethernet-input active 9 9 0 6.41e5 1.00 -fib-walk any wait 0 0 1571 2.12e4 0.00 -flow-report-process any wait 0 0 1 1.13e3 0.00 -flowprobe-timer-process any wait 0 0 1 5.27e3 0.00 -gbp-scanner event wait 0 0 1 5.36e3 0.00 -igmp-timer-process event wait 0 0 1 5.24e4 0.00 -ikev2-manager-process any wait 0 0 3132 1.32e4 0.00 -ioam-export-process any wait 0 0 1 1.18e3 0.00 -ip-neighbor-scan-process any wait 0 0 53 1.49e4 0.00 -ip-route-resolver-process any wait 0 0 32 5.80e3 0.00 -ip4-drop active 5 5 0 3.13e3 1.00 -ip4-local active 5 5 0 1.00e4 1.00 -ip4-lookup active 5 5 0 1.08e6 1.00 -ip4-reassembly-expire-walk any wait 0 0 315 1.27e4 0.00 -ip6-icmp-neighbor-discovery-ev any wait 0 0 3132 1.12e4 0.00 -ip6-input active 9 9 0 3.41e3 1.00 -ip6-not-enabled active 9 9 0 1.47e3 1.00 -ip6-reassembly-expire-walk any wait 0 0 315 8.52e3 0.00 -l2fib-mac-age-scanner-process event wait 0 0 1 1.18e3 0.00 -lacp-process event wait 0 0 1 1.84e5 0.00 -lisp-retry-service any wait 0 0 1571 1.49e4 0.00 -lldp-process event wait 0 0 1 5.81e5 0.00 -memif-process any wait 0 0 1168 1.11e5 0.00 -nat-det-expire-walk done 1 0 0 2.50e3 0.00 -nat64-expire-walk event wait 0 0 1 1.34e4 0.00 -nsh-md2-ioam-export-process any wait 0 0 1 7.89e3 0.00 -perfmon-periodic-process event wait 0 0 1 1.18e8 0.00 -rd-cp-process any wait 0 0 1 1.52e3 0.00 -send-dhcp6-client-message-proc any wait 0 0 1 1.56e3 0.00 -send-dhcp6-pd-client-message-p any wait 0 0 1 1.53e3 0.00 -send-rs-process any wait 0 0 1 1.69e3 0.00 -startup-config-process done 1 0 1 6.13e3 0.00 -statseg-collector-process time wait 0 0 315 3.77e5 0.00 -udp-ping-process any wait 0 0 1 1.62e4 0.00 -unix-cli-127.0.0.1:39670 event wait 0 0 103 2.26e7 0.00 -unix-cli-127.0.0.1:40652 active 1 0 3 4.64e9 0.00 -unix-epoll-input polling 1698354 0 0 5.00e6 0.00 -vhost-user-process any wait 0 0 1 5.29e3 0.00 -vhost-user-send-interrupt-proc any wait 0 0 1 1.88e3 0.00 -vpe-link-state-process event wait 0 0 15 2.33e4 0.00 -vpe-oam-process any wait 0 0 1540 1.21e4 0.00 -vxlan-gpe-ioam-export-process any wait 0 0 1 1.38e3 0.00 -wildcard-ip4-arp-publisher-pro event wait 0 0 1 2.24e3 0.00 -`, - threadCount: 1, - itemCount: 57, - itemIdx: 1, - item: vppcalls.RuntimeItem{ - Name: "af-packet-input", - State: "interrupt wa", - Calls: 9, - Vectors: 9, - Suspends: 0, - Clocks: 1.55e5, - VectorsPerCall: 1, - }, - }, - { - name: "three threads", - reply: `Thread 0 vpp_main (lcore 0) -Time 21.5, average vectors/node 0.00, last 128 main loops 0.00 per node 0.00 - vector rates in 0.0000e0, out 5.0000e-2, drop 0.0000e0, punt 0.0000e0 - Name State Calls Vectors Suspends Clocks Vectors/Call -acl-plugin-fa-cleaner-process event wait 6 5 1 3.12e4 0.00 -api-rx-from-ring any wait 0 0 31 8.61e6 0.00 -avf-process event wait 0 0 1 7.79e3 0.00 -bfd-process event wait 0 0 1 6.80e3 0.00 -cdp-process any wait 0 0 1 1.78e8 0.00 -dhcp-client-process any wait 0 0 1 2.59e3 0.00 -dns-resolver-process any wait 0 0 1 3.35e3 0.00 -fib-walk any wait 0 0 11 1.08e4 0.00 -flow-report-process any wait 0 0 1 1.64e3 0.00 -flowprobe-timer-process any wait 0 0 1 1.16e4 0.00 -igmp-timer-process event wait 0 0 1 1.81e4 0.00 -ikev2-manager-process any wait 0 0 22 5.47e3 0.00 -ioam-export-process any wait 0 0 1 3.26e3 0.00 -ip-route-resolver-process any wait 0 0 1 1.69e3 0.00 -ip4-reassembly-expire-walk any wait 0 0 3 4.27e3 0.00 -ip6-icmp-neighbor-discovery-ev any wait 0 0 22 4.48e3 0.00 -ip6-reassembly-expire-walk any wait 0 0 3 6.88e3 0.00 -l2fib-mac-age-scanner-process event wait 0 0 1 3.94e3 0.00 -lacp-process event wait 0 0 1 1.35e8 0.00 -lisp-retry-service any wait 0 0 11 9.68e3 0.00 -lldp-process event wait 0 0 1 1.49e8 0.00 -memif-process event wait 0 0 1 2.67e4 0.00 -nat-det-expire-walk done 1 0 0 5.42e3 0.00 -nat64-expire-walk event wait 0 0 1 5.87e4 0.00 -rd-cp-process any wait 0 0 614363 3.93e2 0.00 -send-rs-process any wait 0 0 1 3.22e3 0.00 -startup-config-process done 1 0 1 1.33e4 0.00 -udp-ping-process any wait 0 0 1 3.69e4 0.00 -unix-cli-127.0.0.1:38448 active 0 0 23 6.72e7 0.00 -unix-epoll-input polling 8550283 0 0 3.77e3 0.00 -vhost-user-process any wait 0 0 1 2.48e3 0.00 -vhost-user-send-interrupt-proc any wait 0 0 1 1.43e3 0.00 -vpe-link-state-process event wait 0 0 1 1.58e3 0.00 -vpe-oam-process any wait 0 0 11 9.20e3 0.00 -vxlan-gpe-ioam-export-process any wait 0 0 1 1.59e4 0.00 -wildcard-ip4-arp-publisher-pro event wait 0 0 1 1.03e4 0.00 ---------------- -Thread 1 vpp_wk_0 (lcore 1) -Time 21.5, average vectors/node 0.00, last 128 main loops 0.00 per node 0.00 - vector rates in 0.0000e0, out 0.0000e0, drop 0.0000e0, punt 0.0000e0 - Name State Calls Vectors Suspends Clocks Vectors/Call -unix-epoll-input polling 15251181 0 0 3.67e3 0.00 ---------------- -Thread 2 vpp_wk_1 (lcore 2) -Time 21.5, average vectors/node 0.00, last 128 main loops 0.00 per node 0.00 - vector rates in 0.0000e0, out 0.0000e0, drop 0.0000e0, punt 0.0000e0 - Name State Calls Vectors Suspends Clocks Vectors/Call -unix-epoll-input polling 20563870 0 0 3.56e3 0.00 -`, - threadCount: 3, - itemCount: 36, - item: vppcalls.RuntimeItem{ - Name: "acl-plugin-fa-cleaner-process", - State: "event wait", - Calls: 6, - Vectors: 5, - Suspends: 1, - Clocks: 3.12e4, - VectorsPerCall: 0, - }, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ctx, handler := testSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpe.CliInbandReply{Reply: test.reply}) - - info, err := handler.GetRuntimeInfo(context.TODO()) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(len(info.Threads)).To(Equal(test.threadCount)) - Expect(info.Threads[0].Items).To(HaveLen(test.itemCount)) - Expect(info.Threads[0].Items[test.itemIdx]).To(Equal(test.item)) - }) - } -} - -func TestGetMemory(t *testing.T) { - tests := []struct { - name string - reply string - threadCount int - threadIdx int - thread vppcalls.MemoryThread - }{ - { - name: "single", - reply: `Thread 0 vpp_main - virtual memory start 0x7f435fa4a000, size 1048640k, 262160 pages, page size 4k - numa 0: 10084 pages, 40336k - not mapped: 252076 pages, 1008304k - total: 1.00G, used: 31.56M, free: 992.50M, trimmable: 991.39M - free chunks 285 free fastbin blks 0 - max total allocated 1.00G -`, - threadCount: 1, - threadIdx: 0, - thread: vppcalls.MemoryThread{ - ID: 0, - Name: "vpp_main", - Size: 1048.64e6, - Pages: 262160, - PageSize: 4000, - Used: 31.56e6, - Total: 1.00e9, - Free: 992.50e6, - Trimmable: 991.39e6, - FreeChunks: 285, - FreeFastbinBlks: 0, - MaxTotalAlloc: 1e9, - }, - }, - { - name: "unknown", - reply: `Thread 0 vpp_main - virtual memory start 0x7f435fa4a000, size 1048640k, 262160 pages, page size 4k - numa 0: 10084 pages, 40336k - not mapped: 252076 pages, 1008304k - unknown: 368 pages, 1472k - total: 1.00G, used: 31.56M, free: 992.50M, trimmable: 991.39M - free chunks 285 free fastbin blks 0 - max total allocated 1.00G -`, - threadCount: 1, - threadIdx: 0, - thread: vppcalls.MemoryThread{ - ID: 0, - Name: "vpp_main", - Size: 1048.64e6, - Pages: 262160, - PageSize: 4000, - Used: 31.56e6, - Total: 1.00e9, - Free: 992.50e6, - Trimmable: 991.39e6, - FreeChunks: 285, - FreeFastbinBlks: 0, - MaxTotalAlloc: 1e9, - }, - }, - { - name: "3 workers", - reply: `Thread 0 vpp_main - virtual memory start 0x7f435fa4a000, size 1048640k, 262160 pages, page size 4k - numa 0: 10084 pages, 40336k - not mapped: 252076 pages, 1008304k - total: 1.00G, used: 31.56M, free: 992.50M, trimmable: 991.39M - free chunks 285 free fastbin blks 0 - max total allocated 1.00G - -Thread 1 vpp_wk_0 - virtual memory start 0x7f435fa4a000, size 1048640k, 262160 pages, page size 4k - numa 0: 10084 pages, 40336k - not mapped: 252076 pages, 1008304k - total: 1.00G, used: 31.56M, free: 992.50M, trimmable: 991.39M - free chunks 284 free fastbin blks 0 - max total allocated 1.00G - -Thread 2 vpp_wk_1 - virtual memory start 0x7f435fa4a000, size 1048640k, 262160 pages, page size 4k - numa 0: 10084 pages, 40336k - not mapped: 252076 pages, 1008304k - total: 1.00G, used: 31.56M, free: 992.50M, trimmable: 991.39M - free chunks 285 free fastbin blks 0 - max total allocated 1.00G - -Thread 3 vpp_wk_2 - virtual memory start 0x7f435fa4a000, size 1048640k, 262160 pages, page size 4k - numa 0: 10084 pages, 40336k - not mapped: 252076 pages, 1008304k - total: 1.00G, used: 31.56M, free: 992.50M, trimmable: 991.39M - free chunks 285 free fastbin blks 0 - max total allocated 1.00G -`, - threadCount: 4, - threadIdx: 1, - thread: vppcalls.MemoryThread{ - ID: 1, - Name: "vpp_wk_0", - Size: 1048.64e6, - Pages: 262160, - PageSize: 4000, - Used: 31.56e6, - Total: 1.00e9, - Free: 992.50e6, - Trimmable: 991.39e6, - FreeChunks: 284, - FreeFastbinBlks: 0, - MaxTotalAlloc: 1e9, - }, - }, - { - name: "19.08 update", - reply: `Thread 0 vpp_main - virtual memory start 0x7f435fa4a000, size 1048640k, 262160 pages, page size 4k - page information not available (errno 1) - total: 1.00G, used: 31.56M, free: 992.50M, trimmable: 991.39M - free chunks 285 free fastbin blks 0 - max total allocated 1.00G -`, - threadCount: 1, - threadIdx: 0, - thread: vppcalls.MemoryThread{ - ID: 0, - Name: "vpp_main", - Size: 1048.64e6, - Pages: 262160, - PageSize: 4000, - Used: 31.56e6, - Total: 1e9, - Free: 992.50e6, - Trimmable: 991.39e6, - FreeChunks: 285, - FreeFastbinBlks: 0, - MaxTotalAlloc: 1e9, - }, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ctx, handler := testSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpe.CliInbandReply{Reply: test.reply}) - - info, err := handler.GetMemory(context.TODO()) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(info.Threads).To(HaveLen(test.threadCount)) - Expect(info.Threads[test.threadIdx]).To(Equal(test.thread)) - }) - } -} - -func TestGetNodeCounters(t *testing.T) { - ctx, handler := testSetup(t) - defer ctx.TeardownTestCtx() - - const reply = ` Count Node Reason - 32 ipsec-output-ip4 IPSec policy protect - 32 esp-encrypt ESP pkts received - 64 ipsec-input-ip4 IPSEC pkts received - 32 ip4-icmp-input unknown type - 32 ip4-icmp-input echo replies sent - 14 ethernet-input l3 mac mismatch - 1 arp-input ARP replies sent - 4 ip4-input ip4 spoofed local-address packet drops - 2 memif1/1-output interface is down - 1 cdp-input good cdp packets (processed) -` - ctx.MockVpp.MockReply(&vpe.CliInbandReply{ - Reply: reply, - }) - - info, err := handler.GetNodeCounters(context.TODO()) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(info.Counters).To(HaveLen(10)) - Expect(info.Counters[0]).To(Equal(vppcalls.NodeCounter{ - Value: 32, - Node: "ipsec-output-ip4", - Name: "IPSec policy protect", - })) - Expect(info.Counters[6]).To(Equal(vppcalls.NodeCounter{ - Value: 1, - Node: "arp-input", - Name: "ARP replies sent", - })) - Expect(info.Counters[7]).To(Equal(vppcalls.NodeCounter{ - Value: 4, - Node: "ip4-input", - Name: "ip4 spoofed local-address packet drops", - })) - Expect(info.Counters[8]).To(Equal(vppcalls.NodeCounter{ - Value: 2, - Node: "memif1/1-output", - Name: "interface is down", - })) - Expect(info.Counters[9]).To(Equal(vppcalls.NodeCounter{ - Value: 1, - Node: "cdp-input", - Name: "good cdp packets (processed)", - })) -} - -func testSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.TelemetryVppAPI) { - ctx := vppmock.SetupTestCtx(t) - handler := vpp2001.NewTelemetryVppHandler(ctx.MockChannel) - return ctx, handler -} diff --git a/plugins/telemetry/vppcalls/vpp2001/vppcalls_handler.go b/plugins/telemetry/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 932426d71c..0000000000 --- a/plugins/telemetry/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - - vpe_vppcalls "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls" - vpe_vpp2001 "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/telemetry/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memclnt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" -) - -func init() { - msgs := vpp.Messages( - vpe.AllMessages, - memclnt.AllMessages, - ) - vppcalls.AddHandlerVersion(vpp2001.Version, msgs.AllMessages(), func(c vpp.Client) vppcalls.TelemetryVppAPI { - ch, _ := c.NewAPIChannel() - return NewTelemetryVppHandler(ch) - }) -} - -type TelemetryHandler struct { - vpe vpe_vppcalls.VppCoreAPI -} - -func NewTelemetryVppHandler(ch govppapi.Channel) vppcalls.TelemetryVppAPI { - return &TelemetryHandler{ - vpe: vpe_vpp2001.NewVpeHandler(ch), - } -} diff --git a/plugins/vpp/abfplugin/abfplugin.go b/plugins/vpp/abfplugin/abfplugin.go index 73054c6c0d..e89ee8d51a 100644 --- a/plugins/vpp/abfplugin/abfplugin.go +++ b/plugins/vpp/abfplugin/abfplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/abfplugin/vppcalls/vpp2001/abf_vppcalls.go b/plugins/vpp/abfplugin/vppcalls/vpp2001/abf_vppcalls.go deleted file mode 100644 index 365020f00d..0000000000 --- a/plugins/vpp/abfplugin/vppcalls/vpp2001/abf_vppcalls.go +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "github.com/go-errors/errors" - - vpp_abf "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/abf" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - abf "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/abf" -) - -const ( - // NextHopViaLabelUnset constant has to be assigned into the field next hop via label - // in abf_policy_add_del binary message if next hop via label is not defined. - NextHopViaLabelUnset uint32 = 0xfffff + 1 - - // ClassifyTableIndexUnset is a default value for field classify_table_index - // in abf_policy_add_del binary message. - ClassifyTableIndexUnset = ^uint32(0) -) - -// GetAbfVersion retrieves version of the VPP ABF plugin -func (h *ABFVppHandler) GetAbfVersion() (ver string, err error) { - req := &vpp_abf.AbfPluginGetVersion{} - reply := &vpp_abf.AbfPluginGetVersionReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return "", err - } - - return fmt.Sprintf("%d.%d", reply.Major, reply.Minor), nil -} - -// AddAbfPolicy creates new ABF entry together with a list of forwarding paths -func (h *ABFVppHandler) AddAbfPolicy(policyID, aclID uint32, abfPaths []*abf.ABF_ForwardingPath) error { - if err := h.abfAddDelPolicy(policyID, aclID, abfPaths, true); err != nil { - return errors.Errorf("failed to add ABF policy %d (ACL: %v): %v", policyID, aclID, err) - } - return nil -} - -// DeleteAbfPolicy removes existing ABF entry -func (h *ABFVppHandler) DeleteAbfPolicy(policyID uint32, abfPaths []*abf.ABF_ForwardingPath) error { - if err := h.abfAddDelPolicy(policyID, 0, abfPaths, false); err != nil { - return errors.Errorf("failed to delete ABF policy %d: %v", policyID, err) - } - return nil -} - -// AbfAttachInterfaceIPv4 attaches IPv4 interface to the ABF -func (h *ABFVppHandler) AbfAttachInterfaceIPv4(policyID, ifIdx, priority uint32) error { - if err := h.abfAttachDetachInterface(policyID, ifIdx, priority, true, false); err != nil { - return errors.Errorf("failed to attach IPv4 interface %d to ABF policy %d: %v", ifIdx, policyID, err) - } - return nil -} - -// AbfDetachInterfaceIPv4 detaches IPV4 interface from the ABF -func (h *ABFVppHandler) AbfDetachInterfaceIPv4(policyID, ifIdx, priority uint32) error { - if err := h.abfAttachDetachInterface(policyID, ifIdx, priority, false, false); err != nil { - return errors.Errorf("failed to detach IPv4 interface %d from ABF policy %d: %v", ifIdx, policyID, err) - } - return nil -} - -// AbfAttachInterfaceIPv6 attaches IPv6 interface to the ABF -func (h *ABFVppHandler) AbfAttachInterfaceIPv6(policyID, ifIdx, priority uint32) error { - if err := h.abfAttachDetachInterface(policyID, ifIdx, priority, true, true); err != nil { - return errors.Errorf("failed to attach IPv6 interface %d to ABF policy %d: %v", ifIdx, policyID, err) - } - return nil -} - -// AbfDetachInterfaceIPv6 detaches IPv6 interface from the ABF -func (h *ABFVppHandler) AbfDetachInterfaceIPv6(policyID, ifIdx, priority uint32) error { - if err := h.abfAttachDetachInterface(policyID, ifIdx, priority, false, true); err != nil { - return errors.Errorf("failed to detach IPv6 interface %d from ABF policy %d: %v", ifIdx, policyID, err) - } - return nil -} - -func (h *ABFVppHandler) abfAttachDetachInterface(policyID, ifIdx, priority uint32, isAdd, isIPv6 bool) error { - req := &vpp_abf.AbfItfAttachAddDel{ - IsAdd: isAdd, - Attach: vpp_abf.AbfItfAttach{ - PolicyID: policyID, - SwIfIndex: interface_types.InterfaceIndex(ifIdx), - Priority: priority, - IsIPv6: isIPv6, - }, - } - reply := &vpp_abf.AbfItfAttachAddDelReply{} - - return h.callsChannel.SendRequest(req).ReceiveReply(reply) -} - -func (h *ABFVppHandler) abfAddDelPolicy(policyID, aclID uint32, abfPaths []*abf.ABF_ForwardingPath, isAdd bool) error { - req := &vpp_abf.AbfPolicyAddDel{ - IsAdd: isAdd, - Policy: vpp_abf.AbfPolicy{ - PolicyID: policyID, - ACLIndex: aclID, - Paths: h.toFibPaths(abfPaths), - NPaths: uint8(len(abfPaths)), - }, - } - reply := &vpp_abf.AbfPolicyAddDelReply{} - - return h.callsChannel.SendRequest(req).ReceiveReply(reply) -} - -func (h *ABFVppHandler) toFibPaths(abfPaths []*abf.ABF_ForwardingPath) (fibPaths []vpp_abf.FibPath) { - var err error - for _, abfPath := range abfPaths { - // fib path interface - ifData, exists := h.ifIndexes.LookupByName(abfPath.InterfaceName) - if !exists { - continue - } - - fibPath := vpp_abf.FibPath{ - SwIfIndex: ifData.SwIfIndex, - Weight: uint8(abfPath.Weight), - Preference: uint8(abfPath.Preference), - Type: setFibPathType(abfPath.Dvr), - } - if fibPath.Nh, fibPath.Proto, err = setFibPathNhAndProto(abfPath.NextHopIp); err != nil { - h.log.Errorf("ABF path next hop error: %v", err) - } - fibPaths = append(fibPaths, fibPath) - } - - return fibPaths -} - -// supported cases are DVR and normal -func setFibPathType(isDvr bool) vpp_abf.FibPathType { - if isDvr { - return fib_types.FIB_API_PATH_TYPE_DVR - } - return fib_types.FIB_API_PATH_TYPE_NORMAL -} - -// resolve IP address and return FIB path next hop (IP address) and IPv4/IPv6 version -func setFibPathNhAndProto(ipStr string) (nh vpp_abf.FibPathNh, proto vpp_abf.FibPathNhProto, err error) { - netIP := net.ParseIP(ipStr) - if netIP == nil { - return nh, proto, errors.Errorf("failed to parse next hop IP address %s", ipStr) - } - var au fib_types.AddressUnion - if ipv4 := netIP.To4(); ipv4 == nil { - var address fib_types.IP6Address - proto = fib_types.FIB_API_PATH_NH_PROTO_IP6 - copy(address[:], netIP[:]) - au.SetIP6(address) - } else { - var address fib_types.IP4Address - proto = fib_types.FIB_API_PATH_NH_PROTO_IP4 - copy(address[:], netIP[12:]) - au.SetIP4(address) - } - return vpp_abf.FibPathNh{ - Address: au, - ViaLabel: NextHopViaLabelUnset, - ClassifyTableIndex: ClassifyTableIndexUnset, - }, proto, nil -} diff --git a/plugins/vpp/abfplugin/vppcalls/vpp2001/abf_vppcalls_test.go b/plugins/vpp/abfplugin/vppcalls/vpp2001/abf_vppcalls_test.go deleted file mode 100644 index 7c1a61e0e4..0000000000 --- a/plugins/vpp/abfplugin/vppcalls/vpp2001/abf_vppcalls_test.go +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/aclidx" - vpp_abf "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/abf" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - abf "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/abf" -) - -func TestGetABFVersion(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfPluginGetVersionReply{ - Major: 1, - Minor: 0, - }) - version, err := abfHandler.GetAbfVersion() - - Expect(err).To(BeNil()) - Expect(version).To(Equal("1.0")) -} - -func TestAddABFPolicy(t *testing.T) { - ctx, abfHandler, ifIndexes := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfPolicyAddDelReply{}) - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{ - SwIfIndex: 5, - }) - ifIndexes.Put("if2", &ifaceidx.IfaceMetadata{ - SwIfIndex: 10, - }) - - err := abfHandler.AddAbfPolicy(1, 2, []*abf.ABF_ForwardingPath{ - { - InterfaceName: "if1", - NextHopIp: "10.0.0.1", - }, - { - InterfaceName: "if2", - NextHopIp: "ffff::", - }, - }) - - Expect(err).To(BeNil()) - req, ok := ctx.MockChannel.Msg.(*vpp_abf.AbfPolicyAddDel) - Expect(ok).To(BeTrue()) - Expect(req.IsAdd).To(BeTrue()) - Expect(req.Policy.PolicyID).To(Equal(uint32(1))) - Expect(req.Policy.ACLIndex).To(Equal(uint32(2))) - Expect(req.Policy.NPaths).To(Equal(uint8(2))) - Expect(req.Policy.Paths[0].SwIfIndex).To(Equal(uint32(5))) - Expect(req.Policy.Paths[0].Nh.Address.GetIP4()).To(BeEquivalentTo(vpp_abf.IP4Address([4]uint8{10, 0, 0, 1}))) - Expect(req.Policy.Paths[1].SwIfIndex).To(Equal(uint32(10))) - Expect(req.Policy.Paths[1].Nh.Address.GetIP6()).To(BeEquivalentTo(vpp_abf.IP6Address([16]uint8{255, 255}))) -} - -func TestAddABFPolicyError(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfPolicyAddDelReply{ - Retval: 1, - }) - - err := abfHandler.AddAbfPolicy(1, 2, nil) - - Expect(err).ToNot(BeNil()) -} - -func TestDeleteABFPolicy(t *testing.T) { - ctx, abfHandler, ifIndexes := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfPolicyAddDelReply{}) - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{ - SwIfIndex: 5, - }) - ifIndexes.Put("if2", &ifaceidx.IfaceMetadata{ - SwIfIndex: 10, - }) - - err := abfHandler.DeleteAbfPolicy(1, []*abf.ABF_ForwardingPath{ - { - InterfaceName: "if1", - NextHopIp: "10.0.0.1", - }, - { - InterfaceName: "if2", - NextHopIp: "ffff::", - }, - }) - - Expect(err).To(BeNil()) - req, ok := ctx.MockChannel.Msg.(*vpp_abf.AbfPolicyAddDel) - Expect(ok).To(BeTrue()) - Expect(req.IsAdd).To(BeFalse()) - Expect(req.Policy.PolicyID).To(Equal(uint32(1))) - Expect(req.Policy.NPaths).To(Equal(uint8(2))) - Expect(req.Policy.Paths[0].SwIfIndex).To(Equal(uint32(5))) - Expect(req.Policy.Paths[0].Nh.Address.XXX_UnionData[:4]).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) - Expect(req.Policy.Paths[1].SwIfIndex).To(Equal(uint32(10))) - Expect(req.Policy.Paths[1].Nh.Address.XXX_UnionData[:]).To(BeEquivalentTo(net.ParseIP("ffff::").To16())) -} - -func TestDeleteABFPolicyError(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfPolicyAddDelReply{ - Retval: 1, - }) - - err := abfHandler.DeleteAbfPolicy(1, nil) - - Expect(err).ToNot(BeNil()) -} - -func TestAttachABFInterfaceIPv4(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{}) - - err := abfHandler.AbfAttachInterfaceIPv4(1, 2, 3) - - Expect(err).To(BeNil()) - req, ok := ctx.MockChannel.Msg.(*vpp_abf.AbfItfAttachAddDel) - Expect(ok).To(BeTrue()) - Expect(req.IsAdd).To(BeTrue()) - Expect(req.Attach.PolicyID).To(Equal(uint32(1))) - Expect(req.Attach.SwIfIndex).To(BeEquivalentTo(uint32(2))) - Expect(req.Attach.Priority).To(Equal(uint32(3))) - Expect(req.Attach.IsIPv6).To(BeFalse()) -} - -func TestAttachABFInterfaceIPv4Error(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{ - Retval: -1, - }) - - err := abfHandler.AbfAttachInterfaceIPv4(1, 2, 3) - - Expect(err).ToNot(BeNil()) -} - -func TestAttachABFInterfaceIPv6(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{}) - - err := abfHandler.AbfAttachInterfaceIPv6(1, 2, 3) - - Expect(err).To(BeNil()) - req, ok := ctx.MockChannel.Msg.(*vpp_abf.AbfItfAttachAddDel) - Expect(ok).To(BeTrue()) - Expect(req.IsAdd).To(BeTrue()) - Expect(req.Attach.PolicyID).To(Equal(uint32(1))) - Expect(req.Attach.SwIfIndex).To(BeEquivalentTo(uint32(2))) - Expect(req.Attach.Priority).To(Equal(uint32(3))) - Expect(req.Attach.IsIPv6).To(BeTrue()) -} - -func TestAttachABFInterfaceIPv6Error(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{ - Retval: -1, - }) - - err := abfHandler.AbfAttachInterfaceIPv6(1, 2, 3) - - Expect(err).ToNot(BeNil()) -} - -func TestDetachABFInterfaceIPv4(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{}) - - err := abfHandler.AbfDetachInterfaceIPv4(1, 2, 3) - - Expect(err).To(BeNil()) - req, ok := ctx.MockChannel.Msg.(*vpp_abf.AbfItfAttachAddDel) - Expect(ok).To(BeTrue()) - Expect(req.IsAdd).To(BeFalse()) - Expect(req.Attach.PolicyID).To(Equal(uint32(1))) - Expect(req.Attach.SwIfIndex).To(BeEquivalentTo(uint32(2))) - Expect(req.Attach.Priority).To(Equal(uint32(3))) - Expect(req.Attach.IsIPv6).To(BeFalse()) -} - -func TestDetachABFInterfaceIPv4Error(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{ - Retval: -1, - }) - - err := abfHandler.AbfDetachInterfaceIPv4(1, 2, 3) - - Expect(err).ToNot(BeNil()) -} - -func TestDetachABFInterfaceIPv6(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{}) - - err := abfHandler.AbfDetachInterfaceIPv6(1, 2, 3) - - Expect(err).To(BeNil()) - req, ok := ctx.MockChannel.Msg.(*vpp_abf.AbfItfAttachAddDel) - Expect(ok).To(BeTrue()) - Expect(req.IsAdd).To(BeFalse()) - Expect(req.Attach.PolicyID).To(Equal(uint32(1))) - Expect(req.Attach.SwIfIndex).To(BeEquivalentTo(uint32(2))) - Expect(req.Attach.Priority).To(Equal(uint32(3))) - Expect(req.Attach.IsIPv6).To(BeTrue()) -} - -func TestDetachABFInterfaceIPv6Error(t *testing.T) { - ctx, abfHandler, _ := abfTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_abf.AbfItfAttachAddDelReply{ - Retval: -1, - }) - - err := abfHandler.AbfDetachInterfaceIPv6(1, 2, 3) - - Expect(err).ToNot(BeNil()) -} - -func abfTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.ABFVppAPI, ifaceidx.IfaceMetadataIndexRW) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - aclIdx := aclidx.NewACLIndex(log, "acl-index") - ifIdx := ifaceidx.NewIfaceIndex(log, "if-index") - abfHandler := NewABFVppHandler(ctx.MockChannel, aclIdx, ifIdx, log) - return ctx, abfHandler, ifIdx -} diff --git a/plugins/vpp/abfplugin/vppcalls/vpp2001/dump_abf_vppcalls.go b/plugins/vpp/abfplugin/vppcalls/vpp2001/dump_abf_vppcalls.go deleted file mode 100644 index 1122ddb1dd..0000000000 --- a/plugins/vpp/abfplugin/vppcalls/vpp2001/dump_abf_vppcalls.go +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin/vppcalls" - vpp_abf "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/abf" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - abf "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/abf" -) - -// placeholder for unknown names -const unknownName = "" - -// DumpABFPolicy retrieves VPP ABF configuration. -func (h *ABFVppHandler) DumpABFPolicy() ([]*vppcalls.ABFDetails, error) { - // retrieve ABF interfaces - attachedIfs, err := h.dumpABFInterfaces() - if err != nil { - return nil, err - } - - // retrieve ABF policy - abfPolicy, err := h.dumpABFPolicy() - if err != nil { - return nil, err - } - - // merge attached interfaces data to policy - for _, policy := range abfPolicy { - ifData, ok := attachedIfs[policy.Meta.PolicyID] - if ok { - policy.ABF.AttachedInterfaces = ifData - } - } - - return abfPolicy, nil -} - -func (h *ABFVppHandler) dumpABFInterfaces() (map[uint32][]*abf.ABF_AttachedInterface, error) { - // ABF index <-> attached interfaces - abfIfs := make(map[uint32][]*abf.ABF_AttachedInterface) - - req := &vpp_abf.AbfItfAttachDump{} - reqCtx := h.callsChannel.SendMultiRequest(req) - - for { - reply := &vpp_abf.AbfItfAttachDetails{} - last, err := reqCtx.ReceiveReply(reply) - if err != nil { - return nil, err - } - if last { - break - } - - // interface name - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(uint32(reply.Attach.SwIfIndex)) - if !exists { - ifName = unknownName - } - - // attached interface entry - attached := &abf.ABF_AttachedInterface{ - InputInterface: ifName, - Priority: reply.Attach.Priority, - IsIpv6: reply.Attach.IsIPv6, - } - - _, ok := abfIfs[reply.Attach.PolicyID] - if !ok { - abfIfs[reply.Attach.PolicyID] = []*abf.ABF_AttachedInterface{} - } - abfIfs[reply.Attach.PolicyID] = append(abfIfs[reply.Attach.PolicyID], attached) - } - - return abfIfs, nil -} - -func (h *ABFVppHandler) dumpABFPolicy() ([]*vppcalls.ABFDetails, error) { - var abfs []*vppcalls.ABFDetails - req := &vpp_abf.AbfPolicyDump{} - reqCtx := h.callsChannel.SendMultiRequest(req) - - for { - reply := &vpp_abf.AbfPolicyDetails{} - last, err := reqCtx.ReceiveReply(reply) - if err != nil { - return nil, err - } - if last { - break - } - - // ACL name - aclName, _, exists := h.aclIndexes.LookupByIndex(reply.Policy.ACLIndex) - if !exists { - aclName = unknownName - } - - // paths - var fwdPaths []*abf.ABF_ForwardingPath - for _, path := range reply.Policy.Paths { - // interface name - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(path.SwIfIndex) - if !exists { - ifName = unknownName - } - - // base fields - fwdPath := &abf.ABF_ForwardingPath{ - NextHopIp: parseNextHopToString(path.Nh, path.Proto), - InterfaceName: ifName, - Weight: uint32(path.Weight), - Preference: uint32(path.Preference), - Dvr: path.Type == fib_types.FIB_API_PATH_TYPE_DVR, - } - fwdPaths = append(fwdPaths, fwdPath) - } - - abfData := &vppcalls.ABFDetails{ - ABF: &abf.ABF{ - Index: reply.Policy.PolicyID, - AclName: aclName, - ForwardingPaths: fwdPaths, - }, - Meta: &vppcalls.ABFMeta{ - PolicyID: reply.Policy.PolicyID, - }, - } - - abfs = append(abfs, abfData) - } - - return abfs, nil -} - -// returns next hop IP address -func parseNextHopToString(nh vpp_abf.FibPathNh, proto vpp_abf.FibPathNhProto) string { - if proto == fib_types.FIB_API_PATH_NH_PROTO_IP4 { - addr := nh.Address.GetIP4() - return net.IP(addr[:]).To4().String() - } - if proto == fib_types.FIB_API_PATH_NH_PROTO_IP6 { - addr := nh.Address.GetIP6() - return net.IP(addr[:]).To16().String() - } - return "" -} diff --git a/plugins/vpp/abfplugin/vppcalls/vpp2001/vppcalls_handlers.go b/plugins/vpp/abfplugin/vppcalls/vpp2001/vppcalls_handlers.go deleted file mode 100644 index f324707a41..0000000000 --- a/plugins/vpp/abfplugin/vppcalls/vpp2001/vppcalls_handlers.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/abfplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/aclidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - vpp_abf "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/abf" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" -) - -func init() { - var msgs []govppapi.Message - msgs = append(msgs, vpp_abf.AllMessages()...) - - vppcalls.AddABFHandlerVersion(vpp2001.Version, msgs, NewABFVppHandler) -} - -// ABFVppHandler is accessor for abf-related vppcalls methods -type ABFVppHandler struct { - callsChannel govppapi.Channel - aclIndexes aclidx.ACLMetadataIndex - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// NewABFVppHandler returns new ABFVppHandler. -func NewABFVppHandler( - calls govppapi.Channel, - aclIdx aclidx.ACLMetadataIndex, - ifIdx ifaceidx.IfaceMetadataIndex, - log logging.Logger, -) vppcalls.ABFVppAPI { - return &ABFVppHandler{ - callsChannel: calls, - aclIndexes: aclIdx, - ifIndexes: ifIdx, - log: log, - } -} diff --git a/plugins/vpp/aclplugin/aclplugin.go b/plugins/vpp/aclplugin/aclplugin.go index 3944d0ec71..624e4c203b 100644 --- a/plugins/vpp/aclplugin/aclplugin.go +++ b/plugins/vpp/aclplugin/aclplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/aclplugin/vppcalls/vpp2001/acl_vppcalls.go b/plugins/vpp/aclplugin/vppcalls/vpp2001/acl_vppcalls.go deleted file mode 100644 index 47afd7f1db..0000000000 --- a/plugins/vpp/aclplugin/vppcalls/vpp2001/acl_vppcalls.go +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - "strings" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls" - vpp_acl "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" - acl "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/acl" -) - -// AddACL implements ACL handler. -func (h *ACLVppHandler) AddACL(rules []*acl.ACL_Rule, aclName string) (uint32, error) { - // Prepare Ip rules - aclIPRules, err := transformACLIpRules(rules) - if err != nil { - return 0, err - } - if len(aclIPRules) == 0 { - return 0, fmt.Errorf("no rules found for ACL %v", aclName) - } - - req := &vpp_acl.ACLAddReplace{ - ACLIndex: 0xffffffff, // to make new Entry - Count: uint32(len(aclIPRules)), - Tag: []byte(aclName), - R: aclIPRules, - } - reply := &vpp_acl.ACLAddReplaceReply{} - - if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, fmt.Errorf("failed to write ACL %v: %v", aclName, err) - } - - return reply.ACLIndex, nil -} - -// AddMACIPACL implements ACL handler. -func (h *ACLVppHandler) AddMACIPACL(rules []*acl.ACL_Rule, aclName string) (uint32, error) { - // Prepare MAc Ip rules - aclMacIPRules, err := h.transformACLMacIPRules(rules) - if err != nil { - return 0, err - } - if len(aclMacIPRules) == 0 { - return 0, fmt.Errorf("no rules found for ACL %v", aclName) - } - - req := &vpp_acl.MacipACLAdd{ - Count: uint32(len(aclMacIPRules)), - Tag: []byte(aclName), - R: aclMacIPRules, - } - reply := &vpp_acl.MacipACLAddReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, fmt.Errorf("failed to write ACL %v: %v", aclName, err) - } - - return reply.ACLIndex, nil -} - -// ModifyACL implements ACL handler. -func (h *ACLVppHandler) ModifyACL(aclIndex uint32, rules []*acl.ACL_Rule, aclName string) error { - // Prepare Ip rules - aclIPRules, err := transformACLIpRules(rules) - if err != nil { - return err - } - if len(aclIPRules) == 0 { - return nil - } - - req := &vpp_acl.ACLAddReplace{ - ACLIndex: aclIndex, - Count: uint32(len(aclIPRules)), - Tag: []byte(aclName), - R: aclIPRules, - } - reply := &vpp_acl.ACLAddReplaceReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("failed to write ACL %v: %v", aclName, err) - } - - return nil -} - -// ModifyMACIPACL implements ACL handler. -func (h *ACLVppHandler) ModifyMACIPACL(aclIndex uint32, rules []*acl.ACL_Rule, aclName string) error { - // Prepare MAc Ip rules - aclMacIPRules, err := h.transformACLMacIPRules(rules) - if err != nil { - return err - } - if len(aclMacIPRules) == 0 { - return fmt.Errorf("no rules found for ACL %v", aclName) - } - - req := &vpp_acl.MacipACLAddReplace{ - ACLIndex: aclIndex, - Count: uint32(len(aclMacIPRules)), - Tag: []byte(aclName), - R: aclMacIPRules, - } - reply := &vpp_acl.MacipACLAddReplaceReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("failed to write ACL %v: %v", aclName, err) - } - - return nil -} - -// DeleteACL implements ACL handler. -func (h *ACLVppHandler) DeleteACL(aclIndex uint32) error { - req := &vpp_acl.ACLDel{ - ACLIndex: aclIndex, - } - reply := &vpp_acl.ACLDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("failed to remove L3/L4 ACL %v: %v", aclIndex, err) - } - - return nil -} - -// DeleteMACIPACL implements ACL handler. -func (h *ACLVppHandler) DeleteMACIPACL(aclIndex uint32) error { - req := &vpp_acl.MacipACLDel{ - ACLIndex: aclIndex, - } - reply := &vpp_acl.MacipACLDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("failed to remove L2 ACL %v: %v", aclIndex, err) - } - - return nil -} - -// Method transforms provided set of IP proto ACL rules to binapi ACL rules. -func transformACLIpRules(rules []*acl.ACL_Rule) (aclIPRules []vpp_acl.ACLRule, err error) { - for _, rule := range rules { - aclRule := &vpp_acl.ACLRule{ - IsPermit: uint8(rule.Action), - } - // Match - if ipRule := rule.GetIpRule(); ipRule != nil { - // Concerned to IP rules only - // L3 - if ipRule.Ip != nil { - aclRule, err = ipACL(ipRule.Ip, aclRule) - if err != nil { - return nil, err - } - } - // ICMP/L4 - switch ipRule.Ip.GetProtocol() { - case 0: // determine protocol based on rule definition - if ipRule.Icmp != nil { - aclRule = icmpACL(ipRule.Icmp, aclRule) - } else if ipRule.Tcp != nil { - aclRule = tcpACL(ipRule.Tcp, aclRule) - } else if ipRule.Udp != nil { - aclRule = udpACL(ipRule.Udp, aclRule) - } - case vppcalls.ICMPv4Proto: - fallthrough - case vppcalls.ICMPv6Proto: - if ipRule.Icmp != nil { - aclRule = icmpACL(ipRule.Icmp, aclRule) - } - case vppcalls.TCPProto: - if ipRule.Tcp != nil { - aclRule = tcpACL(ipRule.Tcp, aclRule) - } - case vppcalls.UDPProto: - if ipRule.Udp != nil { - aclRule = udpACL(ipRule.Udp, aclRule) - } - } - aclIPRules = append(aclIPRules, *aclRule) - } - } - return aclIPRules, nil -} - -func (h *ACLVppHandler) transformACLMacIPRules(rules []*acl.ACL_Rule) (aclMacIPRules []vpp_acl.MacipACLRule, err error) { - for _, rule := range rules { - aclMacIPRule := &vpp_acl.MacipACLRule{ - IsPermit: uint8(rule.Action), - } - // Matche - if macIPRule := rule.GetMacipRule(); macIPRule != nil { - // Concerned to MAC IP rules only - // Source IP Address + Prefix - srcIPAddress := net.ParseIP(macIPRule.SourceAddress) - if srcIPAddress.To4() != nil { - aclMacIPRule.IsIPv6 = 0 - aclMacIPRule.SrcIPAddr = srcIPAddress.To4() - aclMacIPRule.SrcIPPrefixLen = uint8(macIPRule.SourceAddressPrefix) - } else if srcIPAddress.To16() != nil { - aclMacIPRule.IsIPv6 = 1 - aclMacIPRule.SrcIPAddr = srcIPAddress.To16() - aclMacIPRule.SrcIPPrefixLen = uint8(macIPRule.SourceAddressPrefix) - } else { - return nil, fmt.Errorf("invalid IP address %v", macIPRule.SourceAddress) - } - // MAC + mask - srcMac, err := net.ParseMAC(macIPRule.SourceMacAddress) - if err != nil { - return aclMacIPRules, err - } - srcMacMask, err := net.ParseMAC(macIPRule.SourceMacAddressMask) - if err != nil { - return aclMacIPRules, err - } - aclMacIPRule.SrcMac = srcMac - aclMacIPRule.SrcMacMask = srcMacMask - aclMacIPRules = append(aclMacIPRules, *aclMacIPRule) - } - } - return aclMacIPRules, nil -} - -// The function sets an IP ACL rule fields into provided ACL Rule object. Source -// and destination addresses have to be the same IP version and contain a network mask. -func ipACL(ipRule *acl.ACL_Rule_IpRule_Ip, aclRule *vpp_acl.ACLRule) (*vpp_acl.ACLRule, error) { - var ( - err error - srcNetwork *net.IPNet - dstNetwork *net.IPNet - srcMask uint8 - dstMask uint8 - ) - - if strings.TrimSpace(ipRule.SourceNetwork) != "" { - // Resolve source address - _, srcNetwork, err = net.ParseCIDR(ipRule.SourceNetwork) - if err != nil { - return nil, err - } - if srcNetwork == nil { - srcNetwork = &net.IPNet{} - } - if srcNetwork.IP.To4() == nil && srcNetwork.IP.To16() == nil { - return aclRule, fmt.Errorf("source address %v is invalid", ipRule.SourceNetwork) - } - maskSize, _ := srcNetwork.Mask.Size() - srcMask = uint8(maskSize) - } else { - return aclRule, fmt.Errorf("source address is empty") - } - - if strings.TrimSpace(ipRule.DestinationNetwork) != "" { - // Resolve destination address - _, dstNetwork, err = net.ParseCIDR(ipRule.DestinationNetwork) - if err != nil { - return nil, err - } - if dstNetwork == nil { - dstNetwork = &net.IPNet{} - } - if dstNetwork.IP.To4() == nil && dstNetwork.IP.To16() == nil { - return aclRule, fmt.Errorf("destination address %v is invalid", ipRule.DestinationNetwork) - } - maskSize, _ := dstNetwork.Mask.Size() - dstMask = uint8(maskSize) - } else { - return aclRule, fmt.Errorf("destination address is empty") - } - - // Check IP version (they should be the same), beware: IPv4 address can be converted to IPv6. - if (srcNetwork.IP.To4() != nil && dstNetwork.IP.To4() == nil && dstNetwork.IP.To16() != nil) || - (srcNetwork.IP.To4() == nil && srcNetwork.IP.To16() != nil && dstNetwork.IP.To4() != nil) { - return aclRule, fmt.Errorf("source address %v and destionation address %v have different IP versions", - ipRule.SourceNetwork, ipRule.DestinationNetwork) - } - - if srcNetwork.IP.To4() != nil || dstNetwork.IP.To4() != nil { - // Ipv4 case - aclRule.IsIPv6 = 0 - aclRule.SrcIPAddr = srcNetwork.IP.To4() - aclRule.SrcIPPrefixLen = srcMask - aclRule.DstIPAddr = dstNetwork.IP.To4() - aclRule.DstIPPrefixLen = dstMask - } else if srcNetwork.IP.To16() != nil || dstNetwork.IP.To16() != nil { - // Ipv6 case - aclRule.IsIPv6 = 1 - aclRule.SrcIPAddr = srcNetwork.IP.To16() - aclRule.SrcIPPrefixLen = srcMask - aclRule.DstIPAddr = dstNetwork.IP.To16() - aclRule.DstIPPrefixLen = dstMask - } else { - // Both empty - aclRule.IsIPv6 = 0 - } - aclRule.Proto = uint8(ipRule.GetProtocol()) - return aclRule, nil -} - -// The function sets an ICMP ACL rule fields into provided ACL Rule object. -// The ranges are exclusive, use first = 0 and last = 255/65535 (icmpv4/icmpv6) to match "any". -func icmpACL(icmpRule *acl.ACL_Rule_IpRule_Icmp, aclRule *vpp_acl.ACLRule) *vpp_acl.ACLRule { - if icmpRule == nil { - return aclRule - } - if icmpRule.Icmpv6 { - aclRule.Proto = vppcalls.ICMPv6Proto // IANA ICMPv6 - aclRule.IsIPv6 = 1 - // ICMPv6 type range - aclRule.SrcportOrIcmptypeFirst = uint16(icmpRule.IcmpTypeRange.First) - aclRule.SrcportOrIcmptypeLast = uint16(icmpRule.IcmpTypeRange.Last) - // ICMPv6 code range - aclRule.DstportOrIcmpcodeFirst = uint16(icmpRule.IcmpCodeRange.First) - aclRule.DstportOrIcmpcodeLast = uint16(icmpRule.IcmpCodeRange.Last) - } else { - aclRule.Proto = vppcalls.ICMPv4Proto // IANA ICMPv4 - aclRule.IsIPv6 = 0 - // ICMPv4 type range - aclRule.SrcportOrIcmptypeFirst = uint16(icmpRule.IcmpTypeRange.First) - aclRule.SrcportOrIcmptypeLast = uint16(icmpRule.IcmpTypeRange.Last) - // ICMPv4 code range - aclRule.DstportOrIcmpcodeFirst = uint16(icmpRule.IcmpCodeRange.First) - aclRule.DstportOrIcmpcodeLast = uint16(icmpRule.IcmpCodeRange.Last) - } - return aclRule -} - -// Sets an TCP ACL rule fields into provided ACL Rule object. -func tcpACL(tcpRule *acl.ACL_Rule_IpRule_Tcp, aclRule *vpp_acl.ACLRule) *vpp_acl.ACLRule { - aclRule.Proto = vppcalls.TCPProto // IANA TCP - aclRule.SrcportOrIcmptypeFirst = uint16(tcpRule.SourcePortRange.LowerPort) - aclRule.SrcportOrIcmptypeLast = uint16(tcpRule.SourcePortRange.UpperPort) - aclRule.DstportOrIcmpcodeFirst = uint16(tcpRule.DestinationPortRange.LowerPort) - aclRule.DstportOrIcmpcodeLast = uint16(tcpRule.DestinationPortRange.UpperPort) - aclRule.TCPFlagsValue = uint8(tcpRule.TcpFlagsValue) - aclRule.TCPFlagsMask = uint8(tcpRule.TcpFlagsMask) - return aclRule -} - -// Sets an UDP ACL rule fields into provided ACL Rule object. -func udpACL(udpRule *acl.ACL_Rule_IpRule_Udp, aclRule *vpp_acl.ACLRule) *vpp_acl.ACLRule { - aclRule.Proto = vppcalls.UDPProto // IANA UDP - aclRule.SrcportOrIcmptypeFirst = uint16(udpRule.SourcePortRange.LowerPort) - aclRule.SrcportOrIcmptypeLast = uint16(udpRule.SourcePortRange.UpperPort) - aclRule.DstportOrIcmpcodeFirst = uint16(udpRule.DestinationPortRange.LowerPort) - aclRule.DstportOrIcmpcodeLast = uint16(udpRule.DestinationPortRange.UpperPort) - return aclRule -} diff --git a/plugins/vpp/aclplugin/vppcalls/vpp2001/acl_vppcalls_test.go b/plugins/vpp/aclplugin/vppcalls/vpp2001/acl_vppcalls_test.go deleted file mode 100644 index dd3943fe9f..0000000000 --- a/plugins/vpp/aclplugin/vppcalls/vpp2001/acl_vppcalls_test.go +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_acl "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - acl "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/acl" -) - -var aclNoRules []*acl.ACL_Rule - -var aclErr1Rules = []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: ".0.", - DestinationNetwork: "10.20.0.0/24", - }, - }, - }, -} - -var aclErr2Rules = []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "192.168.1.1/32", - DestinationNetwork: ".0.", - }, - }, - }, -} - -var aclErr3Rules = []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "192.168.1.1/32", - DestinationNetwork: "dead::1/64", - }, - }, - }, -} - -var aclErr4Rules = []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "", - DestinationNetwork: "", - }, - }, - }, -} - -var aclErr5Rules = []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "192.168.0.1", - SourceAddressPrefix: uint32(16), - SourceMacAddress: "", - SourceMacAddressMask: "ff:ff:ff:ff:00:00", - }, - }, -} - -var aclErr6Rules = []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "192.168.0.1", - SourceAddressPrefix: uint32(16), - SourceMacAddress: "11:44:0A:B8:4A:36", - SourceMacAddressMask: "", - }, - }, -} - -var aclErr7Rules = []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "", - SourceAddressPrefix: uint32(16), - SourceMacAddress: "11:44:0A:B8:4A:36", - SourceMacAddressMask: "ff:ff:ff:ff:00:00", - }, - }, -} - -var aclIPrules = []*acl.ACL_Rule{ - { - //RuleName: "permitIPv4", - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "192.168.1.1/32", - DestinationNetwork: "10.20.0.0/24", - }, - }, - }, - { - //RuleName: "permitIPv6", - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "dead::1/64", - DestinationNetwork: "dead::2/64", - }, - }, - }, - { - //RuleName: "denyICMP", - Action: acl.ACL_Rule_DENY, - IpRule: &acl.ACL_Rule_IpRule{ - Icmp: &acl.ACL_Rule_IpRule_Icmp{ - Icmpv6: false, - IcmpCodeRange: &acl.ACL_Rule_IpRule_Icmp_Range{ - First: 1, - Last: 2, - }, - IcmpTypeRange: &acl.ACL_Rule_IpRule_Icmp_Range{ - First: 3, - Last: 4, - }, - }, - }, - }, - { - //RuleName: "denyICMPv6", - Action: acl.ACL_Rule_DENY, - IpRule: &acl.ACL_Rule_IpRule{ - Icmp: &acl.ACL_Rule_IpRule_Icmp{ - Icmpv6: true, - IcmpCodeRange: &acl.ACL_Rule_IpRule_Icmp_Range{ - First: 10, - Last: 20, - }, - IcmpTypeRange: &acl.ACL_Rule_IpRule_Icmp_Range{ - First: 30, - Last: 40, - }, - }, - }, - }, - { - //RuleName: "permitTCP", - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Tcp: &acl.ACL_Rule_IpRule_Tcp{ - TcpFlagsMask: 20, - TcpFlagsValue: 10, - SourcePortRange: &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: 150, - UpperPort: 250, - }, - DestinationPortRange: &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: 1150, - UpperPort: 1250, - }, - }, - }, - }, - { - //RuleName: "denyUDP", - Action: acl.ACL_Rule_DENY, - IpRule: &acl.ACL_Rule_IpRule{ - Udp: &acl.ACL_Rule_IpRule_Udp{ - SourcePortRange: &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: 150, - UpperPort: 250, - }, - DestinationPortRange: &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: 1150, - UpperPort: 1250, - }, - }, - }, - }, -} - -var aclMACIPrules = []*acl.ACL_Rule{ - { - //RuleName: "denyIPv4", - Action: acl.ACL_Rule_DENY, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "192.168.0.1", - SourceAddressPrefix: uint32(16), - SourceMacAddress: "11:44:0A:B8:4A:35", - SourceMacAddressMask: "ff:ff:ff:ff:00:00", - }, - }, - { - //RuleName: "denyIPv6", - Action: acl.ACL_Rule_DENY, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "dead::1", - SourceAddressPrefix: uint32(64), - SourceMacAddress: "11:44:0A:B8:4A:35", - SourceMacAddressMask: "ff:ff:ff:ff:00:00", - }, - }, -} - -type testCtx struct { - *vppmock.TestCtx - aclHandler *ACLVppHandler - ifIndexes ifaceidx.IfaceMetadataIndexRW -} - -func setupACLTest(t *testing.T) *testCtx { - ctx := vppmock.SetupTestCtx(t) - - ifaceIdx := ifaceidx.NewIfaceIndex(logrus.NewLogger("test"), "test") - aclHandler := NewACLVppHandler(ctx.MockVPPClient, ifaceIdx).(*ACLVppHandler) - - return &testCtx{ - TestCtx: ctx, - aclHandler: aclHandler, - ifIndexes: ifaceIdx, - } -} - -func (ctx *testCtx) teardownACLTest() { - ctx.TeardownTestCtx() -} - -// Test add IP acl rules -func TestAddIPAcl(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{}) - - aclIndex, err := ctx.aclHandler.AddACL(aclIPrules, "test0") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(0)) - - _, err = ctx.aclHandler.AddACL(aclNoRules, "test1") - Expect(err).To(Not(BeNil())) - - _, err = ctx.aclHandler.AddACL(aclErr1Rules, "test2") - Expect(err).To(Not(BeNil())) - - _, err = ctx.aclHandler.AddACL(aclErr2Rules, "test3") - Expect(err).To(Not(BeNil())) - - _, err = ctx.aclHandler.AddACL(aclErr3Rules, "test4") - Expect(err).To(Not(BeNil())) - - _, err = ctx.aclHandler.AddACL(aclErr4Rules, "test5") - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReply{}) - _, err = ctx.aclHandler.AddACL(aclIPrules, "test5") - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{Retval: -1}) - _, err = ctx.aclHandler.AddACL(aclIPrules, "test6") - Expect(err).To(Not(BeNil())) -} - -// Test add MACIP acl rules -func TestAddMacIPAcl(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReply{}) - - aclIndex, err := ctx.aclHandler.AddMACIPACL(aclMACIPrules, "test6") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(0)) - - _, err = ctx.aclHandler.AddMACIPACL(aclNoRules, "test7") - Expect(err).To(Not(BeNil())) - - _, err = ctx.aclHandler.AddMACIPACL(aclErr5Rules, "test8") - Expect(err).To(Not(BeNil())) - - _, err = ctx.aclHandler.AddMACIPACL(aclErr6Rules, "test9") - Expect(err).To(Not(BeNil())) - - _, err = ctx.aclHandler.AddMACIPACL(aclErr7Rules, "test10") - Expect(err).To(Not(BeNil())) - Expect(err.Error()).To(BeEquivalentTo("invalid IP address ")) - - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{}) - _, err = ctx.aclHandler.AddMACIPACL(aclMACIPrules, "test11") - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReply{Retval: -1}) - _, err = ctx.aclHandler.AddMACIPACL(aclMACIPrules, "test12") - Expect(err).To(Not(BeNil())) -} - -// Test deletion of IP acl rules -func TestDeleteIPAcl(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{}) - - aclIndex, err := ctx.aclHandler.AddACL(aclIPrules, "test_del0") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(0)) - - rule2del := []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "10.20.30.1/32", - DestinationNetwork: "10.20.0.0/24", - }, - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{ACLIndex: 1}) - aclIndex, err = ctx.aclHandler.AddACL(rule2del, "test_del1") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(1)) - - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{}) - err = ctx.aclHandler.DeleteACL(5) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLDelReply{Retval: -1}) - err = ctx.aclHandler.DeleteACL(5) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLDelReply{}) - err = ctx.aclHandler.DeleteACL(1) - Expect(err).To(BeNil()) -} - -// Test deletion of MACIP acl rules -func TestDeleteMACIPAcl(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReply{}) - - aclIndex, err := ctx.aclHandler.AddMACIPACL(aclMACIPrules, "test_del2") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(0)) - - rule2del := []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "192.168.0.1", - SourceAddressPrefix: uint32(16), - SourceMacAddress: "11:44:0A:B8:4A:35", - SourceMacAddressMask: "ff:ff:ff:ff:00:00", - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReply{ACLIndex: 1}) - aclIndex, err = ctx.aclHandler.AddMACIPACL(rule2del, "test_del3") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(1)) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReply{}) - err = ctx.aclHandler.DeleteMACIPACL(5) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLDelReply{Retval: -1}) - err = ctx.aclHandler.DeleteMACIPACL(5) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLDelReply{}) - err = ctx.aclHandler.DeleteMACIPACL(1) - Expect(err).To(BeNil()) -} - -// Test modification of IP acl rule -func TestModifyIPAcl(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{}) - - aclIndex, err := ctx.aclHandler.AddACL(aclIPrules, "test_modify") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(0)) - - rule2modify := []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "10.20.30.1/32", - DestinationNetwork: "10.20.0.0/24", - }, - }, - }, - { - Action: acl.ACL_Rule_PERMIT, - IpRule: &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: "dead:dead::3/64", - DestinationNetwork: "dead:dead::4/64", - }, - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{}) - err = ctx.aclHandler.ModifyACL(0, rule2modify, "test_modify0") - Expect(err).To(BeNil()) - - err = ctx.aclHandler.ModifyACL(0, aclErr1Rules, "test_modify1") - Expect(err).To(Not(BeNil())) - - err = ctx.aclHandler.ModifyACL(0, aclNoRules, "test_modify2") - Expect(err).To(BeNil()) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{}) - err = ctx.aclHandler.ModifyACL(0, aclIPrules, "test_modify3") - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLAddReplaceReply{Retval: -1}) - err = ctx.aclHandler.ModifyACL(0, aclIPrules, "test_modify4") - Expect(err).To(Not(BeNil())) -} - -// Test modification of MACIP acl rule -func TestModifyMACIPAcl(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReply{}) - - aclIndex, err := ctx.aclHandler.AddMACIPACL(aclMACIPrules, "test_modify") - Expect(err).To(BeNil()) - Expect(aclIndex).To(BeEquivalentTo(0)) - - rule2modify := []*acl.ACL_Rule{ - { - Action: acl.ACL_Rule_DENY, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "192.168.10.1", - SourceAddressPrefix: uint32(24), - SourceMacAddress: "11:44:0A:B8:4A:37", - SourceMacAddressMask: "ff:ff:ff:ff:00:00", - }, - }, - { - Action: acl.ACL_Rule_DENY, - MacipRule: &acl.ACL_Rule_MacIpRule{ - SourceAddress: "dead::2", - SourceAddressPrefix: uint32(64), - SourceMacAddress: "11:44:0A:B8:4A:38", - SourceMacAddressMask: "ff:ff:ff:ff:00:00", - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{}) - err = ctx.aclHandler.ModifyMACIPACL(0, rule2modify, "test_modify0") - Expect(err).To(BeNil()) - - err = ctx.aclHandler.ModifyMACIPACL(0, aclErr1Rules, "test_modify1") - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{}) - err = ctx.aclHandler.ModifyMACIPACL(0, aclIPrules, "test_modify3") - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{Retval: -1}) - err = ctx.aclHandler.ModifyMACIPACL(0, aclIPrules, "test_modify4") - Expect(err).To(Not(BeNil())) -} diff --git a/plugins/vpp/aclplugin/vppcalls/vpp2001/dump_vppcalls.go b/plugins/vpp/aclplugin/vppcalls/vpp2001/dump_vppcalls.go deleted file mode 100644 index 80fb7bcc98..0000000000 --- a/plugins/vpp/aclplugin/vppcalls/vpp2001/dump_vppcalls.go +++ /dev/null @@ -1,657 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "bytes" - "fmt" - "net" - - "go.ligato.io/cn-infra/v2/logging/logrus" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls" - vpp_acl "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" - acl "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/acl" -) - -// DumpACL implements ACL handler. -func (h *ACLVppHandler) DumpACL() ([]*vppcalls.ACLDetails, error) { - ruleIPData := make(map[vppcalls.ACLMeta][]*acl.ACL_Rule) - - // get all ACLs with IP ruleData - IPRuleACLs, err := h.DumpIPAcls() - if len(IPRuleACLs) < 1 || err != nil { - return nil, err - } - - // resolve IP rules for every ACL - // Note: currently ACL may have only IP ruleData or only MAC IP ruleData - var wasErr error - for identifier, IPRules := range IPRuleACLs { - var rulesDetails []*acl.ACL_Rule - - if len(IPRules) > 0 { - for _, IPRule := range IPRules { - ruleDetails, err := h.getIPRuleDetails(IPRule) - if err != nil { - return nil, fmt.Errorf("failed to get IP Rule %v details: %v", IPRule, err) - } - rulesDetails = append(rulesDetails, ruleDetails) - } - } - ruleIPData[identifier] = rulesDetails - } - - // Prepare separate list of all active ACL indices on the VPP - var indices []uint32 - for identifier := range ruleIPData { - indices = append(indices, identifier.Index) - } - - // Get all ACL indices with ingress and egress interfaces - interfaceData, err := h.DumpACLInterfaces(indices) - if err != nil { - return nil, err - } - - var ACLs []*vppcalls.ACLDetails - // Build a list of ACL ruleData with ruleData, interfaces, index and tag (name) - for identifier, rules := range ruleIPData { - ACLs = append(ACLs, &vppcalls.ACLDetails{ - ACL: &acl.ACL{ - Name: identifier.Tag, - Rules: rules, - Interfaces: interfaceData[identifier.Index], - }, - Meta: &vppcalls.ACLMeta{ - Index: identifier.Index, - Tag: identifier.Tag, - }, - }) - } - - return ACLs, wasErr -} - -// DumpMACIPACL implements ACL handler. -func (h *ACLVppHandler) DumpMACIPACL() ([]*vppcalls.ACLDetails, error) { - ruleMACIPData := make(map[vppcalls.ACLMeta][]*acl.ACL_Rule) - - // get all ACLs with MACIP ruleData - MACIPRuleACLs, err := h.DumpMacIPAcls() - if len(MACIPRuleACLs) < 1 || err != nil { - return nil, err - } - - // resolve MACIP rules for every ACL - for metadata, MACIPRules := range MACIPRuleACLs { - var rulesDetails []*acl.ACL_Rule - - for _, MACIPRule := range MACIPRules { - ruleDetails, err := h.getMACIPRuleDetails(MACIPRule) - if err != nil { - return nil, fmt.Errorf("failed to get MACIP Rule %v details: %v", MACIPRule, err) - } - rulesDetails = append(rulesDetails, ruleDetails) - } - ruleMACIPData[metadata] = rulesDetails - } - - // Prepare separate list of all active ACL indices on the VPP - var indices []uint32 - for identifier := range ruleMACIPData { - indices = append(indices, identifier.Index) - } - - // Get all ACL indices with ingress and egress interfaces - interfaceData, err := h.DumpMACIPACLInterfaces(indices) - if err != nil { - return nil, err - } - - var ACLs []*vppcalls.ACLDetails - // Build a list of ACL ruleData with ruleData, interfaces, index and tag (name) - for metadata, rules := range ruleMACIPData { - ACLs = append(ACLs, &vppcalls.ACLDetails{ - ACL: &acl.ACL{ - Name: metadata.Tag, - Rules: rules, - Interfaces: interfaceData[metadata.Index], - }, - Meta: &vppcalls.ACLMeta{ - Index: metadata.Index, - Tag: metadata.Tag, - }, - }) - } - return ACLs, nil -} - -// DumpACLInterfaces implements ACL handler. -func (h *ACLVppHandler) DumpACLInterfaces(indices []uint32) (map[uint32]*acl.ACL_Interfaces, error) { - // list of ACL-to-interfaces - aclsWithInterfaces := make(map[uint32]*acl.ACL_Interfaces) - - var interfaceData []*vppcalls.ACLToInterface - var wasErr error - - msgIP := &vpp_acl.ACLInterfaceListDump{ - SwIfIndex: 0xffffffff, // dump all - } - reqIP := h.callsChannel.SendMultiRequest(msgIP) - for { - replyIP := &vpp_acl.ACLInterfaceListDetails{} - stop, err := reqIP.ReceiveReply(replyIP) - if stop { - break - } - if err != nil { - return aclsWithInterfaces, fmt.Errorf("ACL interface list dump reply error: %v", err) - } - - if replyIP.Count > 0 { - data := &vppcalls.ACLToInterface{ - SwIfIdx: replyIP.SwIfIndex, - } - for i, aclIdx := range replyIP.Acls { - if i < int(replyIP.NInput) { - data.IngressACL = append(data.IngressACL, aclIdx) - } else { - data.EgressACL = append(data.EgressACL, aclIdx) - } - } - interfaceData = append(interfaceData, data) - } - } - - // sort interfaces for every ACL - for _, aclIdx := range indices { - var ingress []string - var egress []string - for _, data := range interfaceData { - // look for ingress - for _, ingressACLIdx := range data.IngressACL { - if ingressACLIdx == aclIdx { - name, _, found := h.ifIndexes.LookupBySwIfIndex(data.SwIfIdx) - if !found { - continue - } - ingress = append(ingress, name) - } - } - // look for egress - for _, egressACLIdx := range data.EgressACL { - if egressACLIdx == aclIdx { - name, _, found := h.ifIndexes.LookupBySwIfIndex(data.SwIfIdx) - if !found { - continue - } - egress = append(egress, name) - } - } - } - - aclsWithInterfaces[aclIdx] = &acl.ACL_Interfaces{ - Egress: egress, - Ingress: ingress, - } - } - - return aclsWithInterfaces, wasErr -} - -// DumpMACIPACLInterfaces implements ACL handler. -func (h *ACLVppHandler) DumpMACIPACLInterfaces(indices []uint32) (map[uint32]*acl.ACL_Interfaces, error) { - // list of ACL-to-interfaces - aclsWithInterfaces := make(map[uint32]*acl.ACL_Interfaces) - - var interfaceData []*vppcalls.ACLToInterface - - msgMACIP := &vpp_acl.MacipACLInterfaceListDump{ - SwIfIndex: 0xffffffff, // dump all - } - reqMACIP := h.callsChannel.SendMultiRequest(msgMACIP) - for { - replyMACIP := &vpp_acl.MacipACLInterfaceListDetails{} - stop, err := reqMACIP.ReceiveReply(replyMACIP) - if stop { - break - } - if err != nil { - return nil, fmt.Errorf("MACIP ACL interface list dump reply error: %v", err) - } - if replyMACIP.Count > 0 { - data := &vppcalls.ACLToInterface{ - SwIfIdx: replyMACIP.SwIfIndex, - } - for _, aclIdx := range replyMACIP.Acls { - data.IngressACL = append(data.IngressACL, aclIdx) - } - interfaceData = append(interfaceData, data) - } - } - - for _, aclIdx := range indices { - var ingress []string - for _, data := range interfaceData { - // look for ingress - for _, ingressACLIdx := range data.IngressACL { - if ingressACLIdx == aclIdx { - name, _, found := h.ifIndexes.LookupBySwIfIndex(data.SwIfIdx) - if !found { - continue - } - ingress = append(ingress, name) - } - } - } - var ifaces *acl.ACL_Interfaces - if len(ingress) > 0 { - ifaces = &acl.ACL_Interfaces{ - Egress: nil, - Ingress: ingress, - } - } - aclsWithInterfaces[aclIdx] = ifaces - } - - return aclsWithInterfaces, nil -} - -// DumpIPAcls implements ACL handler. -func (h *ACLVppHandler) DumpIPAcls() (map[vppcalls.ACLMeta][]vpp_acl.ACLRule, error) { - aclIPRules := make(map[vppcalls.ACLMeta][]vpp_acl.ACLRule) - var wasErr error - - req := &vpp_acl.ACLDump{ - ACLIndex: 0xffffffff, - } - reqContext := h.callsChannel.SendMultiRequest(req) - for { - msg := &vpp_acl.ACLDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return aclIPRules, fmt.Errorf("ACL dump reply error: %v", err) - } - if stop { - break - } - - metadata := vppcalls.ACLMeta{ - Index: msg.ACLIndex, - Tag: string(bytes.SplitN(msg.Tag, []byte{0x00}, 2)[0]), - } - - aclIPRules[metadata] = msg.R - } - - return aclIPRules, wasErr -} - -// DumpMacIPAcls implements ACL handler. -func (h *ACLVppHandler) DumpMacIPAcls() (map[vppcalls.ACLMeta][]vpp_acl.MacipACLRule, error) { - aclMACIPRules := make(map[vppcalls.ACLMeta][]vpp_acl.MacipACLRule) - - req := &vpp_acl.MacipACLDump{ - ACLIndex: 0xffffffff, - } - reqContext := h.callsChannel.SendMultiRequest(req) - for { - msg := &vpp_acl.MacipACLDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("ACL MACIP dump reply error: %v", err) - } - if stop { - break - } - - metadata := vppcalls.ACLMeta{ - Index: msg.ACLIndex, - Tag: string(bytes.Trim(msg.Tag, "\x00")), - } - - aclMACIPRules[metadata] = msg.R - } - return aclMACIPRules, nil -} - -// DumpInterfaceACLs implements ACL handler. -func (h *ACLVppHandler) DumpInterfaceACLs(swIndex uint32) (acls []*acl.ACL, err error) { - res, err := h.DumpInterfaceACLList(swIndex) - if err != nil { - return nil, err - } - - if res.SwIfIndex != swIndex { - return nil, fmt.Errorf("returned interface index %d does not match request", res.SwIfIndex) - } - - for aidx := range res.Acls { - ipACL, err := h.getIPACLDetails(uint32(aidx)) - if err != nil { - return nil, err - } - acls = append(acls, ipACL) - } - return acls, nil -} - -// DumpInterfaceMACIPACLs implements ACL handler. -func (h *ACLVppHandler) DumpInterfaceMACIPACLs(swIndex uint32) (acls []*acl.ACL, err error) { - resMacIP, err := h.DumpInterfaceMACIPACLList(swIndex) - if err != nil { - return nil, err - } - - if resMacIP.SwIfIndex != swIndex { - return nil, fmt.Errorf("returned interface index %d does not match request", resMacIP.SwIfIndex) - } - - for aidx := range resMacIP.Acls { - macipACL, err := h.getMACIPACLDetails(uint32(aidx)) - if err != nil { - return nil, err - } - acls = append(acls, macipACL) - } - return acls, nil -} - -// DumpInterfaceACLList implements ACL handler. -func (h *ACLVppHandler) DumpInterfaceACLList(swIndex uint32) (*vpp_acl.ACLInterfaceListDetails, error) { - req := &vpp_acl.ACLInterfaceListDump{ - SwIfIndex: swIndex, - } - reply := &vpp_acl.ACLInterfaceListDetails{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return nil, err - } - - return reply, nil -} - -// DumpInterfaceMACIPACLList implements ACL handler. -func (h *ACLVppHandler) DumpInterfaceMACIPACLList(swIndex uint32) (*vpp_acl.MacipACLInterfaceListDetails, error) { - req := &vpp_acl.MacipACLInterfaceListDump{ - SwIfIndex: swIndex, - } - reply := &vpp_acl.MacipACLInterfaceListDetails{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return nil, err - } - - return reply, nil -} - -// DumpInterfacesLists implements ACL handler. -func (h *ACLVppHandler) DumpInterfacesLists() ([]*vpp_acl.ACLInterfaceListDetails, []*vpp_acl.MacipACLInterfaceListDetails, error) { - msgIPACL := &vpp_acl.ACLInterfaceListDump{ - SwIfIndex: 0xffffffff, // dump all - } - - reqIPACL := h.callsChannel.SendMultiRequest(msgIPACL) - - var IPaclInterfaces []*vpp_acl.ACLInterfaceListDetails - for { - reply := &vpp_acl.ACLInterfaceListDetails{} - stop, err := reqIPACL.ReceiveReply(reply) - if stop { - break - } - if err != nil { - logrus.DefaultLogger().Error(err) - return nil, nil, err - } - IPaclInterfaces = append(IPaclInterfaces, reply) - } - - msgMACIPACL := &vpp_acl.ACLInterfaceListDump{ - SwIfIndex: 0xffffffff, // dump all - } - - reqMACIPACL := h.callsChannel.SendMultiRequest(msgMACIPACL) - - var MACIPaclInterfaces []*vpp_acl.MacipACLInterfaceListDetails - for { - reply := &vpp_acl.MacipACLInterfaceListDetails{} - stop, err := reqMACIPACL.ReceiveReply(reply) - if stop { - break - } - if err != nil { - logrus.DefaultLogger().Error(err) - return nil, nil, err - } - MACIPaclInterfaces = append(MACIPaclInterfaces, reply) - } - - return IPaclInterfaces, MACIPaclInterfaces, nil -} - -func (h *ACLVppHandler) getIPRuleDetails(rule vpp_acl.ACLRule) (*acl.ACL_Rule, error) { - // Resolve rule actions - aclAction, err := h.resolveRuleAction(rule.IsPermit) - if err != nil { - return nil, err - } - - return &acl.ACL_Rule{ - Action: aclAction, - IpRule: h.getIPRuleMatches(rule), - }, nil -} - -// getIPACLDetails gets details for a given IP ACL from VPP and translates -// them from the binary VPP API format into the ACL Plugin's NB format. -func (h *ACLVppHandler) getIPACLDetails(idx uint32) (aclRule *acl.ACL, err error) { - req := &vpp_acl.ACLDump{ - ACLIndex: uint32(idx), - } - - reply := &vpp_acl.ACLDetails{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return nil, err - } - - var ruleData []*acl.ACL_Rule - for _, r := range reply.R { - rule := &acl.ACL_Rule{} - - ipRule, err := h.getIPRuleDetails(r) - if err != nil { - return nil, err - } - - aclAction, err := h.resolveRuleAction(r.IsPermit) - if err != nil { - return nil, err - } - - rule.IpRule = ipRule.GetIpRule() - rule.Action = aclAction - ruleData = append(ruleData, rule) - } - - return &acl.ACL{Rules: ruleData, Name: string(bytes.SplitN(reply.Tag, []byte{0x00}, 2)[0])}, nil -} - -func (h *ACLVppHandler) getMACIPRuleDetails(rule vpp_acl.MacipACLRule) (*acl.ACL_Rule, error) { - // Resolve rule actions - aclAction, err := h.resolveRuleAction(rule.IsPermit) - if err != nil { - return nil, err - } - - return &acl.ACL_Rule{ - Action: aclAction, - MacipRule: h.getMACIPRuleMatches(rule), - }, nil -} - -// getMACIPACLDetails gets details for a given MACIP ACL from VPP and translates -// them from the binary VPP API format into the ACL Plugin's NB format. -func (h *ACLVppHandler) getMACIPACLDetails(idx uint32) (aclRule *acl.ACL, err error) { - req := &vpp_acl.MacipACLDump{ - ACLIndex: uint32(idx), - } - - reply := &vpp_acl.MacipACLDetails{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return nil, err - } - - var ruleData []*acl.ACL_Rule - for _, r := range reply.R { - rule := &acl.ACL_Rule{} - - ipRule, err := h.getMACIPRuleDetails(r) - if err != nil { - return nil, err - } - - aclAction, err := h.resolveRuleAction(r.IsPermit) - if err != nil { - return nil, err - } - - rule.IpRule = ipRule.GetIpRule() - rule.Action = aclAction - ruleData = append(ruleData, rule) - } - - return &acl.ACL{Rules: ruleData, Name: string(bytes.SplitN(reply.Tag, []byte{0x00}, 2)[0])}, nil -} - -// getIPRuleMatches translates an IP rule from the binary VPP API format into the -// ACL Plugin's NB format -func (h *ACLVppHandler) getIPRuleMatches(r vpp_acl.ACLRule) *acl.ACL_Rule_IpRule { - var srcIP, dstIP string - if r.IsIPv6 == 1 { - srcIP = net.IP(r.SrcIPAddr).To16().String() - dstIP = net.IP(r.DstIPAddr).To16().String() - } else { - srcIP = net.IP(r.SrcIPAddr[:4]).To4().String() - dstIP = net.IP(r.DstIPAddr[:4]).To4().String() - } - - ipRule := &acl.ACL_Rule_IpRule{ - Ip: &acl.ACL_Rule_IpRule_Ip{ - SourceNetwork: fmt.Sprintf("%s/%d", srcIP, r.SrcIPPrefixLen), - DestinationNetwork: fmt.Sprintf("%s/%d", dstIP, r.DstIPPrefixLen), - Protocol: uint32(r.Proto), - }, - } - - switch r.Proto { - case vppcalls.TCPProto: - ipRule.Tcp = h.getTCPMatchRule(r) - case vppcalls.UDPProto: - ipRule.Udp = h.getUDPMatchRule(r) - case vppcalls.ICMPv4Proto, vppcalls.ICMPv6Proto: - ipRule.Icmp = h.getIcmpMatchRule(r) - } - return ipRule -} - -// getMACIPRuleMatches translates an MACIP rule from the binary VPP API format into the -// ACL Plugin's NB format -func (h *ACLVppHandler) getMACIPRuleMatches(rule vpp_acl.MacipACLRule) *acl.ACL_Rule_MacIpRule { - var srcAddr string - if rule.IsIPv6 == 1 { - srcAddr = net.IP(rule.SrcIPAddr).To16().String() - } else { - srcAddr = net.IP(rule.SrcIPAddr[:4]).To4().String() - } - srcMacAddr := net.HardwareAddr(rule.SrcMac) - srcMacAddrMask := net.HardwareAddr(rule.SrcMacMask) - return &acl.ACL_Rule_MacIpRule{ - SourceAddress: srcAddr, - SourceAddressPrefix: uint32(rule.SrcIPPrefixLen), - SourceMacAddress: srcMacAddr.String(), - SourceMacAddressMask: srcMacAddrMask.String(), - } -} - -// getTCPMatchRule translates a TCP match rule from the binary VPP API format -// into the ACL Plugin's NB format -func (h *ACLVppHandler) getTCPMatchRule(r vpp_acl.ACLRule) *acl.ACL_Rule_IpRule_Tcp { - dstPortRange := &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: uint32(r.DstportOrIcmpcodeFirst), - UpperPort: uint32(r.DstportOrIcmpcodeLast), - } - srcPortRange := &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: uint32(r.SrcportOrIcmptypeFirst), - UpperPort: uint32(r.SrcportOrIcmptypeLast), - } - tcp := acl.ACL_Rule_IpRule_Tcp{ - DestinationPortRange: dstPortRange, - SourcePortRange: srcPortRange, - TcpFlagsMask: uint32(r.TCPFlagsMask), - TcpFlagsValue: uint32(r.TCPFlagsValue), - } - return &tcp -} - -// getUDPMatchRule translates a UDP match rule from the binary VPP API format -// into the ACL Plugin's NB format -func (h *ACLVppHandler) getUDPMatchRule(r vpp_acl.ACLRule) *acl.ACL_Rule_IpRule_Udp { - dstPortRange := &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: uint32(r.DstportOrIcmpcodeFirst), - UpperPort: uint32(r.DstportOrIcmpcodeLast), - } - srcPortRange := &acl.ACL_Rule_IpRule_PortRange{ - LowerPort: uint32(r.SrcportOrIcmptypeFirst), - UpperPort: uint32(r.SrcportOrIcmptypeLast), - } - udp := acl.ACL_Rule_IpRule_Udp{ - DestinationPortRange: dstPortRange, - SourcePortRange: srcPortRange, - } - return &udp -} - -// getIcmpMatchRule translates an ICMP match rule from the binary VPP API -// format into the ACL Plugin's NB format -func (h *ACLVppHandler) getIcmpMatchRule(r vpp_acl.ACLRule) *acl.ACL_Rule_IpRule_Icmp { - icmp := &acl.ACL_Rule_IpRule_Icmp{ - Icmpv6: r.IsIPv6 > 0, - IcmpCodeRange: &acl.ACL_Rule_IpRule_Icmp_Range{ - First: uint32(r.DstportOrIcmpcodeFirst), - Last: uint32(r.DstportOrIcmpcodeLast), - }, - IcmpTypeRange: &acl.ACL_Rule_IpRule_Icmp_Range{ - First: uint32(r.SrcportOrIcmptypeFirst), - Last: uint32(r.SrcportOrIcmptypeLast), - }, - } - return icmp -} - -// Returns rule action representation in model according to the vpp input -func (h *ACLVppHandler) resolveRuleAction(isPermit uint8) (acl.ACL_Rule_Action, error) { - switch isPermit { - case 0: - return acl.ACL_Rule_DENY, nil - case 1: - return acl.ACL_Rule_PERMIT, nil - case 2: - return acl.ACL_Rule_REFLECT, nil - default: - return acl.ACL_Rule_DENY, fmt.Errorf("invalid match rule %d", isPermit) - } -} diff --git a/plugins/vpp/aclplugin/vppcalls/vpp2001/dump_vppcalls_test.go b/plugins/vpp/aclplugin/vppcalls/vpp2001/dump_vppcalls_test.go deleted file mode 100644 index 741e310c3c..0000000000 --- a/plugins/vpp/aclplugin/vppcalls/vpp2001/dump_vppcalls_test.go +++ /dev/null @@ -1,402 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls" - vpp_acl "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" -) - -// Test translation of IP rule into ACL Plugin's format -func TestGetIPRuleMatch(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - icmpV4Rule := ctx.aclHandler.getIPRuleMatches(vpp_acl.ACLRule{ - SrcIPAddr: []byte{10, 0, 0, 1}, - SrcIPPrefixLen: 24, - DstIPAddr: []byte{20, 0, 0, 1}, - DstIPPrefixLen: 24, - Proto: vppcalls.ICMPv4Proto, - }) - if icmpV4Rule.GetIcmp() == nil { - t.Fatal("should have icmp match") - } - - icmpV6Rule := ctx.aclHandler.getIPRuleMatches(vpp_acl.ACLRule{ - IsIPv6: 1, - SrcIPAddr: []byte{'d', 'e', 'd', 'd', 1}, - SrcIPPrefixLen: 64, - DstIPAddr: []byte{'d', 'e', 'd', 'd', 2}, - DstIPPrefixLen: 32, - Proto: vppcalls.ICMPv6Proto, - }) - if icmpV6Rule.GetIcmp() == nil { - t.Fatal("should have icmpv6 match") - } - - tcpRule := ctx.aclHandler.getIPRuleMatches(vpp_acl.ACLRule{ - SrcIPAddr: []byte{10, 0, 0, 1}, - SrcIPPrefixLen: 24, - DstIPAddr: []byte{20, 0, 0, 1}, - DstIPPrefixLen: 24, - Proto: vppcalls.TCPProto, - }) - if tcpRule.GetTcp() == nil { - t.Fatal("should have tcp match") - } - - udpRule := ctx.aclHandler.getIPRuleMatches(vpp_acl.ACLRule{ - SrcIPAddr: []byte{10, 0, 0, 1}, - SrcIPPrefixLen: 24, - DstIPAddr: []byte{20, 0, 0, 1}, - DstIPPrefixLen: 24, - Proto: vppcalls.UDPProto, - }) - if udpRule.GetUdp() == nil { - t.Fatal("should have udp match") - } -} - -// Test translation of MACIP rule into ACL Plugin's format -func TestGetMACIPRuleMatches(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - macipV4Rule := ctx.aclHandler.getMACIPRuleMatches(vpp_acl.MacipACLRule{ - IsPermit: 1, - SrcMac: []byte{2, 'd', 'e', 'a', 'd', 2}, - SrcMacMask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, - SrcIPAddr: []byte{10, 0, 0, 1}, - SrcIPPrefixLen: 32, - }) - if macipV4Rule.GetSourceMacAddress() == "" { - t.Fatal("should have mac match") - } - macipV6Rule := ctx.aclHandler.getMACIPRuleMatches(vpp_acl.MacipACLRule{ - IsPermit: 0, - IsIPv6: 1, - SrcMac: []byte{2, 'd', 'e', 'a', 'd', 2}, - SrcMacMask: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, - SrcIPAddr: []byte{'d', 'e', 'a', 'd', 1}, - SrcIPPrefixLen: 64, - }) - if macipV6Rule.GetSourceMacAddress() == "" { - t.Fatal("should have mac match") - } -} - -// Test dumping of IP rules -func TestDumpIPACL(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply( - &vpp_acl.ACLDetails{ - ACLIndex: 0, - Tag: []byte{'a', 'c', 'l', '1'}, - Count: 1, - R: []vpp_acl.ACLRule{{IsPermit: 1}}, - }, - &vpp_acl.ACLDetails{ - ACLIndex: 1, - Tag: []byte{'a', 'c', 'l', '2'}, - Count: 2, - R: []vpp_acl.ACLRule{{IsPermit: 0}, {IsPermit: 2}}, - }, - &vpp_acl.ACLDetails{ - ACLIndex: 2, - Tag: []byte{'a', 'c', 'l', '3'}, - Count: 3, - R: []vpp_acl.ACLRule{{IsPermit: 0}, {IsPermit: 1}, {IsPermit: 2}}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 1, - Count: 2, - NInput: 1, - Acls: []uint32{0, 2}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - ctx.ifIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ifaces, err := ctx.aclHandler.DumpACL() - Expect(err).To(Succeed()) - Expect(ifaces).To(HaveLen(3)) - //Expect(ifaces[0].Identifier.ACLIndex).To(Equal(uint32(0))) - //Expect(ifaces[0].vppcalls.ACLDetails.Rules[0].AclAction).To(Equal(uint32(1))) - //Expect(ifaces[1].Identifier.ACLIndex).To(Equal(uint32(1))) - //Expect(ifaces[2].Identifier.ACLIndex).To(Equal(uint32(2))) -} - -// Test dumping of MACIP rules -func TestDumpMACIPACL(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply( - &vpp_acl.MacipACLDetails{ - ACLIndex: 0, - Tag: []byte{'a', 'c', 'l', '1'}, - Count: 1, - R: []vpp_acl.MacipACLRule{{IsPermit: 1}}, - }, - &vpp_acl.MacipACLDetails{ - ACLIndex: 1, - Tag: []byte{'a', 'c', 'l', '2'}, - Count: 2, - R: []vpp_acl.MacipACLRule{{IsPermit: 0}, {IsPermit: 2}}, - }, - &vpp_acl.MacipACLDetails{ - ACLIndex: 2, - Tag: []byte{'a', 'c', 'l', '3'}, - Count: 3, - R: []vpp_acl.MacipACLRule{{IsPermit: 0}, {IsPermit: 1}, {IsPermit: 2}}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceListDetails{ - SwIfIndex: 1, - Count: 2, - Acls: []uint32{0, 2}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - swIfIndexes := ifaceidx.NewIfaceIndex(logrus.DefaultLogger(), "test") - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ifaces, err := ctx.aclHandler.DumpMACIPACL() - Expect(err).To(Succeed()) - Expect(ifaces).To(HaveLen(3)) - //Expect(ifaces[0].Identifier.ACLIndex).To(Equal(uint32(0))) - //Expect(ifaces[0].vppcalls.ACLDetails.Rules[0].AclAction).To(Equal(uint32(1))) - //Expect(ifaces[1].Identifier.ACLIndex).To(Equal(uint32(1))) - //Expect(ifaces[2].Identifier.ACLIndex).To(Equal(uint32(2))) -} - -// Test dumping of interfaces with assigned IP rules -func TestDumpACLInterfaces(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 1, - Count: 2, - NInput: 1, - Acls: []uint32{0, 2}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - ctx.ifIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - indexes := []uint32{0, 2} - ifaces, err := ctx.aclHandler.DumpACLInterfaces(indexes) - Expect(err).To(Succeed()) - Expect(ifaces).To(HaveLen(2)) - Expect(ifaces[0].Ingress).To(Equal([]string{"if0"})) - Expect(ifaces[2].Egress).To(Equal([]string{"if0"})) -} - -// Test dumping of interfaces with assigned MACIP rules -func TestDumpMACIPACLInterfaces(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceListDetails{ - SwIfIndex: 1, - Count: 2, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - ctx.ifIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - indexes := []uint32{0, 1} - ifaces, err := ctx.aclHandler.DumpMACIPACLInterfaces(indexes) - Expect(err).To(Succeed()) - Expect(ifaces).To(HaveLen(2)) - Expect(ifaces[0].Ingress).To(Equal([]string{"if0"})) - Expect(ifaces[0].Egress).To(BeNil()) - Expect(ifaces[1].Ingress).To(Equal([]string{"if0"})) - Expect(ifaces[1].Egress).To(BeNil()) -} - -// Test dumping of all configured ACLs with IP-type ruleData -func TestDumpIPAcls(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.ACLDetails{ - ACLIndex: 0, - Count: 1, - R: []vpp_acl.ACLRule{{IsPermit: 1}}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - IPRuleACLs, err := ctx.aclHandler.DumpIPAcls() - Expect(err).To(Succeed()) - Expect(IPRuleACLs).To(HaveLen(1)) -} - -// Test dumping of all configured ACLs with MACIP-type ruleData -func TestDumpMacIPAcls(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLDetails{ - ACLIndex: 0, - Count: 1, - R: []vpp_acl.MacipACLRule{{IsPermit: 1}}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - MacIPRuleACLs, err := ctx.aclHandler.DumpMacIPAcls() - Expect(err).To(Succeed()) - Expect(MacIPRuleACLs).To(HaveLen(1)) -} - -func TestDumpInterfaceIPAcls(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 2, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLDetails{ - ACLIndex: 0, - Count: 1, - R: []vpp_acl.ACLRule{{IsPermit: 1}, {IsPermit: 0}}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLDetails{ - ACLIndex: 1, - Count: 1, - R: []vpp_acl.ACLRule{{IsPermit: 2}, {IsPermit: 0}}, - }) - - ACLs, err := ctx.aclHandler.DumpInterfaceACLs(0) - Expect(err).To(Succeed()) - Expect(ACLs).To(HaveLen(2)) -} - -func TestDumpInterfaceMACIPAcls(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 2, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.MacipACLDetails{ - ACLIndex: 0, - Count: 1, - R: []vpp_acl.MacipACLRule{{IsPermit: 1}, {IsPermit: 0}}, - }) - ctx.MockVpp.MockReply(&vpp_acl.MacipACLDetails{ - ACLIndex: 1, - Count: 1, - R: []vpp_acl.MacipACLRule{{IsPermit: 2}, {IsPermit: 1}}, - }) - - ACLs, err := ctx.aclHandler.DumpInterfaceMACIPACLs(0) - Expect(err).To(Succeed()) - Expect(ACLs).To(HaveLen(2)) -} - -func TestDumpInterface(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 2, - NInput: 1, - Acls: []uint32{0, 1}, - }) - IPacls, err := ctx.aclHandler.DumpInterfaceACLList(0) - Expect(err).To(BeNil()) - Expect(IPacls.Acls).To(HaveLen(2)) - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{}) - IPacls, err = ctx.aclHandler.DumpInterfaceACLList(0) - Expect(err).To(BeNil()) - Expect(IPacls.Acls).To(HaveLen(0)) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 2, - Acls: []uint32{0, 1}, - }) - MACIPacls, err := ctx.aclHandler.DumpInterfaceMACIPACLList(0) - Expect(err).To(BeNil()) - Expect(MACIPacls.Acls).To(HaveLen(2)) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceListDetails{}) - MACIPacls, err = ctx.aclHandler.DumpInterfaceMACIPACLList(0) - Expect(err).To(BeNil()) - Expect(MACIPacls.Acls).To(HaveLen(0)) -} - -func TestDumpInterfaces(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply( - &vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 2, - NInput: 1, - Acls: []uint32{0, 1}, - }, - &vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 1, - Count: 1, - NInput: 1, - Acls: []uint32{2}, - }, - &vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 2, - Count: 2, - NInput: 1, - Acls: []uint32{3, 4}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceListDetails{ - SwIfIndex: 3, - Count: 2, - Acls: []uint32{6, 7}, - }, - &vpp_acl.MacipACLInterfaceListDetails{ - SwIfIndex: 4, - Count: 1, - Acls: []uint32{5}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - IPacls, MACIPacls, err := ctx.aclHandler.DumpInterfacesLists() - Expect(err).To(BeNil()) - Expect(IPacls).To(HaveLen(3)) - Expect(MACIPacls).To(HaveLen(2)) -} diff --git a/plugins/vpp/aclplugin/vppcalls/vpp2001/interfaces_vppcalls.go b/plugins/vpp/aclplugin/vppcalls/vpp2001/interfaces_vppcalls.go deleted file mode 100644 index f9c1a124bf..0000000000 --- a/plugins/vpp/aclplugin/vppcalls/vpp2001/interfaces_vppcalls.go +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - - vpp_acl "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" -) - -// SetACLToInterfacesAsIngress implements ACL handler. -func (h *ACLVppHandler) SetACLToInterfacesAsIngress(ACLIndex uint32, ifIndices []uint32) error { - return h.requestSetACLToInterfaces(&aclInterfaceLogicalReq{ - aclIndex: ACLIndex, - ifIndices: ifIndices, - ingress: true, - }) -} - -// RemoveACLFromInterfacesAsIngress implements ACL handler. -func (h *ACLVppHandler) RemoveACLFromInterfacesAsIngress(ACLIndex uint32, ifIndices []uint32) error { - return h.requestRemoveInterfacesFromACL(&aclInterfaceLogicalReq{ - aclIndex: ACLIndex, - ifIndices: ifIndices, - ingress: true, - }) -} - -// SetACLToInterfacesAsEgress implements ACL handler. -func (h *ACLVppHandler) SetACLToInterfacesAsEgress(ACLIndex uint32, ifIndices []uint32) error { - return h.requestSetACLToInterfaces(&aclInterfaceLogicalReq{ - aclIndex: ACLIndex, - ifIndices: ifIndices, - ingress: false, - }) -} - -// RemoveACLFromInterfacesAsEgress implements ACL handler. -func (h *ACLVppHandler) RemoveACLFromInterfacesAsEgress(ACLIndex uint32, ifIndices []uint32) error { - return h.requestRemoveInterfacesFromACL(&aclInterfaceLogicalReq{ - aclIndex: ACLIndex, - ifIndices: ifIndices, - ingress: false, - }) -} - -// AddACLToInterfaceAsIngress implements ACL handler. -func (h *ACLVppHandler) AddACLToInterfaceAsIngress(aclIndex uint32, ifName string) error { - meta, ok := h.ifIndexes.LookupByName(ifName) - if !ok { - return fmt.Errorf("metadata for interface %s not found", ifName) - } - ifIdx := meta.SwIfIndex - - req := &vpp_acl.ACLInterfaceAddDel{ - ACLIndex: aclIndex, - IsAdd: 1, - SwIfIndex: ifIdx, - IsInput: 1, - } - reply := &vpp_acl.ACLInterfaceAddDelReply{} - - err := h.callsChannel.SendRequest(req).ReceiveReply(reply) - if err != nil { - return fmt.Errorf("failed to add interface %d to ACL (L3/L4) %d as ingress: %v", ifIdx, aclIndex, err) - } - - return nil -} - -// AddACLToInterfaceAsEgress implements ACL handler. -func (h *ACLVppHandler) AddACLToInterfaceAsEgress(aclIndex uint32, ifName string) error { - meta, ok := h.ifIndexes.LookupByName(ifName) - if !ok { - return fmt.Errorf("metadata for interface %s not found", ifName) - } - ifIdx := meta.SwIfIndex - - req := &vpp_acl.ACLInterfaceAddDel{ - ACLIndex: aclIndex, - IsAdd: 1, - SwIfIndex: ifIdx, - IsInput: 0, - } - reply := &vpp_acl.ACLInterfaceAddDelReply{} - - err := h.callsChannel.SendRequest(req).ReceiveReply(reply) - if err != nil { - return fmt.Errorf("failed to add interface %d to ACL (L3/L4) %d as egress: %v", ifIdx, aclIndex, err) - } - - return nil -} - -// DeleteACLFromInterfaceAsIngress implements ACL handler. -func (h *ACLVppHandler) DeleteACLFromInterfaceAsIngress(aclIndex uint32, ifName string) error { - meta, ok := h.ifIndexes.LookupByName(ifName) - if !ok { - return fmt.Errorf("metadata for interface %s not found", ifName) - } - ifIdx := meta.SwIfIndex - - req := &vpp_acl.ACLInterfaceAddDel{ - ACLIndex: aclIndex, - IsAdd: 0, - SwIfIndex: ifIdx, - IsInput: 1, - } - reply := &vpp_acl.ACLInterfaceAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("failed to delete interface %d from ACL (L3/L4) %d as ingress: %v", ifIdx, aclIndex, err) - } - - return nil -} - -// DeleteACLFromInterfaceAsEgress implements ACL handler. -func (h *ACLVppHandler) DeleteACLFromInterfaceAsEgress(aclIndex uint32, ifName string) error { - meta, ok := h.ifIndexes.LookupByName(ifName) - if !ok { - return fmt.Errorf("metadata for interface %s not found", ifName) - } - ifIdx := meta.SwIfIndex - - req := &vpp_acl.ACLInterfaceAddDel{ - ACLIndex: aclIndex, - IsAdd: 0, - SwIfIndex: ifIdx, - IsInput: 0, - } - reply := &vpp_acl.ACLInterfaceAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("failed to delete interface %d from ACL (L3/L4) %d as egress: %v", ifIdx, aclIndex, err) - } - - return nil -} - -// AddMACIPACLToInterface implements ACL handler. -func (h *ACLVppHandler) AddMACIPACLToInterface(aclIndex uint32, ifName string) error { - meta, ok := h.ifIndexes.LookupByName(ifName) - if !ok { - return fmt.Errorf("metadata for interface %s not found", ifName) - } - ifIdx := meta.SwIfIndex - - req := &vpp_acl.MacipACLInterfaceAddDel{ - ACLIndex: aclIndex, - IsAdd: 1, - SwIfIndex: ifIdx, - } - reply := &vpp_acl.MacipACLInterfaceAddDelReply{} - - err := h.callsChannel.SendRequest(req).ReceiveReply(reply) - if err != nil { - return fmt.Errorf("failed to add interface %d to MACIP ACL (L2) %d: %v", ifIdx, aclIndex, err) - } - - return nil -} - -// DeleteMACIPACLFromInterface implements ACL handler. -func (h *ACLVppHandler) DeleteMACIPACLFromInterface(aclIndex uint32, ifName string) error { - meta, ok := h.ifIndexes.LookupByName(ifName) - if !ok { - return fmt.Errorf("metadata for interface %s not found", ifName) - } - ifIdx := meta.SwIfIndex - - req := &vpp_acl.MacipACLInterfaceAddDel{ - ACLIndex: aclIndex, - IsAdd: 0, - SwIfIndex: ifIdx, - } - reply := &vpp_acl.MacipACLInterfaceAddDelReply{} - - err := h.callsChannel.SendRequest(req).ReceiveReply(reply) - if err != nil { - return fmt.Errorf("failed to delete interface %d from MACIP ACL (L2) %d: %v", ifIdx, aclIndex, err) - } - - return nil -} - -// SetMACIPACLToInterfaces implements ACL handler. -func (h *ACLVppHandler) SetMACIPACLToInterfaces(aclIndex uint32, ifIndices []uint32) error { - for _, ingressIfIdx := range ifIndices { - req := &vpp_acl.MacipACLInterfaceAddDel{ - ACLIndex: aclIndex, - IsAdd: 1, - SwIfIndex: ingressIfIdx, - } - reply := &vpp_acl.MacipACLInterfaceAddDelReply{} - - err := h.callsChannel.SendRequest(req).ReceiveReply(reply) - if err != nil { - return fmt.Errorf("failed to set interface %d to L2 ACL %d: %v", ingressIfIdx, aclIndex, err) - } - } - - return nil -} - -// RemoveMACIPACLFromInterfaces implements ACL handler. -func (h *ACLVppHandler) RemoveMACIPACLFromInterfaces(removedACLIndex uint32, ifIndices []uint32) error { - for _, ifIdx := range ifIndices { - req := &vpp_acl.MacipACLInterfaceAddDel{ - ACLIndex: removedACLIndex, - SwIfIndex: ifIdx, - IsAdd: 0, - } - reply := &vpp_acl.MacipACLInterfaceAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("failed to remove L2 ACL %d from interface %d: %v", removedACLIndex, ifIdx, err) - } - } - return nil -} - -// aclInterfaceLogicalReq groups multiple fields to not enumerate all of them in one function call -type aclInterfaceLogicalReq struct { - aclIndex uint32 - ifIndices []uint32 - ingress bool -} - -func (h *ACLVppHandler) requestSetACLToInterfaces(logicalReq *aclInterfaceLogicalReq) error { - for _, aclIfIdx := range logicalReq.ifIndices { - // Create acl list with new entry - var ACLs []uint32 - - // All previously assigned ACLs have to be dumped and added to acl list - aclInterfaceDetails, err := h.DumpInterfaceACLList(aclIfIdx) - if err != nil { - return err - } - - var nInput uint8 - if aclInterfaceDetails != nil { - nInput = aclInterfaceDetails.NInput - if logicalReq.ingress { - // Construct ACL list. ACLs within NInput are defined as ingress, so provided new aclIndex has to be - // added to the beginning of the list - // TODO it would be nicer to add new acl index to newNInput index - ACLs = append(ACLs, logicalReq.aclIndex) - for _, aclIndex := range aclInterfaceDetails.Acls { - ACLs = append(ACLs, aclIndex) - } - nInput++ // Rise NInput - } else { - // Construct ACL list. ACLs outside of NInput are defined as egress, so provided new aclIndex has to be - // added to the end of the list - for _, aclIndex := range aclInterfaceDetails.Acls { - ACLs = append(ACLs, aclIndex) - } - ACLs = append(ACLs, logicalReq.aclIndex) - // NInput remains the same - } - } - - msg := &vpp_acl.ACLInterfaceSetACLList{ - Acls: ACLs, - Count: uint8(len(ACLs)), - SwIfIndex: aclIfIdx, - NInput: nInput, - } - reply := &vpp_acl.ACLInterfaceSetACLListReply{} - - err = h.callsChannel.SendRequest(msg).ReceiveReply(reply) - if err != nil { - return err - } - } - - return nil -} - -func (h *ACLVppHandler) requestRemoveInterfacesFromACL(logicalReq *aclInterfaceLogicalReq) error { - var wasErr error - for _, aclIfIdx := range logicalReq.ifIndices { - // Create empty ACL list - var ACLs []uint32 - - // All assigned ACLs have to be dumped - aclInterfaceDetails, err := h.DumpInterfaceACLList(aclIfIdx) - if err != nil { - return err - } - - // Reconstruct ACL list without removed ACL - var nInput uint8 - if aclInterfaceDetails != nil { - nInput = aclInterfaceDetails.NInput - for idx, aclIndex := range aclInterfaceDetails.Acls { - if (aclIndex != logicalReq.aclIndex) || - (logicalReq.ingress && idx >= int(aclInterfaceDetails.NInput)) || - (!logicalReq.ingress && idx < int(aclInterfaceDetails.NInput)) { - ACLs = append(ACLs, aclIndex) - } else { - // Decrease NInput if ingress, otherwise keep it the same - if logicalReq.ingress { - nInput-- - } - } - } - } - - msg := &vpp_acl.ACLInterfaceSetACLList{ - Acls: ACLs, - Count: uint8(len(ACLs)), - SwIfIndex: aclIfIdx, - NInput: nInput, - } - - reply := &vpp_acl.ACLInterfaceSetACLListReply{} - err = h.callsChannel.SendRequest(msg).ReceiveReply(reply) - if err != nil { - wasErr = err - } - } - - return wasErr -} diff --git a/plugins/vpp/aclplugin/vppcalls/vpp2001/interfaces_vppcalls_test.go b/plugins/vpp/aclplugin/vppcalls/vpp2001/interfaces_vppcalls_test.go deleted file mode 100644 index cac194ec52..0000000000 --- a/plugins/vpp/aclplugin/vppcalls/vpp2001/interfaces_vppcalls_test.go +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_acl "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" -) - -// Test assignment of IP acl rule to given interface -func TestRequestSetACLToInterfaces(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{}) - err := ctx.aclHandler.SetACLToInterfacesAsIngress(0, []uint32{0}) - Expect(err).To(BeNil()) - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{}) - err = ctx.aclHandler.SetACLToInterfacesAsEgress(0, []uint32{0}) - Expect(err).To(BeNil()) - - // error cases - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{}) - err = ctx.aclHandler.SetACLToInterfacesAsIngress(0, []uint32{0}) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{}) - err = ctx.aclHandler.SetACLToInterfacesAsIngress(0, []uint32{0}) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{Retval: -1}) - err = ctx.aclHandler.SetACLToInterfacesAsIngress(0, []uint32{0}) - Expect(err).To(Not(BeNil())) -} - -// Test deletion of IP acl rule from given interface -func TestRequestRemoveInterfacesFromACL(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{}) - err := ctx.aclHandler.RemoveACLFromInterfacesAsIngress(0, []uint32{0}) - Expect(err).To(BeNil()) - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{}) - err = ctx.aclHandler.RemoveACLFromInterfacesAsEgress(0, []uint32{0}) - Expect(err).To(BeNil()) - - // error cases - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{}) - err = ctx.aclHandler.RemoveACLFromInterfacesAsEgress(0, []uint32{0}) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{}) - err = ctx.aclHandler.RemoveACLFromInterfacesAsEgress(0, []uint32{0}) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceListDetails{ - SwIfIndex: 0, - Count: 1, - NInput: 1, - Acls: []uint32{0, 1}, - }) - ctx.MockVpp.MockReply(&vpp_acl.ACLInterfaceSetACLListReply{Retval: -1}) - err = ctx.aclHandler.RemoveACLFromInterfacesAsEgress(0, []uint32{0}) - Expect(err).To(Not(BeNil())) -} - -// Test assignment of MACIP acl rule to given interface -func TestSetMacIPAclToInterface(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceAddDelReply{}) - err := ctx.aclHandler.SetMACIPACLToInterfaces(0, []uint32{0}) - Expect(err).To(BeNil()) - - // error cases - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{}) - err = ctx.aclHandler.SetMACIPACLToInterfaces(0, []uint32{0}) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceAddDelReply{Retval: -1}) - err = ctx.aclHandler.SetMACIPACLToInterfaces(0, []uint32{0}) - Expect(err).To(Not(BeNil())) -} - -// Test deletion of MACIP acl rule from given interface -func TestRemoveMacIPIngressACLFromInterfaces(t *testing.T) { - ctx := setupACLTest(t) - defer ctx.teardownACLTest() - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceAddDelReply{}) - err := ctx.aclHandler.RemoveMACIPACLFromInterfaces(1, []uint32{0}) - Expect(err).To(BeNil()) - - // error cases - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLAddReplaceReply{}) - err = ctx.aclHandler.RemoveMACIPACLFromInterfaces(0, []uint32{0}) - Expect(err).To(Not(BeNil())) - - ctx.MockVpp.MockReply(&vpp_acl.MacipACLInterfaceAddDelReply{Retval: -1}) - err = ctx.aclHandler.RemoveMACIPACLFromInterfaces(0, []uint32{0}) - Expect(err).To(Not(BeNil())) -} diff --git a/plugins/vpp/aclplugin/vppcalls/vpp2001/vppcalls_handlers.go b/plugins/vpp/aclplugin/vppcalls/vpp2001/vppcalls_handlers.go deleted file mode 100644 index d8a45b772d..0000000000 --- a/plugins/vpp/aclplugin/vppcalls/vpp2001/vppcalls_handlers.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/aclplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" -) - -func init() { - msgs := acl.AllMessages() - vppcalls.AddHandlerVersion(vpp2001.Version, msgs, NewACLVppHandler) -} - -// ACLVppHandler is accessor for acl-related vppcalls methods -type ACLVppHandler struct { - callsChannel govppapi.Channel - // TODO: use only RPC service - acl acl.RPCService - ifIndexes ifaceidx.IfaceMetadataIndex -} - -func NewACLVppHandler(c vpp.Client, ifIdx ifaceidx.IfaceMetadataIndex) vppcalls.ACLVppAPI { - ch, err := c.NewAPIChannel() - if err != nil { - return nil - } - return &ACLVppHandler{ - callsChannel: ch, - acl: acl.NewServiceClient(ch), - ifIndexes: ifIdx, - } -} diff --git a/plugins/vpp/binapi/vpp2001/abf/abf.ba.go b/plugins/vpp/binapi/vpp2001/abf/abf.ba.go deleted file mode 100644 index a5e47f7c19..0000000000 --- a/plugins/vpp/binapi/vpp2001/abf/abf.ba.go +++ /dev/null @@ -1,352 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/abf.api.json - -/* -Package abf is a generated VPP binary API for 'abf' module. - -It consists of: - 13 enums - 6 aliases - 11 types - 1 union - 10 messages - 5 services -*/ -package abf - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - fib_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "abf" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xc2e5c644 -) - -type AddressFamily = ip_types.AddressFamily - -type FibPathFlags = fib_types.FibPathFlags - -type FibPathNhProto = fib_types.FibPathNhProto - -type FibPathType = fib_types.FibPathType - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -// AbfItfAttach represents VPP binary API type 'abf_itf_attach'. -type AbfItfAttach struct { - PolicyID uint32 - SwIfIndex InterfaceIndex - Priority uint32 - IsIPv6 bool -} - -func (*AbfItfAttach) GetTypeName() string { return "abf_itf_attach" } - -// AbfPolicy represents VPP binary API type 'abf_policy'. -type AbfPolicy struct { - PolicyID uint32 - ACLIndex uint32 - NPaths uint8 `struc:"sizeof=Paths"` - Paths []FibPath -} - -func (*AbfPolicy) GetTypeName() string { return "abf_policy" } - -type Address = ip_types.Address - -type FibMplsLabel = fib_types.FibMplsLabel - -type FibPath = fib_types.FibPath - -type FibPathNh = fib_types.FibPathNh - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// AbfItfAttachAddDel represents VPP binary API message 'abf_itf_attach_add_del'. -type AbfItfAttachAddDel struct { - IsAdd bool - Attach AbfItfAttach -} - -func (m *AbfItfAttachAddDel) Reset() { *m = AbfItfAttachAddDel{} } -func (*AbfItfAttachAddDel) GetMessageName() string { return "abf_itf_attach_add_del" } -func (*AbfItfAttachAddDel) GetCrcString() string { return "25c8621b" } -func (*AbfItfAttachAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// AbfItfAttachAddDelReply represents VPP binary API message 'abf_itf_attach_add_del_reply'. -type AbfItfAttachAddDelReply struct { - Retval int32 -} - -func (m *AbfItfAttachAddDelReply) Reset() { *m = AbfItfAttachAddDelReply{} } -func (*AbfItfAttachAddDelReply) GetMessageName() string { return "abf_itf_attach_add_del_reply" } -func (*AbfItfAttachAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*AbfItfAttachAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AbfItfAttachDetails represents VPP binary API message 'abf_itf_attach_details'. -type AbfItfAttachDetails struct { - Attach AbfItfAttach -} - -func (m *AbfItfAttachDetails) Reset() { *m = AbfItfAttachDetails{} } -func (*AbfItfAttachDetails) GetMessageName() string { return "abf_itf_attach_details" } -func (*AbfItfAttachDetails) GetCrcString() string { return "7819523e" } -func (*AbfItfAttachDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AbfItfAttachDump represents VPP binary API message 'abf_itf_attach_dump'. -type AbfItfAttachDump struct{} - -func (m *AbfItfAttachDump) Reset() { *m = AbfItfAttachDump{} } -func (*AbfItfAttachDump) GetMessageName() string { return "abf_itf_attach_dump" } -func (*AbfItfAttachDump) GetCrcString() string { return "51077d14" } -func (*AbfItfAttachDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// AbfPluginGetVersion represents VPP binary API message 'abf_plugin_get_version'. -type AbfPluginGetVersion struct{} - -func (m *AbfPluginGetVersion) Reset() { *m = AbfPluginGetVersion{} } -func (*AbfPluginGetVersion) GetMessageName() string { return "abf_plugin_get_version" } -func (*AbfPluginGetVersion) GetCrcString() string { return "51077d14" } -func (*AbfPluginGetVersion) GetMessageType() api.MessageType { return api.RequestMessage } - -// AbfPluginGetVersionReply represents VPP binary API message 'abf_plugin_get_version_reply'. -type AbfPluginGetVersionReply struct { - Major uint32 - Minor uint32 -} - -func (m *AbfPluginGetVersionReply) Reset() { *m = AbfPluginGetVersionReply{} } -func (*AbfPluginGetVersionReply) GetMessageName() string { return "abf_plugin_get_version_reply" } -func (*AbfPluginGetVersionReply) GetCrcString() string { return "9b32cf86" } -func (*AbfPluginGetVersionReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AbfPolicyAddDel represents VPP binary API message 'abf_policy_add_del'. -type AbfPolicyAddDel struct { - IsAdd bool - Policy AbfPolicy -} - -func (m *AbfPolicyAddDel) Reset() { *m = AbfPolicyAddDel{} } -func (*AbfPolicyAddDel) GetMessageName() string { return "abf_policy_add_del" } -func (*AbfPolicyAddDel) GetCrcString() string { return "ee66f93e" } -func (*AbfPolicyAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// AbfPolicyAddDelReply represents VPP binary API message 'abf_policy_add_del_reply'. -type AbfPolicyAddDelReply struct { - Retval int32 -} - -func (m *AbfPolicyAddDelReply) Reset() { *m = AbfPolicyAddDelReply{} } -func (*AbfPolicyAddDelReply) GetMessageName() string { return "abf_policy_add_del_reply" } -func (*AbfPolicyAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*AbfPolicyAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AbfPolicyDetails represents VPP binary API message 'abf_policy_details'. -type AbfPolicyDetails struct { - Policy AbfPolicy -} - -func (m *AbfPolicyDetails) Reset() { *m = AbfPolicyDetails{} } -func (*AbfPolicyDetails) GetMessageName() string { return "abf_policy_details" } -func (*AbfPolicyDetails) GetCrcString() string { return "6769e504" } -func (*AbfPolicyDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AbfPolicyDump represents VPP binary API message 'abf_policy_dump'. -type AbfPolicyDump struct{} - -func (m *AbfPolicyDump) Reset() { *m = AbfPolicyDump{} } -func (*AbfPolicyDump) GetMessageName() string { return "abf_policy_dump" } -func (*AbfPolicyDump) GetCrcString() string { return "51077d14" } -func (*AbfPolicyDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*AbfItfAttachAddDel)(nil), "abf.AbfItfAttachAddDel") - api.RegisterMessage((*AbfItfAttachAddDelReply)(nil), "abf.AbfItfAttachAddDelReply") - api.RegisterMessage((*AbfItfAttachDetails)(nil), "abf.AbfItfAttachDetails") - api.RegisterMessage((*AbfItfAttachDump)(nil), "abf.AbfItfAttachDump") - api.RegisterMessage((*AbfPluginGetVersion)(nil), "abf.AbfPluginGetVersion") - api.RegisterMessage((*AbfPluginGetVersionReply)(nil), "abf.AbfPluginGetVersionReply") - api.RegisterMessage((*AbfPolicyAddDel)(nil), "abf.AbfPolicyAddDel") - api.RegisterMessage((*AbfPolicyAddDelReply)(nil), "abf.AbfPolicyAddDelReply") - api.RegisterMessage((*AbfPolicyDetails)(nil), "abf.AbfPolicyDetails") - api.RegisterMessage((*AbfPolicyDump)(nil), "abf.AbfPolicyDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*AbfItfAttachAddDel)(nil), - (*AbfItfAttachAddDelReply)(nil), - (*AbfItfAttachDetails)(nil), - (*AbfItfAttachDump)(nil), - (*AbfPluginGetVersion)(nil), - (*AbfPluginGetVersionReply)(nil), - (*AbfPolicyAddDel)(nil), - (*AbfPolicyAddDelReply)(nil), - (*AbfPolicyDetails)(nil), - (*AbfPolicyDump)(nil), - } -} - -// RPCService represents RPC service API for abf module. -type RPCService interface { - DumpAbfItfAttach(ctx context.Context, in *AbfItfAttachDump) (RPCService_DumpAbfItfAttachClient, error) - DumpAbfPolicy(ctx context.Context, in *AbfPolicyDump) (RPCService_DumpAbfPolicyClient, error) - AbfItfAttachAddDel(ctx context.Context, in *AbfItfAttachAddDel) (*AbfItfAttachAddDelReply, error) - AbfPluginGetVersion(ctx context.Context, in *AbfPluginGetVersion) (*AbfPluginGetVersionReply, error) - AbfPolicyAddDel(ctx context.Context, in *AbfPolicyAddDel) (*AbfPolicyAddDelReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpAbfItfAttach(ctx context.Context, in *AbfItfAttachDump) (RPCService_DumpAbfItfAttachClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpAbfItfAttachClient{stream} - return x, nil -} - -type RPCService_DumpAbfItfAttachClient interface { - Recv() (*AbfItfAttachDetails, error) -} - -type serviceClient_DumpAbfItfAttachClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpAbfItfAttachClient) Recv() (*AbfItfAttachDetails, error) { - m := new(AbfItfAttachDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpAbfPolicy(ctx context.Context, in *AbfPolicyDump) (RPCService_DumpAbfPolicyClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpAbfPolicyClient{stream} - return x, nil -} - -type RPCService_DumpAbfPolicyClient interface { - Recv() (*AbfPolicyDetails, error) -} - -type serviceClient_DumpAbfPolicyClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpAbfPolicyClient) Recv() (*AbfPolicyDetails, error) { - m := new(AbfPolicyDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) AbfItfAttachAddDel(ctx context.Context, in *AbfItfAttachAddDel) (*AbfItfAttachAddDelReply, error) { - out := new(AbfItfAttachAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) AbfPluginGetVersion(ctx context.Context, in *AbfPluginGetVersion) (*AbfPluginGetVersionReply, error) { - out := new(AbfPluginGetVersionReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) AbfPolicyAddDel(ctx context.Context, in *AbfPolicyAddDel) (*AbfPolicyAddDelReply, error) { - out := new(AbfPolicyAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/acl/acl.ba.go b/plugins/vpp/binapi/vpp2001/acl/acl.ba.go deleted file mode 100644 index 1042ffbc35..0000000000 --- a/plugins/vpp/binapi/vpp2001/acl/acl.ba.go +++ /dev/null @@ -1,882 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/acl.api.json - -/* -Package acl is a generated VPP binary API for 'acl' module. - -It consists of: - 2 types - 38 messages - 19 services -*/ -package acl - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "acl" - // APIVersion is the API version of this module. - APIVersion = "1.0.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0x11c5c1e5 -) - -// ACLRule represents VPP binary API type 'acl_rule'. -type ACLRule struct { - IsPermit uint8 - IsIPv6 uint8 - SrcIPAddr []byte `struc:"[16]byte"` - SrcIPPrefixLen uint8 - DstIPAddr []byte `struc:"[16]byte"` - DstIPPrefixLen uint8 - Proto uint8 - SrcportOrIcmptypeFirst uint16 - SrcportOrIcmptypeLast uint16 - DstportOrIcmpcodeFirst uint16 - DstportOrIcmpcodeLast uint16 - TCPFlagsMask uint8 - TCPFlagsValue uint8 -} - -func (*ACLRule) GetTypeName() string { return "acl_rule" } - -// MacipACLRule represents VPP binary API type 'macip_acl_rule'. -type MacipACLRule struct { - IsPermit uint8 - IsIPv6 uint8 - SrcMac []byte `struc:"[6]byte"` - SrcMacMask []byte `struc:"[6]byte"` - SrcIPAddr []byte `struc:"[16]byte"` - SrcIPPrefixLen uint8 -} - -func (*MacipACLRule) GetTypeName() string { return "macip_acl_rule" } - -// ACLAddReplace represents VPP binary API message 'acl_add_replace'. -type ACLAddReplace struct { - ACLIndex uint32 - Tag []byte `struc:"[64]byte"` - Count uint32 `struc:"sizeof=R"` - R []ACLRule -} - -func (m *ACLAddReplace) Reset() { *m = ACLAddReplace{} } -func (*ACLAddReplace) GetMessageName() string { return "acl_add_replace" } -func (*ACLAddReplace) GetCrcString() string { return "13bc8539" } -func (*ACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLAddReplaceReply represents VPP binary API message 'acl_add_replace_reply'. -type ACLAddReplaceReply struct { - ACLIndex uint32 - Retval int32 -} - -func (m *ACLAddReplaceReply) Reset() { *m = ACLAddReplaceReply{} } -func (*ACLAddReplaceReply) GetMessageName() string { return "acl_add_replace_reply" } -func (*ACLAddReplaceReply) GetCrcString() string { return "ac407b0c" } -func (*ACLAddReplaceReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLDel represents VPP binary API message 'acl_del'. -type ACLDel struct { - ACLIndex uint32 -} - -func (m *ACLDel) Reset() { *m = ACLDel{} } -func (*ACLDel) GetMessageName() string { return "acl_del" } -func (*ACLDel) GetCrcString() string { return "ef34fea4" } -func (*ACLDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLDelReply represents VPP binary API message 'acl_del_reply'. -type ACLDelReply struct { - Retval int32 -} - -func (m *ACLDelReply) Reset() { *m = ACLDelReply{} } -func (*ACLDelReply) GetMessageName() string { return "acl_del_reply" } -func (*ACLDelReply) GetCrcString() string { return "e8d4e804" } -func (*ACLDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLDetails represents VPP binary API message 'acl_details'. -type ACLDetails struct { - ACLIndex uint32 - Tag []byte `struc:"[64]byte"` - Count uint32 `struc:"sizeof=R"` - R []ACLRule -} - -func (m *ACLDetails) Reset() { *m = ACLDetails{} } -func (*ACLDetails) GetMessageName() string { return "acl_details" } -func (*ACLDetails) GetCrcString() string { return "f89d7a88" } -func (*ACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLDump represents VPP binary API message 'acl_dump'. -type ACLDump struct { - ACLIndex uint32 -} - -func (m *ACLDump) Reset() { *m = ACLDump{} } -func (*ACLDump) GetMessageName() string { return "acl_dump" } -func (*ACLDump) GetCrcString() string { return "ef34fea4" } -func (*ACLDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLInterfaceAddDel represents VPP binary API message 'acl_interface_add_del'. -type ACLInterfaceAddDel struct { - IsAdd uint8 - IsInput uint8 - SwIfIndex uint32 - ACLIndex uint32 -} - -func (m *ACLInterfaceAddDel) Reset() { *m = ACLInterfaceAddDel{} } -func (*ACLInterfaceAddDel) GetMessageName() string { return "acl_interface_add_del" } -func (*ACLInterfaceAddDel) GetCrcString() string { return "0b2aedd1" } -func (*ACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLInterfaceAddDelReply represents VPP binary API message 'acl_interface_add_del_reply'. -type ACLInterfaceAddDelReply struct { - Retval int32 -} - -func (m *ACLInterfaceAddDelReply) Reset() { *m = ACLInterfaceAddDelReply{} } -func (*ACLInterfaceAddDelReply) GetMessageName() string { return "acl_interface_add_del_reply" } -func (*ACLInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*ACLInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLInterfaceEtypeWhitelistDetails represents VPP binary API message 'acl_interface_etype_whitelist_details'. -type ACLInterfaceEtypeWhitelistDetails struct { - SwIfIndex uint32 - Count uint8 `struc:"sizeof=Whitelist"` - NInput uint8 - Whitelist []uint16 -} - -func (m *ACLInterfaceEtypeWhitelistDetails) Reset() { *m = ACLInterfaceEtypeWhitelistDetails{} } -func (*ACLInterfaceEtypeWhitelistDetails) GetMessageName() string { - return "acl_interface_etype_whitelist_details" -} -func (*ACLInterfaceEtypeWhitelistDetails) GetCrcString() string { return "6a5d4e81" } -func (*ACLInterfaceEtypeWhitelistDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLInterfaceEtypeWhitelistDump represents VPP binary API message 'acl_interface_etype_whitelist_dump'. -type ACLInterfaceEtypeWhitelistDump struct { - SwIfIndex uint32 -} - -func (m *ACLInterfaceEtypeWhitelistDump) Reset() { *m = ACLInterfaceEtypeWhitelistDump{} } -func (*ACLInterfaceEtypeWhitelistDump) GetMessageName() string { - return "acl_interface_etype_whitelist_dump" -} -func (*ACLInterfaceEtypeWhitelistDump) GetCrcString() string { return "529cb13f" } -func (*ACLInterfaceEtypeWhitelistDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLInterfaceListDetails represents VPP binary API message 'acl_interface_list_details'. -type ACLInterfaceListDetails struct { - SwIfIndex uint32 - Count uint8 `struc:"sizeof=Acls"` - NInput uint8 - Acls []uint32 -} - -func (m *ACLInterfaceListDetails) Reset() { *m = ACLInterfaceListDetails{} } -func (*ACLInterfaceListDetails) GetMessageName() string { return "acl_interface_list_details" } -func (*ACLInterfaceListDetails) GetCrcString() string { return "d5e80809" } -func (*ACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLInterfaceListDump represents VPP binary API message 'acl_interface_list_dump'. -type ACLInterfaceListDump struct { - SwIfIndex uint32 -} - -func (m *ACLInterfaceListDump) Reset() { *m = ACLInterfaceListDump{} } -func (*ACLInterfaceListDump) GetMessageName() string { return "acl_interface_list_dump" } -func (*ACLInterfaceListDump) GetCrcString() string { return "529cb13f" } -func (*ACLInterfaceListDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLInterfaceSetACLList represents VPP binary API message 'acl_interface_set_acl_list'. -type ACLInterfaceSetACLList struct { - SwIfIndex uint32 - Count uint8 `struc:"sizeof=Acls"` - NInput uint8 - Acls []uint32 -} - -func (m *ACLInterfaceSetACLList) Reset() { *m = ACLInterfaceSetACLList{} } -func (*ACLInterfaceSetACLList) GetMessageName() string { return "acl_interface_set_acl_list" } -func (*ACLInterfaceSetACLList) GetCrcString() string { return "8baece38" } -func (*ACLInterfaceSetACLList) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLInterfaceSetACLListReply represents VPP binary API message 'acl_interface_set_acl_list_reply'. -type ACLInterfaceSetACLListReply struct { - Retval int32 -} - -func (m *ACLInterfaceSetACLListReply) Reset() { *m = ACLInterfaceSetACLListReply{} } -func (*ACLInterfaceSetACLListReply) GetMessageName() string { - return "acl_interface_set_acl_list_reply" -} -func (*ACLInterfaceSetACLListReply) GetCrcString() string { return "e8d4e804" } -func (*ACLInterfaceSetACLListReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLInterfaceSetEtypeWhitelist represents VPP binary API message 'acl_interface_set_etype_whitelist'. -type ACLInterfaceSetEtypeWhitelist struct { - SwIfIndex uint32 - Count uint8 `struc:"sizeof=Whitelist"` - NInput uint8 - Whitelist []uint16 -} - -func (m *ACLInterfaceSetEtypeWhitelist) Reset() { *m = ACLInterfaceSetEtypeWhitelist{} } -func (*ACLInterfaceSetEtypeWhitelist) GetMessageName() string { - return "acl_interface_set_etype_whitelist" -} -func (*ACLInterfaceSetEtypeWhitelist) GetCrcString() string { return "f515efc5" } -func (*ACLInterfaceSetEtypeWhitelist) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLInterfaceSetEtypeWhitelistReply represents VPP binary API message 'acl_interface_set_etype_whitelist_reply'. -type ACLInterfaceSetEtypeWhitelistReply struct { - Retval int32 -} - -func (m *ACLInterfaceSetEtypeWhitelistReply) Reset() { *m = ACLInterfaceSetEtypeWhitelistReply{} } -func (*ACLInterfaceSetEtypeWhitelistReply) GetMessageName() string { - return "acl_interface_set_etype_whitelist_reply" -} -func (*ACLInterfaceSetEtypeWhitelistReply) GetCrcString() string { return "e8d4e804" } -func (*ACLInterfaceSetEtypeWhitelistReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLPluginControlPing represents VPP binary API message 'acl_plugin_control_ping'. -type ACLPluginControlPing struct{} - -func (m *ACLPluginControlPing) Reset() { *m = ACLPluginControlPing{} } -func (*ACLPluginControlPing) GetMessageName() string { return "acl_plugin_control_ping" } -func (*ACLPluginControlPing) GetCrcString() string { return "51077d14" } -func (*ACLPluginControlPing) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLPluginControlPingReply represents VPP binary API message 'acl_plugin_control_ping_reply'. -type ACLPluginControlPingReply struct { - Retval int32 - ClientIndex uint32 - VpePID uint32 -} - -func (m *ACLPluginControlPingReply) Reset() { *m = ACLPluginControlPingReply{} } -func (*ACLPluginControlPingReply) GetMessageName() string { return "acl_plugin_control_ping_reply" } -func (*ACLPluginControlPingReply) GetCrcString() string { return "f6b0b8ca" } -func (*ACLPluginControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLPluginGetConnTableMaxEntries represents VPP binary API message 'acl_plugin_get_conn_table_max_entries'. -type ACLPluginGetConnTableMaxEntries struct{} - -func (m *ACLPluginGetConnTableMaxEntries) Reset() { *m = ACLPluginGetConnTableMaxEntries{} } -func (*ACLPluginGetConnTableMaxEntries) GetMessageName() string { - return "acl_plugin_get_conn_table_max_entries" -} -func (*ACLPluginGetConnTableMaxEntries) GetCrcString() string { return "51077d14" } -func (*ACLPluginGetConnTableMaxEntries) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLPluginGetConnTableMaxEntriesReply represents VPP binary API message 'acl_plugin_get_conn_table_max_entries_reply'. -type ACLPluginGetConnTableMaxEntriesReply struct { - ConnTableMaxEntries uint64 -} - -func (m *ACLPluginGetConnTableMaxEntriesReply) Reset() { *m = ACLPluginGetConnTableMaxEntriesReply{} } -func (*ACLPluginGetConnTableMaxEntriesReply) GetMessageName() string { - return "acl_plugin_get_conn_table_max_entries_reply" -} -func (*ACLPluginGetConnTableMaxEntriesReply) GetCrcString() string { return "7a096d3d" } -func (*ACLPluginGetConnTableMaxEntriesReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// ACLPluginGetVersion represents VPP binary API message 'acl_plugin_get_version'. -type ACLPluginGetVersion struct{} - -func (m *ACLPluginGetVersion) Reset() { *m = ACLPluginGetVersion{} } -func (*ACLPluginGetVersion) GetMessageName() string { return "acl_plugin_get_version" } -func (*ACLPluginGetVersion) GetCrcString() string { return "51077d14" } -func (*ACLPluginGetVersion) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLPluginGetVersionReply represents VPP binary API message 'acl_plugin_get_version_reply'. -type ACLPluginGetVersionReply struct { - Major uint32 - Minor uint32 -} - -func (m *ACLPluginGetVersionReply) Reset() { *m = ACLPluginGetVersionReply{} } -func (*ACLPluginGetVersionReply) GetMessageName() string { return "acl_plugin_get_version_reply" } -func (*ACLPluginGetVersionReply) GetCrcString() string { return "9b32cf86" } -func (*ACLPluginGetVersionReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ACLStatsIntfCountersEnable represents VPP binary API message 'acl_stats_intf_counters_enable'. -type ACLStatsIntfCountersEnable struct { - Enable bool -} - -func (m *ACLStatsIntfCountersEnable) Reset() { *m = ACLStatsIntfCountersEnable{} } -func (*ACLStatsIntfCountersEnable) GetMessageName() string { return "acl_stats_intf_counters_enable" } -func (*ACLStatsIntfCountersEnable) GetCrcString() string { return "b3e225d2" } -func (*ACLStatsIntfCountersEnable) GetMessageType() api.MessageType { return api.RequestMessage } - -// ACLStatsIntfCountersEnableReply represents VPP binary API message 'acl_stats_intf_counters_enable_reply'. -type ACLStatsIntfCountersEnableReply struct { - Retval int32 -} - -func (m *ACLStatsIntfCountersEnableReply) Reset() { *m = ACLStatsIntfCountersEnableReply{} } -func (*ACLStatsIntfCountersEnableReply) GetMessageName() string { - return "acl_stats_intf_counters_enable_reply" -} -func (*ACLStatsIntfCountersEnableReply) GetCrcString() string { return "e8d4e804" } -func (*ACLStatsIntfCountersEnableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLAdd represents VPP binary API message 'macip_acl_add'. -type MacipACLAdd struct { - Tag []byte `struc:"[64]byte"` - Count uint32 `struc:"sizeof=R"` - R []MacipACLRule -} - -func (m *MacipACLAdd) Reset() { *m = MacipACLAdd{} } -func (*MacipACLAdd) GetMessageName() string { return "macip_acl_add" } -func (*MacipACLAdd) GetCrcString() string { return "0c680ca5" } -func (*MacipACLAdd) GetMessageType() api.MessageType { return api.RequestMessage } - -// MacipACLAddReplace represents VPP binary API message 'macip_acl_add_replace'. -type MacipACLAddReplace struct { - ACLIndex uint32 - Tag []byte `struc:"[64]byte"` - Count uint32 `struc:"sizeof=R"` - R []MacipACLRule -} - -func (m *MacipACLAddReplace) Reset() { *m = MacipACLAddReplace{} } -func (*MacipACLAddReplace) GetMessageName() string { return "macip_acl_add_replace" } -func (*MacipACLAddReplace) GetCrcString() string { return "d3d313e7" } -func (*MacipACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } - -// MacipACLAddReplaceReply represents VPP binary API message 'macip_acl_add_replace_reply'. -type MacipACLAddReplaceReply struct { - ACLIndex uint32 - Retval int32 -} - -func (m *MacipACLAddReplaceReply) Reset() { *m = MacipACLAddReplaceReply{} } -func (*MacipACLAddReplaceReply) GetMessageName() string { return "macip_acl_add_replace_reply" } -func (*MacipACLAddReplaceReply) GetCrcString() string { return "ac407b0c" } -func (*MacipACLAddReplaceReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLAddReply represents VPP binary API message 'macip_acl_add_reply'. -type MacipACLAddReply struct { - ACLIndex uint32 - Retval int32 -} - -func (m *MacipACLAddReply) Reset() { *m = MacipACLAddReply{} } -func (*MacipACLAddReply) GetMessageName() string { return "macip_acl_add_reply" } -func (*MacipACLAddReply) GetCrcString() string { return "ac407b0c" } -func (*MacipACLAddReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLDel represents VPP binary API message 'macip_acl_del'. -type MacipACLDel struct { - ACLIndex uint32 -} - -func (m *MacipACLDel) Reset() { *m = MacipACLDel{} } -func (*MacipACLDel) GetMessageName() string { return "macip_acl_del" } -func (*MacipACLDel) GetCrcString() string { return "ef34fea4" } -func (*MacipACLDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// MacipACLDelReply represents VPP binary API message 'macip_acl_del_reply'. -type MacipACLDelReply struct { - Retval int32 -} - -func (m *MacipACLDelReply) Reset() { *m = MacipACLDelReply{} } -func (*MacipACLDelReply) GetMessageName() string { return "macip_acl_del_reply" } -func (*MacipACLDelReply) GetCrcString() string { return "e8d4e804" } -func (*MacipACLDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLDetails represents VPP binary API message 'macip_acl_details'. -type MacipACLDetails struct { - ACLIndex uint32 - Tag []byte `struc:"[64]byte"` - Count uint32 `struc:"sizeof=R"` - R []MacipACLRule -} - -func (m *MacipACLDetails) Reset() { *m = MacipACLDetails{} } -func (*MacipACLDetails) GetMessageName() string { return "macip_acl_details" } -func (*MacipACLDetails) GetCrcString() string { return "e164e69a" } -func (*MacipACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLDump represents VPP binary API message 'macip_acl_dump'. -type MacipACLDump struct { - ACLIndex uint32 -} - -func (m *MacipACLDump) Reset() { *m = MacipACLDump{} } -func (*MacipACLDump) GetMessageName() string { return "macip_acl_dump" } -func (*MacipACLDump) GetCrcString() string { return "ef34fea4" } -func (*MacipACLDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// MacipACLInterfaceAddDel represents VPP binary API message 'macip_acl_interface_add_del'. -type MacipACLInterfaceAddDel struct { - IsAdd uint8 - SwIfIndex uint32 - ACLIndex uint32 -} - -func (m *MacipACLInterfaceAddDel) Reset() { *m = MacipACLInterfaceAddDel{} } -func (*MacipACLInterfaceAddDel) GetMessageName() string { return "macip_acl_interface_add_del" } -func (*MacipACLInterfaceAddDel) GetCrcString() string { return "6a6be97c" } -func (*MacipACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// MacipACLInterfaceAddDelReply represents VPP binary API message 'macip_acl_interface_add_del_reply'. -type MacipACLInterfaceAddDelReply struct { - Retval int32 -} - -func (m *MacipACLInterfaceAddDelReply) Reset() { *m = MacipACLInterfaceAddDelReply{} } -func (*MacipACLInterfaceAddDelReply) GetMessageName() string { - return "macip_acl_interface_add_del_reply" -} -func (*MacipACLInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*MacipACLInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLInterfaceGet represents VPP binary API message 'macip_acl_interface_get'. -type MacipACLInterfaceGet struct{} - -func (m *MacipACLInterfaceGet) Reset() { *m = MacipACLInterfaceGet{} } -func (*MacipACLInterfaceGet) GetMessageName() string { return "macip_acl_interface_get" } -func (*MacipACLInterfaceGet) GetCrcString() string { return "51077d14" } -func (*MacipACLInterfaceGet) GetMessageType() api.MessageType { return api.RequestMessage } - -// MacipACLInterfaceGetReply represents VPP binary API message 'macip_acl_interface_get_reply'. -type MacipACLInterfaceGetReply struct { - Count uint32 `struc:"sizeof=Acls"` - Acls []uint32 -} - -func (m *MacipACLInterfaceGetReply) Reset() { *m = MacipACLInterfaceGetReply{} } -func (*MacipACLInterfaceGetReply) GetMessageName() string { return "macip_acl_interface_get_reply" } -func (*MacipACLInterfaceGetReply) GetCrcString() string { return "accf9b05" } -func (*MacipACLInterfaceGetReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLInterfaceListDetails represents VPP binary API message 'macip_acl_interface_list_details'. -type MacipACLInterfaceListDetails struct { - SwIfIndex uint32 - Count uint8 `struc:"sizeof=Acls"` - Acls []uint32 -} - -func (m *MacipACLInterfaceListDetails) Reset() { *m = MacipACLInterfaceListDetails{} } -func (*MacipACLInterfaceListDetails) GetMessageName() string { - return "macip_acl_interface_list_details" -} -func (*MacipACLInterfaceListDetails) GetCrcString() string { return "29783fa0" } -func (*MacipACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MacipACLInterfaceListDump represents VPP binary API message 'macip_acl_interface_list_dump'. -type MacipACLInterfaceListDump struct { - SwIfIndex uint32 -} - -func (m *MacipACLInterfaceListDump) Reset() { *m = MacipACLInterfaceListDump{} } -func (*MacipACLInterfaceListDump) GetMessageName() string { return "macip_acl_interface_list_dump" } -func (*MacipACLInterfaceListDump) GetCrcString() string { return "529cb13f" } -func (*MacipACLInterfaceListDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*ACLAddReplace)(nil), "acl.ACLAddReplace") - api.RegisterMessage((*ACLAddReplaceReply)(nil), "acl.ACLAddReplaceReply") - api.RegisterMessage((*ACLDel)(nil), "acl.ACLDel") - api.RegisterMessage((*ACLDelReply)(nil), "acl.ACLDelReply") - api.RegisterMessage((*ACLDetails)(nil), "acl.ACLDetails") - api.RegisterMessage((*ACLDump)(nil), "acl.ACLDump") - api.RegisterMessage((*ACLInterfaceAddDel)(nil), "acl.ACLInterfaceAddDel") - api.RegisterMessage((*ACLInterfaceAddDelReply)(nil), "acl.ACLInterfaceAddDelReply") - api.RegisterMessage((*ACLInterfaceEtypeWhitelistDetails)(nil), "acl.ACLInterfaceEtypeWhitelistDetails") - api.RegisterMessage((*ACLInterfaceEtypeWhitelistDump)(nil), "acl.ACLInterfaceEtypeWhitelistDump") - api.RegisterMessage((*ACLInterfaceListDetails)(nil), "acl.ACLInterfaceListDetails") - api.RegisterMessage((*ACLInterfaceListDump)(nil), "acl.ACLInterfaceListDump") - api.RegisterMessage((*ACLInterfaceSetACLList)(nil), "acl.ACLInterfaceSetACLList") - api.RegisterMessage((*ACLInterfaceSetACLListReply)(nil), "acl.ACLInterfaceSetACLListReply") - api.RegisterMessage((*ACLInterfaceSetEtypeWhitelist)(nil), "acl.ACLInterfaceSetEtypeWhitelist") - api.RegisterMessage((*ACLInterfaceSetEtypeWhitelistReply)(nil), "acl.ACLInterfaceSetEtypeWhitelistReply") - api.RegisterMessage((*ACLPluginControlPing)(nil), "acl.ACLPluginControlPing") - api.RegisterMessage((*ACLPluginControlPingReply)(nil), "acl.ACLPluginControlPingReply") - api.RegisterMessage((*ACLPluginGetConnTableMaxEntries)(nil), "acl.ACLPluginGetConnTableMaxEntries") - api.RegisterMessage((*ACLPluginGetConnTableMaxEntriesReply)(nil), "acl.ACLPluginGetConnTableMaxEntriesReply") - api.RegisterMessage((*ACLPluginGetVersion)(nil), "acl.ACLPluginGetVersion") - api.RegisterMessage((*ACLPluginGetVersionReply)(nil), "acl.ACLPluginGetVersionReply") - api.RegisterMessage((*ACLStatsIntfCountersEnable)(nil), "acl.ACLStatsIntfCountersEnable") - api.RegisterMessage((*ACLStatsIntfCountersEnableReply)(nil), "acl.ACLStatsIntfCountersEnableReply") - api.RegisterMessage((*MacipACLAdd)(nil), "acl.MacipACLAdd") - api.RegisterMessage((*MacipACLAddReplace)(nil), "acl.MacipACLAddReplace") - api.RegisterMessage((*MacipACLAddReplaceReply)(nil), "acl.MacipACLAddReplaceReply") - api.RegisterMessage((*MacipACLAddReply)(nil), "acl.MacipACLAddReply") - api.RegisterMessage((*MacipACLDel)(nil), "acl.MacipACLDel") - api.RegisterMessage((*MacipACLDelReply)(nil), "acl.MacipACLDelReply") - api.RegisterMessage((*MacipACLDetails)(nil), "acl.MacipACLDetails") - api.RegisterMessage((*MacipACLDump)(nil), "acl.MacipACLDump") - api.RegisterMessage((*MacipACLInterfaceAddDel)(nil), "acl.MacipACLInterfaceAddDel") - api.RegisterMessage((*MacipACLInterfaceAddDelReply)(nil), "acl.MacipACLInterfaceAddDelReply") - api.RegisterMessage((*MacipACLInterfaceGet)(nil), "acl.MacipACLInterfaceGet") - api.RegisterMessage((*MacipACLInterfaceGetReply)(nil), "acl.MacipACLInterfaceGetReply") - api.RegisterMessage((*MacipACLInterfaceListDetails)(nil), "acl.MacipACLInterfaceListDetails") - api.RegisterMessage((*MacipACLInterfaceListDump)(nil), "acl.MacipACLInterfaceListDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*ACLAddReplace)(nil), - (*ACLAddReplaceReply)(nil), - (*ACLDel)(nil), - (*ACLDelReply)(nil), - (*ACLDetails)(nil), - (*ACLDump)(nil), - (*ACLInterfaceAddDel)(nil), - (*ACLInterfaceAddDelReply)(nil), - (*ACLInterfaceEtypeWhitelistDetails)(nil), - (*ACLInterfaceEtypeWhitelistDump)(nil), - (*ACLInterfaceListDetails)(nil), - (*ACLInterfaceListDump)(nil), - (*ACLInterfaceSetACLList)(nil), - (*ACLInterfaceSetACLListReply)(nil), - (*ACLInterfaceSetEtypeWhitelist)(nil), - (*ACLInterfaceSetEtypeWhitelistReply)(nil), - (*ACLPluginControlPing)(nil), - (*ACLPluginControlPingReply)(nil), - (*ACLPluginGetConnTableMaxEntries)(nil), - (*ACLPluginGetConnTableMaxEntriesReply)(nil), - (*ACLPluginGetVersion)(nil), - (*ACLPluginGetVersionReply)(nil), - (*ACLStatsIntfCountersEnable)(nil), - (*ACLStatsIntfCountersEnableReply)(nil), - (*MacipACLAdd)(nil), - (*MacipACLAddReplace)(nil), - (*MacipACLAddReplaceReply)(nil), - (*MacipACLAddReply)(nil), - (*MacipACLDel)(nil), - (*MacipACLDelReply)(nil), - (*MacipACLDetails)(nil), - (*MacipACLDump)(nil), - (*MacipACLInterfaceAddDel)(nil), - (*MacipACLInterfaceAddDelReply)(nil), - (*MacipACLInterfaceGet)(nil), - (*MacipACLInterfaceGetReply)(nil), - (*MacipACLInterfaceListDetails)(nil), - (*MacipACLInterfaceListDump)(nil), - } -} - -// RPCService represents RPC service API for acl module. -type RPCService interface { - DumpACL(ctx context.Context, in *ACLDump) (RPCService_DumpACLClient, error) - DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_DumpACLInterfaceEtypeWhitelistClient, error) - DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) (RPCService_DumpACLInterfaceListClient, error) - DumpMacipACL(ctx context.Context, in *MacipACLDump) (RPCService_DumpMacipACLClient, error) - DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_DumpMacipACLInterfaceListClient, error) - ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) - ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) - ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) - ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSetACLList) (*ACLInterfaceSetACLListReply, error) - ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) - ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) - ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) - ACLPluginGetVersion(ctx context.Context, in *ACLPluginGetVersion) (*ACLPluginGetVersionReply, error) - ACLStatsIntfCountersEnable(ctx context.Context, in *ACLStatsIntfCountersEnable) (*ACLStatsIntfCountersEnableReply, error) - MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) - MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) - MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) - MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) - MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpACL(ctx context.Context, in *ACLDump) (RPCService_DumpACLClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpACLClient{stream} - return x, nil -} - -type RPCService_DumpACLClient interface { - Recv() (*ACLDetails, error) -} - -type serviceClient_DumpACLClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpACLClient) Recv() (*ACLDetails, error) { - m := new(ACLDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpACLInterfaceEtypeWhitelist(ctx context.Context, in *ACLInterfaceEtypeWhitelistDump) (RPCService_DumpACLInterfaceEtypeWhitelistClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpACLInterfaceEtypeWhitelistClient{stream} - return x, nil -} - -type RPCService_DumpACLInterfaceEtypeWhitelistClient interface { - Recv() (*ACLInterfaceEtypeWhitelistDetails, error) -} - -type serviceClient_DumpACLInterfaceEtypeWhitelistClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpACLInterfaceEtypeWhitelistClient) Recv() (*ACLInterfaceEtypeWhitelistDetails, error) { - m := new(ACLInterfaceEtypeWhitelistDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpACLInterfaceList(ctx context.Context, in *ACLInterfaceListDump) (RPCService_DumpACLInterfaceListClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpACLInterfaceListClient{stream} - return x, nil -} - -type RPCService_DumpACLInterfaceListClient interface { - Recv() (*ACLInterfaceListDetails, error) -} - -type serviceClient_DumpACLInterfaceListClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpACLInterfaceListClient) Recv() (*ACLInterfaceListDetails, error) { - m := new(ACLInterfaceListDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpMacipACL(ctx context.Context, in *MacipACLDump) (RPCService_DumpMacipACLClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpMacipACLClient{stream} - return x, nil -} - -type RPCService_DumpMacipACLClient interface { - Recv() (*MacipACLDetails, error) -} - -type serviceClient_DumpMacipACLClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpMacipACLClient) Recv() (*MacipACLDetails, error) { - m := new(MacipACLDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpMacipACLInterfaceList(ctx context.Context, in *MacipACLInterfaceListDump) (RPCService_DumpMacipACLInterfaceListClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpMacipACLInterfaceListClient{stream} - return x, nil -} - -type RPCService_DumpMacipACLInterfaceListClient interface { - Recv() (*MacipACLInterfaceListDetails, error) -} - -type serviceClient_DumpMacipACLInterfaceListClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpMacipACLInterfaceListClient) Recv() (*MacipACLInterfaceListDetails, error) { - m := new(MacipACLInterfaceListDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) ACLAddReplace(ctx context.Context, in *ACLAddReplace) (*ACLAddReplaceReply, error) { - out := new(ACLAddReplaceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLDel(ctx context.Context, in *ACLDel) (*ACLDelReply, error) { - out := new(ACLDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLInterfaceAddDel(ctx context.Context, in *ACLInterfaceAddDel) (*ACLInterfaceAddDelReply, error) { - out := new(ACLInterfaceAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLInterfaceSetACLList(ctx context.Context, in *ACLInterfaceSetACLList) (*ACLInterfaceSetACLListReply, error) { - out := new(ACLInterfaceSetACLListReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLInterfaceSetEtypeWhitelist(ctx context.Context, in *ACLInterfaceSetEtypeWhitelist) (*ACLInterfaceSetEtypeWhitelistReply, error) { - out := new(ACLInterfaceSetEtypeWhitelistReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLPluginControlPing(ctx context.Context, in *ACLPluginControlPing) (*ACLPluginControlPingReply, error) { - out := new(ACLPluginControlPingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLPluginGetConnTableMaxEntries(ctx context.Context, in *ACLPluginGetConnTableMaxEntries) (*ACLPluginGetConnTableMaxEntriesReply, error) { - out := new(ACLPluginGetConnTableMaxEntriesReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLPluginGetVersion(ctx context.Context, in *ACLPluginGetVersion) (*ACLPluginGetVersionReply, error) { - out := new(ACLPluginGetVersionReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ACLStatsIntfCountersEnable(ctx context.Context, in *ACLStatsIntfCountersEnable) (*ACLStatsIntfCountersEnableReply, error) { - out := new(ACLStatsIntfCountersEnableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MacipACLAdd(ctx context.Context, in *MacipACLAdd) (*MacipACLAddReply, error) { - out := new(MacipACLAddReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MacipACLAddReplace(ctx context.Context, in *MacipACLAddReplace) (*MacipACLAddReplaceReply, error) { - out := new(MacipACLAddReplaceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MacipACLDel(ctx context.Context, in *MacipACLDel) (*MacipACLDelReply, error) { - out := new(MacipACLDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MacipACLInterfaceAddDel(ctx context.Context, in *MacipACLInterfaceAddDel) (*MacipACLInterfaceAddDelReply, error) { - out := new(MacipACLInterfaceAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MacipACLInterfaceGet(ctx context.Context, in *MacipACLInterfaceGet) (*MacipACLInterfaceGetReply, error) { - out := new(MacipACLInterfaceGetReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/af_packet/af_packet.ba.go b/plugins/vpp/binapi/vpp2001/af_packet/af_packet.ba.go deleted file mode 100644 index a571b95b1b..0000000000 --- a/plugins/vpp/binapi/vpp2001/af_packet/af_packet.ba.go +++ /dev/null @@ -1,244 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/af_packet.api.json - -/* -Package af_packet is a generated VPP binary API for 'af_packet' module. - -It consists of: - 6 enums - 2 aliases - 8 messages - 4 services -*/ -package af_packet - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "af_packet" - // APIVersion is the API version of this module. - APIVersion = "2.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xba745e20 -) - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type InterfaceIndex = interface_types.InterfaceIndex - -type MacAddress = ethernet_types.MacAddress - -// AfPacketCreate represents VPP binary API message 'af_packet_create'. -type AfPacketCreate struct { - HwAddr MacAddress - UseRandomHwAddr bool - HostIfName string `struc:"[64]byte"` -} - -func (m *AfPacketCreate) Reset() { *m = AfPacketCreate{} } -func (*AfPacketCreate) GetMessageName() string { return "af_packet_create" } -func (*AfPacketCreate) GetCrcString() string { return "a190415f" } -func (*AfPacketCreate) GetMessageType() api.MessageType { return api.RequestMessage } - -// AfPacketCreateReply represents VPP binary API message 'af_packet_create_reply'. -type AfPacketCreateReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *AfPacketCreateReply) Reset() { *m = AfPacketCreateReply{} } -func (*AfPacketCreateReply) GetMessageName() string { return "af_packet_create_reply" } -func (*AfPacketCreateReply) GetCrcString() string { return "5383d31f" } -func (*AfPacketCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AfPacketDelete represents VPP binary API message 'af_packet_delete'. -type AfPacketDelete struct { - HostIfName string `struc:"[64]byte"` -} - -func (m *AfPacketDelete) Reset() { *m = AfPacketDelete{} } -func (*AfPacketDelete) GetMessageName() string { return "af_packet_delete" } -func (*AfPacketDelete) GetCrcString() string { return "863fa648" } -func (*AfPacketDelete) GetMessageType() api.MessageType { return api.RequestMessage } - -// AfPacketDeleteReply represents VPP binary API message 'af_packet_delete_reply'. -type AfPacketDeleteReply struct { - Retval int32 -} - -func (m *AfPacketDeleteReply) Reset() { *m = AfPacketDeleteReply{} } -func (*AfPacketDeleteReply) GetMessageName() string { return "af_packet_delete_reply" } -func (*AfPacketDeleteReply) GetCrcString() string { return "e8d4e804" } -func (*AfPacketDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AfPacketDetails represents VPP binary API message 'af_packet_details'. -type AfPacketDetails struct { - SwIfIndex InterfaceIndex - HostIfName string `struc:"[64]byte"` -} - -func (m *AfPacketDetails) Reset() { *m = AfPacketDetails{} } -func (*AfPacketDetails) GetMessageName() string { return "af_packet_details" } -func (*AfPacketDetails) GetCrcString() string { return "58c7c042" } -func (*AfPacketDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// AfPacketDump represents VPP binary API message 'af_packet_dump'. -type AfPacketDump struct{} - -func (m *AfPacketDump) Reset() { *m = AfPacketDump{} } -func (*AfPacketDump) GetMessageName() string { return "af_packet_dump" } -func (*AfPacketDump) GetCrcString() string { return "51077d14" } -func (*AfPacketDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// AfPacketSetL4CksumOffload represents VPP binary API message 'af_packet_set_l4_cksum_offload'. -type AfPacketSetL4CksumOffload struct { - SwIfIndex InterfaceIndex - Set bool -} - -func (m *AfPacketSetL4CksumOffload) Reset() { *m = AfPacketSetL4CksumOffload{} } -func (*AfPacketSetL4CksumOffload) GetMessageName() string { return "af_packet_set_l4_cksum_offload" } -func (*AfPacketSetL4CksumOffload) GetCrcString() string { return "319cd5c8" } -func (*AfPacketSetL4CksumOffload) GetMessageType() api.MessageType { return api.RequestMessage } - -// AfPacketSetL4CksumOffloadReply represents VPP binary API message 'af_packet_set_l4_cksum_offload_reply'. -type AfPacketSetL4CksumOffloadReply struct { - Retval int32 -} - -func (m *AfPacketSetL4CksumOffloadReply) Reset() { *m = AfPacketSetL4CksumOffloadReply{} } -func (*AfPacketSetL4CksumOffloadReply) GetMessageName() string { - return "af_packet_set_l4_cksum_offload_reply" -} -func (*AfPacketSetL4CksumOffloadReply) GetCrcString() string { return "e8d4e804" } -func (*AfPacketSetL4CksumOffloadReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*AfPacketCreate)(nil), "af_packet.AfPacketCreate") - api.RegisterMessage((*AfPacketCreateReply)(nil), "af_packet.AfPacketCreateReply") - api.RegisterMessage((*AfPacketDelete)(nil), "af_packet.AfPacketDelete") - api.RegisterMessage((*AfPacketDeleteReply)(nil), "af_packet.AfPacketDeleteReply") - api.RegisterMessage((*AfPacketDetails)(nil), "af_packet.AfPacketDetails") - api.RegisterMessage((*AfPacketDump)(nil), "af_packet.AfPacketDump") - api.RegisterMessage((*AfPacketSetL4CksumOffload)(nil), "af_packet.AfPacketSetL4CksumOffload") - api.RegisterMessage((*AfPacketSetL4CksumOffloadReply)(nil), "af_packet.AfPacketSetL4CksumOffloadReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*AfPacketCreate)(nil), - (*AfPacketCreateReply)(nil), - (*AfPacketDelete)(nil), - (*AfPacketDeleteReply)(nil), - (*AfPacketDetails)(nil), - (*AfPacketDump)(nil), - (*AfPacketSetL4CksumOffload)(nil), - (*AfPacketSetL4CksumOffloadReply)(nil), - } -} - -// RPCService represents RPC service API for af_packet module. -type RPCService interface { - DumpAfPacket(ctx context.Context, in *AfPacketDump) (RPCService_DumpAfPacketClient, error) - AfPacketCreate(ctx context.Context, in *AfPacketCreate) (*AfPacketCreateReply, error) - AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPacketDeleteReply, error) - AfPacketSetL4CksumOffload(ctx context.Context, in *AfPacketSetL4CksumOffload) (*AfPacketSetL4CksumOffloadReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpAfPacket(ctx context.Context, in *AfPacketDump) (RPCService_DumpAfPacketClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpAfPacketClient{stream} - return x, nil -} - -type RPCService_DumpAfPacketClient interface { - Recv() (*AfPacketDetails, error) -} - -type serviceClient_DumpAfPacketClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpAfPacketClient) Recv() (*AfPacketDetails, error) { - m := new(AfPacketDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) AfPacketCreate(ctx context.Context, in *AfPacketCreate) (*AfPacketCreateReply, error) { - out := new(AfPacketCreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) AfPacketDelete(ctx context.Context, in *AfPacketDelete) (*AfPacketDeleteReply, error) { - out := new(AfPacketDeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) AfPacketSetL4CksumOffload(ctx context.Context, in *AfPacketSetL4CksumOffload) (*AfPacketSetL4CksumOffloadReply, error) { - out := new(AfPacketSetL4CksumOffloadReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/arp/arp.ba.go b/plugins/vpp/binapi/vpp2001/arp/arp.ba.go deleted file mode 100644 index 06ce793c63..0000000000 --- a/plugins/vpp/binapi/vpp2001/arp/arp.ba.go +++ /dev/null @@ -1,300 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/arp.api.json - -/* -Package arp is a generated VPP binary API for 'arp' module. - -It consists of: - 10 enums - 7 aliases - 7 types - 1 union - 8 messages - 4 services -*/ -package arp - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "arp" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xa818aaf3 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type MacAddress = ethernet_types.MacAddress - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -// ProxyArp represents VPP binary API type 'proxy_arp'. -type ProxyArp struct { - TableID uint32 - Low IP4Address - Hi IP4Address -} - -func (*ProxyArp) GetTypeName() string { return "proxy_arp" } - -type AddressUnion = ip_types.AddressUnion - -// ProxyArpAddDel represents VPP binary API message 'proxy_arp_add_del'. -type ProxyArpAddDel struct { - IsAdd bool - Proxy ProxyArp -} - -func (m *ProxyArpAddDel) Reset() { *m = ProxyArpAddDel{} } -func (*ProxyArpAddDel) GetMessageName() string { return "proxy_arp_add_del" } -func (*ProxyArpAddDel) GetCrcString() string { return "85486cbd" } -func (*ProxyArpAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// ProxyArpAddDelReply represents VPP binary API message 'proxy_arp_add_del_reply'. -type ProxyArpAddDelReply struct { - Retval int32 -} - -func (m *ProxyArpAddDelReply) Reset() { *m = ProxyArpAddDelReply{} } -func (*ProxyArpAddDelReply) GetMessageName() string { return "proxy_arp_add_del_reply" } -func (*ProxyArpAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*ProxyArpAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ProxyArpDetails represents VPP binary API message 'proxy_arp_details'. -type ProxyArpDetails struct { - Proxy ProxyArp -} - -func (m *ProxyArpDetails) Reset() { *m = ProxyArpDetails{} } -func (*ProxyArpDetails) GetMessageName() string { return "proxy_arp_details" } -func (*ProxyArpDetails) GetCrcString() string { return "9228c150" } -func (*ProxyArpDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ProxyArpDump represents VPP binary API message 'proxy_arp_dump'. -type ProxyArpDump struct{} - -func (m *ProxyArpDump) Reset() { *m = ProxyArpDump{} } -func (*ProxyArpDump) GetMessageName() string { return "proxy_arp_dump" } -func (*ProxyArpDump) GetCrcString() string { return "51077d14" } -func (*ProxyArpDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// ProxyArpIntfcDetails represents VPP binary API message 'proxy_arp_intfc_details'. -type ProxyArpIntfcDetails struct { - SwIfIndex uint32 -} - -func (m *ProxyArpIntfcDetails) Reset() { *m = ProxyArpIntfcDetails{} } -func (*ProxyArpIntfcDetails) GetMessageName() string { return "proxy_arp_intfc_details" } -func (*ProxyArpIntfcDetails) GetCrcString() string { return "f6458e5f" } -func (*ProxyArpIntfcDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ProxyArpIntfcDump represents VPP binary API message 'proxy_arp_intfc_dump'. -type ProxyArpIntfcDump struct{} - -func (m *ProxyArpIntfcDump) Reset() { *m = ProxyArpIntfcDump{} } -func (*ProxyArpIntfcDump) GetMessageName() string { return "proxy_arp_intfc_dump" } -func (*ProxyArpIntfcDump) GetCrcString() string { return "51077d14" } -func (*ProxyArpIntfcDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// ProxyArpIntfcEnableDisable represents VPP binary API message 'proxy_arp_intfc_enable_disable'. -type ProxyArpIntfcEnableDisable struct { - SwIfIndex InterfaceIndex - Enable bool -} - -func (m *ProxyArpIntfcEnableDisable) Reset() { *m = ProxyArpIntfcEnableDisable{} } -func (*ProxyArpIntfcEnableDisable) GetMessageName() string { return "proxy_arp_intfc_enable_disable" } -func (*ProxyArpIntfcEnableDisable) GetCrcString() string { return "ae6cfcfb" } -func (*ProxyArpIntfcEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// ProxyArpIntfcEnableDisableReply represents VPP binary API message 'proxy_arp_intfc_enable_disable_reply'. -type ProxyArpIntfcEnableDisableReply struct { - Retval int32 -} - -func (m *ProxyArpIntfcEnableDisableReply) Reset() { *m = ProxyArpIntfcEnableDisableReply{} } -func (*ProxyArpIntfcEnableDisableReply) GetMessageName() string { - return "proxy_arp_intfc_enable_disable_reply" -} -func (*ProxyArpIntfcEnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*ProxyArpIntfcEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*ProxyArpAddDel)(nil), "arp.ProxyArpAddDel") - api.RegisterMessage((*ProxyArpAddDelReply)(nil), "arp.ProxyArpAddDelReply") - api.RegisterMessage((*ProxyArpDetails)(nil), "arp.ProxyArpDetails") - api.RegisterMessage((*ProxyArpDump)(nil), "arp.ProxyArpDump") - api.RegisterMessage((*ProxyArpIntfcDetails)(nil), "arp.ProxyArpIntfcDetails") - api.RegisterMessage((*ProxyArpIntfcDump)(nil), "arp.ProxyArpIntfcDump") - api.RegisterMessage((*ProxyArpIntfcEnableDisable)(nil), "arp.ProxyArpIntfcEnableDisable") - api.RegisterMessage((*ProxyArpIntfcEnableDisableReply)(nil), "arp.ProxyArpIntfcEnableDisableReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*ProxyArpAddDel)(nil), - (*ProxyArpAddDelReply)(nil), - (*ProxyArpDetails)(nil), - (*ProxyArpDump)(nil), - (*ProxyArpIntfcDetails)(nil), - (*ProxyArpIntfcDump)(nil), - (*ProxyArpIntfcEnableDisable)(nil), - (*ProxyArpIntfcEnableDisableReply)(nil), - } -} - -// RPCService represents RPC service API for arp module. -type RPCService interface { - DumpProxyArp(ctx context.Context, in *ProxyArpDump) (RPCService_DumpProxyArpClient, error) - DumpProxyArpIntfc(ctx context.Context, in *ProxyArpIntfcDump) (RPCService_DumpProxyArpIntfcClient, error) - ProxyArpAddDel(ctx context.Context, in *ProxyArpAddDel) (*ProxyArpAddDelReply, error) - ProxyArpIntfcEnableDisable(ctx context.Context, in *ProxyArpIntfcEnableDisable) (*ProxyArpIntfcEnableDisableReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpProxyArp(ctx context.Context, in *ProxyArpDump) (RPCService_DumpProxyArpClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpProxyArpClient{stream} - return x, nil -} - -type RPCService_DumpProxyArpClient interface { - Recv() (*ProxyArpDetails, error) -} - -type serviceClient_DumpProxyArpClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpProxyArpClient) Recv() (*ProxyArpDetails, error) { - m := new(ProxyArpDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpProxyArpIntfc(ctx context.Context, in *ProxyArpIntfcDump) (RPCService_DumpProxyArpIntfcClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpProxyArpIntfcClient{stream} - return x, nil -} - -type RPCService_DumpProxyArpIntfcClient interface { - Recv() (*ProxyArpIntfcDetails, error) -} - -type serviceClient_DumpProxyArpIntfcClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpProxyArpIntfcClient) Recv() (*ProxyArpIntfcDetails, error) { - m := new(ProxyArpIntfcDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) ProxyArpAddDel(ctx context.Context, in *ProxyArpAddDel) (*ProxyArpAddDelReply, error) { - out := new(ProxyArpAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ProxyArpIntfcEnableDisable(ctx context.Context, in *ProxyArpIntfcEnableDisable) (*ProxyArpIntfcEnableDisableReply, error) { - out := new(ProxyArpIntfcEnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/bond/bond.ba.go b/plugins/vpp/binapi/vpp2001/bond/bond.ba.go deleted file mode 100644 index a174d54fa1..0000000000 --- a/plugins/vpp/binapi/vpp2001/bond/bond.ba.go +++ /dev/null @@ -1,453 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/bond.api.json - -/* -Package bond is a generated VPP binary API for 'bond' module. - -It consists of: - 8 enums - 2 aliases - 14 messages - 7 services -*/ -package bond - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "bond" - // APIVersion is the API version of this module. - APIVersion = "2.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x69f583ad -) - -// BondLbAlgo represents VPP binary API enum 'bond_lb_algo'. -type BondLbAlgo uint32 - -const ( - BOND_API_LB_ALGO_L2 BondLbAlgo = 0 - BOND_API_LB_ALGO_L34 BondLbAlgo = 1 - BOND_API_LB_ALGO_L23 BondLbAlgo = 2 - BOND_API_LB_ALGO_RR BondLbAlgo = 3 - BOND_API_LB_ALGO_BC BondLbAlgo = 4 - BOND_API_LB_ALGO_AB BondLbAlgo = 5 -) - -var BondLbAlgo_name = map[uint32]string{ - 0: "BOND_API_LB_ALGO_L2", - 1: "BOND_API_LB_ALGO_L34", - 2: "BOND_API_LB_ALGO_L23", - 3: "BOND_API_LB_ALGO_RR", - 4: "BOND_API_LB_ALGO_BC", - 5: "BOND_API_LB_ALGO_AB", -} - -var BondLbAlgo_value = map[string]uint32{ - "BOND_API_LB_ALGO_L2": 0, - "BOND_API_LB_ALGO_L34": 1, - "BOND_API_LB_ALGO_L23": 2, - "BOND_API_LB_ALGO_RR": 3, - "BOND_API_LB_ALGO_BC": 4, - "BOND_API_LB_ALGO_AB": 5, -} - -func (x BondLbAlgo) String() string { - s, ok := BondLbAlgo_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// BondMode represents VPP binary API enum 'bond_mode'. -type BondMode uint32 - -const ( - BOND_API_MODE_ROUND_ROBIN BondMode = 1 - BOND_API_MODE_ACTIVE_BACKUP BondMode = 2 - BOND_API_MODE_XOR BondMode = 3 - BOND_API_MODE_BROADCAST BondMode = 4 - BOND_API_MODE_LACP BondMode = 5 -) - -var BondMode_name = map[uint32]string{ - 1: "BOND_API_MODE_ROUND_ROBIN", - 2: "BOND_API_MODE_ACTIVE_BACKUP", - 3: "BOND_API_MODE_XOR", - 4: "BOND_API_MODE_BROADCAST", - 5: "BOND_API_MODE_LACP", -} - -var BondMode_value = map[string]uint32{ - "BOND_API_MODE_ROUND_ROBIN": 1, - "BOND_API_MODE_ACTIVE_BACKUP": 2, - "BOND_API_MODE_XOR": 3, - "BOND_API_MODE_BROADCAST": 4, - "BOND_API_MODE_LACP": 5, -} - -func (x BondMode) String() string { - s, ok := BondMode_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type InterfaceIndex = interface_types.InterfaceIndex - -type MacAddress = ethernet_types.MacAddress - -// BondCreate represents VPP binary API message 'bond_create'. -type BondCreate struct { - ID uint32 - UseCustomMac bool - MacAddress MacAddress - Mode BondMode - Lb BondLbAlgo - NumaOnly bool -} - -func (m *BondCreate) Reset() { *m = BondCreate{} } -func (*BondCreate) GetMessageName() string { return "bond_create" } -func (*BondCreate) GetCrcString() string { return "48883c7e" } -func (*BondCreate) GetMessageType() api.MessageType { return api.RequestMessage } - -// BondCreateReply represents VPP binary API message 'bond_create_reply'. -type BondCreateReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *BondCreateReply) Reset() { *m = BondCreateReply{} } -func (*BondCreateReply) GetMessageName() string { return "bond_create_reply" } -func (*BondCreateReply) GetCrcString() string { return "5383d31f" } -func (*BondCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BondDelete represents VPP binary API message 'bond_delete'. -type BondDelete struct { - SwIfIndex InterfaceIndex -} - -func (m *BondDelete) Reset() { *m = BondDelete{} } -func (*BondDelete) GetMessageName() string { return "bond_delete" } -func (*BondDelete) GetCrcString() string { return "f9e6675e" } -func (*BondDelete) GetMessageType() api.MessageType { return api.RequestMessage } - -// BondDeleteReply represents VPP binary API message 'bond_delete_reply'. -type BondDeleteReply struct { - Retval int32 -} - -func (m *BondDeleteReply) Reset() { *m = BondDeleteReply{} } -func (*BondDeleteReply) GetMessageName() string { return "bond_delete_reply" } -func (*BondDeleteReply) GetCrcString() string { return "e8d4e804" } -func (*BondDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BondDetachSlave represents VPP binary API message 'bond_detach_slave'. -type BondDetachSlave struct { - SwIfIndex InterfaceIndex -} - -func (m *BondDetachSlave) Reset() { *m = BondDetachSlave{} } -func (*BondDetachSlave) GetMessageName() string { return "bond_detach_slave" } -func (*BondDetachSlave) GetCrcString() string { return "f9e6675e" } -func (*BondDetachSlave) GetMessageType() api.MessageType { return api.RequestMessage } - -// BondDetachSlaveReply represents VPP binary API message 'bond_detach_slave_reply'. -type BondDetachSlaveReply struct { - Retval int32 -} - -func (m *BondDetachSlaveReply) Reset() { *m = BondDetachSlaveReply{} } -func (*BondDetachSlaveReply) GetMessageName() string { return "bond_detach_slave_reply" } -func (*BondDetachSlaveReply) GetCrcString() string { return "e8d4e804" } -func (*BondDetachSlaveReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BondEnslave represents VPP binary API message 'bond_enslave'. -type BondEnslave struct { - SwIfIndex InterfaceIndex - BondSwIfIndex InterfaceIndex - IsPassive bool - IsLongTimeout bool -} - -func (m *BondEnslave) Reset() { *m = BondEnslave{} } -func (*BondEnslave) GetMessageName() string { return "bond_enslave" } -func (*BondEnslave) GetCrcString() string { return "076ecfa7" } -func (*BondEnslave) GetMessageType() api.MessageType { return api.RequestMessage } - -// BondEnslaveReply represents VPP binary API message 'bond_enslave_reply'. -type BondEnslaveReply struct { - Retval int32 -} - -func (m *BondEnslaveReply) Reset() { *m = BondEnslaveReply{} } -func (*BondEnslaveReply) GetMessageName() string { return "bond_enslave_reply" } -func (*BondEnslaveReply) GetCrcString() string { return "e8d4e804" } -func (*BondEnslaveReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceBondDetails represents VPP binary API message 'sw_interface_bond_details'. -type SwInterfaceBondDetails struct { - SwIfIndex InterfaceIndex - ID uint32 - Mode BondMode - Lb BondLbAlgo - NumaOnly bool - ActiveSlaves uint32 - Slaves uint32 - InterfaceName string `struc:"[64]byte"` -} - -func (m *SwInterfaceBondDetails) Reset() { *m = SwInterfaceBondDetails{} } -func (*SwInterfaceBondDetails) GetMessageName() string { return "sw_interface_bond_details" } -func (*SwInterfaceBondDetails) GetCrcString() string { return "f5ef2106" } -func (*SwInterfaceBondDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceBondDump represents VPP binary API message 'sw_interface_bond_dump'. -type SwInterfaceBondDump struct{} - -func (m *SwInterfaceBondDump) Reset() { *m = SwInterfaceBondDump{} } -func (*SwInterfaceBondDump) GetMessageName() string { return "sw_interface_bond_dump" } -func (*SwInterfaceBondDump) GetCrcString() string { return "51077d14" } -func (*SwInterfaceBondDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetBondWeight represents VPP binary API message 'sw_interface_set_bond_weight'. -type SwInterfaceSetBondWeight struct { - SwIfIndex InterfaceIndex - Weight uint32 -} - -func (m *SwInterfaceSetBondWeight) Reset() { *m = SwInterfaceSetBondWeight{} } -func (*SwInterfaceSetBondWeight) GetMessageName() string { return "sw_interface_set_bond_weight" } -func (*SwInterfaceSetBondWeight) GetCrcString() string { return "deb510a0" } -func (*SwInterfaceSetBondWeight) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetBondWeightReply represents VPP binary API message 'sw_interface_set_bond_weight_reply'. -type SwInterfaceSetBondWeightReply struct { - Retval int32 -} - -func (m *SwInterfaceSetBondWeightReply) Reset() { *m = SwInterfaceSetBondWeightReply{} } -func (*SwInterfaceSetBondWeightReply) GetMessageName() string { - return "sw_interface_set_bond_weight_reply" -} -func (*SwInterfaceSetBondWeightReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetBondWeightReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSlaveDetails represents VPP binary API message 'sw_interface_slave_details'. -type SwInterfaceSlaveDetails struct { - SwIfIndex InterfaceIndex - InterfaceName string `struc:"[64]byte"` - IsPassive bool - IsLongTimeout bool - IsLocalNuma bool - Weight uint32 -} - -func (m *SwInterfaceSlaveDetails) Reset() { *m = SwInterfaceSlaveDetails{} } -func (*SwInterfaceSlaveDetails) GetMessageName() string { return "sw_interface_slave_details" } -func (*SwInterfaceSlaveDetails) GetCrcString() string { return "3c4a0e23" } -func (*SwInterfaceSlaveDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSlaveDump represents VPP binary API message 'sw_interface_slave_dump'. -type SwInterfaceSlaveDump struct { - SwIfIndex InterfaceIndex -} - -func (m *SwInterfaceSlaveDump) Reset() { *m = SwInterfaceSlaveDump{} } -func (*SwInterfaceSlaveDump) GetMessageName() string { return "sw_interface_slave_dump" } -func (*SwInterfaceSlaveDump) GetCrcString() string { return "f9e6675e" } -func (*SwInterfaceSlaveDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*BondCreate)(nil), "bond.BondCreate") - api.RegisterMessage((*BondCreateReply)(nil), "bond.BondCreateReply") - api.RegisterMessage((*BondDelete)(nil), "bond.BondDelete") - api.RegisterMessage((*BondDeleteReply)(nil), "bond.BondDeleteReply") - api.RegisterMessage((*BondDetachSlave)(nil), "bond.BondDetachSlave") - api.RegisterMessage((*BondDetachSlaveReply)(nil), "bond.BondDetachSlaveReply") - api.RegisterMessage((*BondEnslave)(nil), "bond.BondEnslave") - api.RegisterMessage((*BondEnslaveReply)(nil), "bond.BondEnslaveReply") - api.RegisterMessage((*SwInterfaceBondDetails)(nil), "bond.SwInterfaceBondDetails") - api.RegisterMessage((*SwInterfaceBondDump)(nil), "bond.SwInterfaceBondDump") - api.RegisterMessage((*SwInterfaceSetBondWeight)(nil), "bond.SwInterfaceSetBondWeight") - api.RegisterMessage((*SwInterfaceSetBondWeightReply)(nil), "bond.SwInterfaceSetBondWeightReply") - api.RegisterMessage((*SwInterfaceSlaveDetails)(nil), "bond.SwInterfaceSlaveDetails") - api.RegisterMessage((*SwInterfaceSlaveDump)(nil), "bond.SwInterfaceSlaveDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*BondCreate)(nil), - (*BondCreateReply)(nil), - (*BondDelete)(nil), - (*BondDeleteReply)(nil), - (*BondDetachSlave)(nil), - (*BondDetachSlaveReply)(nil), - (*BondEnslave)(nil), - (*BondEnslaveReply)(nil), - (*SwInterfaceBondDetails)(nil), - (*SwInterfaceBondDump)(nil), - (*SwInterfaceSetBondWeight)(nil), - (*SwInterfaceSetBondWeightReply)(nil), - (*SwInterfaceSlaveDetails)(nil), - (*SwInterfaceSlaveDump)(nil), - } -} - -// RPCService represents RPC service API for bond module. -type RPCService interface { - DumpSwInterfaceBond(ctx context.Context, in *SwInterfaceBondDump) (RPCService_DumpSwInterfaceBondClient, error) - DumpSwInterfaceSlave(ctx context.Context, in *SwInterfaceSlaveDump) (RPCService_DumpSwInterfaceSlaveClient, error) - BondCreate(ctx context.Context, in *BondCreate) (*BondCreateReply, error) - BondDelete(ctx context.Context, in *BondDelete) (*BondDeleteReply, error) - BondDetachSlave(ctx context.Context, in *BondDetachSlave) (*BondDetachSlaveReply, error) - BondEnslave(ctx context.Context, in *BondEnslave) (*BondEnslaveReply, error) - SwInterfaceSetBondWeight(ctx context.Context, in *SwInterfaceSetBondWeight) (*SwInterfaceSetBondWeightReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpSwInterfaceBond(ctx context.Context, in *SwInterfaceBondDump) (RPCService_DumpSwInterfaceBondClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceBondClient{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceBondClient interface { - Recv() (*SwInterfaceBondDetails, error) -} - -type serviceClient_DumpSwInterfaceBondClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSwInterfaceBondClient) Recv() (*SwInterfaceBondDetails, error) { - m := new(SwInterfaceBondDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpSwInterfaceSlave(ctx context.Context, in *SwInterfaceSlaveDump) (RPCService_DumpSwInterfaceSlaveClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceSlaveClient{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceSlaveClient interface { - Recv() (*SwInterfaceSlaveDetails, error) -} - -type serviceClient_DumpSwInterfaceSlaveClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSwInterfaceSlaveClient) Recv() (*SwInterfaceSlaveDetails, error) { - m := new(SwInterfaceSlaveDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) BondCreate(ctx context.Context, in *BondCreate) (*BondCreateReply, error) { - out := new(BondCreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BondDelete(ctx context.Context, in *BondDelete) (*BondDeleteReply, error) { - out := new(BondDeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BondDetachSlave(ctx context.Context, in *BondDetachSlave) (*BondDetachSlaveReply, error) { - out := new(BondDetachSlaveReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BondEnslave(ctx context.Context, in *BondEnslave) (*BondEnslaveReply, error) { - out := new(BondEnslaveReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetBondWeight(ctx context.Context, in *SwInterfaceSetBondWeight) (*SwInterfaceSetBondWeightReply, error) { - out := new(SwInterfaceSetBondWeightReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/dhcp/dhcp.ba.go b/plugins/vpp/binapi/vpp2001/dhcp/dhcp.ba.go deleted file mode 100644 index c13f6d38f5..0000000000 --- a/plugins/vpp/binapi/vpp2001/dhcp/dhcp.ba.go +++ /dev/null @@ -1,883 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/dhcp.api.json - -/* -Package dhcp is a generated VPP binary API for 'dhcp' module. - -It consists of: - 13 enums - 7 aliases - 12 types - 1 union - 29 messages - 13 services -*/ -package dhcp - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "dhcp" - // APIVersion is the API version of this module. - APIVersion = "3.0.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0x96a5f046 -) - -type AddressFamily = ip_types.AddressFamily - -// DHCPClientState represents VPP binary API enum 'dhcp_client_state'. -type DHCPClientState uint32 - -const ( - DHCP_CLIENT_STATE_API_DISCOVER DHCPClientState = 1 - DHCP_CLIENT_STATE_API_REQUEST DHCPClientState = 2 - DHCP_CLIENT_STATE_API_BOUND DHCPClientState = 3 -) - -var DHCPClientState_name = map[uint32]string{ - 1: "DHCP_CLIENT_STATE_API_DISCOVER", - 2: "DHCP_CLIENT_STATE_API_REQUEST", - 3: "DHCP_CLIENT_STATE_API_BOUND", -} - -var DHCPClientState_value = map[string]uint32{ - "DHCP_CLIENT_STATE_API_DISCOVER": 1, - "DHCP_CLIENT_STATE_API_REQUEST": 2, - "DHCP_CLIENT_STATE_API_BOUND": 3, -} - -func (x DHCPClientState) String() string { - s, ok := DHCPClientState_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// Dhcpv6MsgType represents VPP binary API enum 'dhcpv6_msg_type'. -type Dhcpv6MsgType uint32 - -const ( - DHCPV6_MSG_API_SOLICIT Dhcpv6MsgType = 1 - DHCPV6_MSG_API_ADVERTISE Dhcpv6MsgType = 2 - DHCPV6_MSG_API_REQUEST Dhcpv6MsgType = 3 - DHCPV6_MSG_API_CONFIRM Dhcpv6MsgType = 4 - DHCPV6_MSG_API_RENEW Dhcpv6MsgType = 5 - DHCPV6_MSG_API_REBIND Dhcpv6MsgType = 6 - DHCPV6_MSG_API_REPLY Dhcpv6MsgType = 7 - DHCPV6_MSG_API_RELEASE Dhcpv6MsgType = 8 - DHCPV6_MSG_API_DECLINE Dhcpv6MsgType = 9 - DHCPV6_MSG_API_RECONFIGURE Dhcpv6MsgType = 10 - DHCPV6_MSG_API_INFORMATION_REQUEST Dhcpv6MsgType = 11 - DHCPV6_MSG_API_RELAY_FORW Dhcpv6MsgType = 12 - DHCPV6_MSG_API_RELAY_REPL Dhcpv6MsgType = 13 -) - -var Dhcpv6MsgType_name = map[uint32]string{ - 1: "DHCPV6_MSG_API_SOLICIT", - 2: "DHCPV6_MSG_API_ADVERTISE", - 3: "DHCPV6_MSG_API_REQUEST", - 4: "DHCPV6_MSG_API_CONFIRM", - 5: "DHCPV6_MSG_API_RENEW", - 6: "DHCPV6_MSG_API_REBIND", - 7: "DHCPV6_MSG_API_REPLY", - 8: "DHCPV6_MSG_API_RELEASE", - 9: "DHCPV6_MSG_API_DECLINE", - 10: "DHCPV6_MSG_API_RECONFIGURE", - 11: "DHCPV6_MSG_API_INFORMATION_REQUEST", - 12: "DHCPV6_MSG_API_RELAY_FORW", - 13: "DHCPV6_MSG_API_RELAY_REPL", -} - -var Dhcpv6MsgType_value = map[string]uint32{ - "DHCPV6_MSG_API_SOLICIT": 1, - "DHCPV6_MSG_API_ADVERTISE": 2, - "DHCPV6_MSG_API_REQUEST": 3, - "DHCPV6_MSG_API_CONFIRM": 4, - "DHCPV6_MSG_API_RENEW": 5, - "DHCPV6_MSG_API_REBIND": 6, - "DHCPV6_MSG_API_REPLY": 7, - "DHCPV6_MSG_API_RELEASE": 8, - "DHCPV6_MSG_API_DECLINE": 9, - "DHCPV6_MSG_API_RECONFIGURE": 10, - "DHCPV6_MSG_API_INFORMATION_REQUEST": 11, - "DHCPV6_MSG_API_RELAY_FORW": 12, - "DHCPV6_MSG_API_RELAY_REPL": 13, -} - -func (x Dhcpv6MsgType) String() string { - s, ok := Dhcpv6MsgType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -// VssType represents VPP binary API enum 'vss_type'. -type VssType uint32 - -const ( - VSS_TYPE_API_ASCII VssType = 0 - VSS_TYPE_API_VPN_ID VssType = 1 - VSS_TYPE_API_INVALID VssType = 123 - VSS_TYPE_API_DEFAULT VssType = 255 -) - -var VssType_name = map[uint32]string{ - 0: "VSS_TYPE_API_ASCII", - 1: "VSS_TYPE_API_VPN_ID", - 123: "VSS_TYPE_API_INVALID", - 255: "VSS_TYPE_API_DEFAULT", -} - -var VssType_value = map[string]uint32{ - "VSS_TYPE_API_ASCII": 0, - "VSS_TYPE_API_VPN_ID": 1, - "VSS_TYPE_API_INVALID": 123, - "VSS_TYPE_API_DEFAULT": 255, -} - -func (x VssType) String() string { - s, ok := VssType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type MacAddress = ethernet_types.MacAddress - -type Address = ip_types.Address - -// DHCP6AddressInfo represents VPP binary API type 'dhcp6_address_info'. -type DHCP6AddressInfo struct { - Address IP6Address - ValidTime uint32 - PreferredTime uint32 -} - -func (*DHCP6AddressInfo) GetTypeName() string { return "dhcp6_address_info" } - -// DHCP6PdPrefixInfo represents VPP binary API type 'dhcp6_pd_prefix_info'. -type DHCP6PdPrefixInfo struct { - Prefix IP6Prefix - ValidTime uint32 - PreferredTime uint32 -} - -func (*DHCP6PdPrefixInfo) GetTypeName() string { return "dhcp6_pd_prefix_info" } - -// DHCPClient represents VPP binary API type 'dhcp_client'. -type DHCPClient struct { - SwIfIndex InterfaceIndex - Hostname string `struc:"[64]byte"` - ID []byte `struc:"[64]byte"` - WantDHCPEvent bool - SetBroadcastFlag bool - Dscp IPDscp - PID uint32 -} - -func (*DHCPClient) GetTypeName() string { return "dhcp_client" } - -// DHCPLease represents VPP binary API type 'dhcp_lease'. -type DHCPLease struct { - SwIfIndex InterfaceIndex - State DHCPClientState - IsIPv6 bool - Hostname string `struc:"[64]byte"` - MaskWidth uint8 - HostAddress Address - RouterAddress Address - HostMac MacAddress - Count uint8 `struc:"sizeof=DomainServer"` - DomainServer []DomainServer -} - -func (*DHCPLease) GetTypeName() string { return "dhcp_lease" } - -// DHCPServer represents VPP binary API type 'dhcp_server'. -type DHCPServer struct { - ServerVrfID uint32 - DHCPServer Address -} - -func (*DHCPServer) GetTypeName() string { return "dhcp_server" } - -// DomainServer represents VPP binary API type 'domain_server'. -type DomainServer struct { - Address Address -} - -func (*DomainServer) GetTypeName() string { return "domain_server" } - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// DHCP6ClientsEnableDisable represents VPP binary API message 'dhcp6_clients_enable_disable'. -type DHCP6ClientsEnableDisable struct { - Enable bool -} - -func (m *DHCP6ClientsEnableDisable) Reset() { *m = DHCP6ClientsEnableDisable{} } -func (*DHCP6ClientsEnableDisable) GetMessageName() string { return "dhcp6_clients_enable_disable" } -func (*DHCP6ClientsEnableDisable) GetCrcString() string { return "b3e225d2" } -func (*DHCP6ClientsEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCP6ClientsEnableDisableReply represents VPP binary API message 'dhcp6_clients_enable_disable_reply'. -type DHCP6ClientsEnableDisableReply struct { - Retval int32 -} - -func (m *DHCP6ClientsEnableDisableReply) Reset() { *m = DHCP6ClientsEnableDisableReply{} } -func (*DHCP6ClientsEnableDisableReply) GetMessageName() string { - return "dhcp6_clients_enable_disable_reply" -} -func (*DHCP6ClientsEnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*DHCP6ClientsEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCP6DuidLlSet represents VPP binary API message 'dhcp6_duid_ll_set'. -type DHCP6DuidLlSet struct { - DuidLl []byte `struc:"[10]byte"` -} - -func (m *DHCP6DuidLlSet) Reset() { *m = DHCP6DuidLlSet{} } -func (*DHCP6DuidLlSet) GetMessageName() string { return "dhcp6_duid_ll_set" } -func (*DHCP6DuidLlSet) GetCrcString() string { return "0f6ca323" } -func (*DHCP6DuidLlSet) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCP6DuidLlSetReply represents VPP binary API message 'dhcp6_duid_ll_set_reply'. -type DHCP6DuidLlSetReply struct { - Retval int32 -} - -func (m *DHCP6DuidLlSetReply) Reset() { *m = DHCP6DuidLlSetReply{} } -func (*DHCP6DuidLlSetReply) GetMessageName() string { return "dhcp6_duid_ll_set_reply" } -func (*DHCP6DuidLlSetReply) GetCrcString() string { return "e8d4e804" } -func (*DHCP6DuidLlSetReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCP6PdReplyEvent represents VPP binary API message 'dhcp6_pd_reply_event'. -type DHCP6PdReplyEvent struct { - PID uint32 - SwIfIndex InterfaceIndex - ServerIndex uint32 - MsgType Dhcpv6MsgType - T1 uint32 - T2 uint32 - InnerStatusCode uint16 - StatusCode uint16 - Preference uint8 - NPrefixes uint32 `struc:"sizeof=Prefixes"` - Prefixes []DHCP6PdPrefixInfo -} - -func (m *DHCP6PdReplyEvent) Reset() { *m = DHCP6PdReplyEvent{} } -func (*DHCP6PdReplyEvent) GetMessageName() string { return "dhcp6_pd_reply_event" } -func (*DHCP6PdReplyEvent) GetCrcString() string { return "cb3e462b" } -func (*DHCP6PdReplyEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// DHCP6PdSendClientMessage represents VPP binary API message 'dhcp6_pd_send_client_message'. -type DHCP6PdSendClientMessage struct { - SwIfIndex InterfaceIndex - ServerIndex uint32 - Irt uint32 - Mrt uint32 - Mrc uint32 - Mrd uint32 - Stop bool - MsgType Dhcpv6MsgType - T1 uint32 - T2 uint32 - NPrefixes uint32 `struc:"sizeof=Prefixes"` - Prefixes []DHCP6PdPrefixInfo -} - -func (m *DHCP6PdSendClientMessage) Reset() { *m = DHCP6PdSendClientMessage{} } -func (*DHCP6PdSendClientMessage) GetMessageName() string { return "dhcp6_pd_send_client_message" } -func (*DHCP6PdSendClientMessage) GetCrcString() string { return "064badb8" } -func (*DHCP6PdSendClientMessage) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCP6PdSendClientMessageReply represents VPP binary API message 'dhcp6_pd_send_client_message_reply'. -type DHCP6PdSendClientMessageReply struct { - Retval int32 -} - -func (m *DHCP6PdSendClientMessageReply) Reset() { *m = DHCP6PdSendClientMessageReply{} } -func (*DHCP6PdSendClientMessageReply) GetMessageName() string { - return "dhcp6_pd_send_client_message_reply" -} -func (*DHCP6PdSendClientMessageReply) GetCrcString() string { return "e8d4e804" } -func (*DHCP6PdSendClientMessageReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCP6ReplyEvent represents VPP binary API message 'dhcp6_reply_event'. -type DHCP6ReplyEvent struct { - PID uint32 - SwIfIndex InterfaceIndex - ServerIndex uint32 - MsgType Dhcpv6MsgType - T1 uint32 - T2 uint32 - InnerStatusCode uint16 - StatusCode uint16 - Preference uint8 - NAddresses uint32 `struc:"sizeof=Addresses"` - Addresses []DHCP6AddressInfo -} - -func (m *DHCP6ReplyEvent) Reset() { *m = DHCP6ReplyEvent{} } -func (*DHCP6ReplyEvent) GetMessageName() string { return "dhcp6_reply_event" } -func (*DHCP6ReplyEvent) GetCrcString() string { return "9f3af9e5" } -func (*DHCP6ReplyEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// DHCP6SendClientMessage represents VPP binary API message 'dhcp6_send_client_message'. -type DHCP6SendClientMessage struct { - SwIfIndex InterfaceIndex - ServerIndex uint32 - Irt uint32 - Mrt uint32 - Mrc uint32 - Mrd uint32 - Stop bool - MsgType Dhcpv6MsgType - T1 uint32 - T2 uint32 - NAddresses uint32 `struc:"sizeof=Addresses"` - Addresses []DHCP6AddressInfo -} - -func (m *DHCP6SendClientMessage) Reset() { *m = DHCP6SendClientMessage{} } -func (*DHCP6SendClientMessage) GetMessageName() string { return "dhcp6_send_client_message" } -func (*DHCP6SendClientMessage) GetCrcString() string { return "f6f14ef0" } -func (*DHCP6SendClientMessage) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCP6SendClientMessageReply represents VPP binary API message 'dhcp6_send_client_message_reply'. -type DHCP6SendClientMessageReply struct { - Retval int32 -} - -func (m *DHCP6SendClientMessageReply) Reset() { *m = DHCP6SendClientMessageReply{} } -func (*DHCP6SendClientMessageReply) GetMessageName() string { return "dhcp6_send_client_message_reply" } -func (*DHCP6SendClientMessageReply) GetCrcString() string { return "e8d4e804" } -func (*DHCP6SendClientMessageReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCPClientConfig represents VPP binary API message 'dhcp_client_config'. -type DHCPClientConfig struct { - IsAdd bool - Client DHCPClient -} - -func (m *DHCPClientConfig) Reset() { *m = DHCPClientConfig{} } -func (*DHCPClientConfig) GetMessageName() string { return "dhcp_client_config" } -func (*DHCPClientConfig) GetCrcString() string { return "959b80a3" } -func (*DHCPClientConfig) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCPClientConfigReply represents VPP binary API message 'dhcp_client_config_reply'. -type DHCPClientConfigReply struct { - Retval int32 -} - -func (m *DHCPClientConfigReply) Reset() { *m = DHCPClientConfigReply{} } -func (*DHCPClientConfigReply) GetMessageName() string { return "dhcp_client_config_reply" } -func (*DHCPClientConfigReply) GetCrcString() string { return "e8d4e804" } -func (*DHCPClientConfigReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCPClientDetails represents VPP binary API message 'dhcp_client_details'. -type DHCPClientDetails struct { - Client DHCPClient - Lease DHCPLease -} - -func (m *DHCPClientDetails) Reset() { *m = DHCPClientDetails{} } -func (*DHCPClientDetails) GetMessageName() string { return "dhcp_client_details" } -func (*DHCPClientDetails) GetCrcString() string { return "acd82f5a" } -func (*DHCPClientDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCPClientDump represents VPP binary API message 'dhcp_client_dump'. -type DHCPClientDump struct{} - -func (m *DHCPClientDump) Reset() { *m = DHCPClientDump{} } -func (*DHCPClientDump) GetMessageName() string { return "dhcp_client_dump" } -func (*DHCPClientDump) GetCrcString() string { return "51077d14" } -func (*DHCPClientDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCPComplEvent represents VPP binary API message 'dhcp_compl_event'. -type DHCPComplEvent struct { - PID uint32 - Lease DHCPLease -} - -func (m *DHCPComplEvent) Reset() { *m = DHCPComplEvent{} } -func (*DHCPComplEvent) GetMessageName() string { return "dhcp_compl_event" } -func (*DHCPComplEvent) GetCrcString() string { return "e908fd1d" } -func (*DHCPComplEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// DHCPPluginControlPing represents VPP binary API message 'dhcp_plugin_control_ping'. -type DHCPPluginControlPing struct{} - -func (m *DHCPPluginControlPing) Reset() { *m = DHCPPluginControlPing{} } -func (*DHCPPluginControlPing) GetMessageName() string { return "dhcp_plugin_control_ping" } -func (*DHCPPluginControlPing) GetCrcString() string { return "51077d14" } -func (*DHCPPluginControlPing) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCPPluginControlPingReply represents VPP binary API message 'dhcp_plugin_control_ping_reply'. -type DHCPPluginControlPingReply struct { - Retval int32 - ClientIndex uint32 - VpePID uint32 -} - -func (m *DHCPPluginControlPingReply) Reset() { *m = DHCPPluginControlPingReply{} } -func (*DHCPPluginControlPingReply) GetMessageName() string { return "dhcp_plugin_control_ping_reply" } -func (*DHCPPluginControlPingReply) GetCrcString() string { return "f6b0b8ca" } -func (*DHCPPluginControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCPPluginGetVersion represents VPP binary API message 'dhcp_plugin_get_version'. -type DHCPPluginGetVersion struct{} - -func (m *DHCPPluginGetVersion) Reset() { *m = DHCPPluginGetVersion{} } -func (*DHCPPluginGetVersion) GetMessageName() string { return "dhcp_plugin_get_version" } -func (*DHCPPluginGetVersion) GetCrcString() string { return "51077d14" } -func (*DHCPPluginGetVersion) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCPPluginGetVersionReply represents VPP binary API message 'dhcp_plugin_get_version_reply'. -type DHCPPluginGetVersionReply struct { - Major uint32 - Minor uint32 -} - -func (m *DHCPPluginGetVersionReply) Reset() { *m = DHCPPluginGetVersionReply{} } -func (*DHCPPluginGetVersionReply) GetMessageName() string { return "dhcp_plugin_get_version_reply" } -func (*DHCPPluginGetVersionReply) GetCrcString() string { return "9b32cf86" } -func (*DHCPPluginGetVersionReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCPProxyConfig represents VPP binary API message 'dhcp_proxy_config'. -type DHCPProxyConfig struct { - RxVrfID uint32 - ServerVrfID uint32 - IsAdd bool - DHCPServer Address - DHCPSrcAddress Address -} - -func (m *DHCPProxyConfig) Reset() { *m = DHCPProxyConfig{} } -func (*DHCPProxyConfig) GetMessageName() string { return "dhcp_proxy_config" } -func (*DHCPProxyConfig) GetCrcString() string { return "6767230e" } -func (*DHCPProxyConfig) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCPProxyConfigReply represents VPP binary API message 'dhcp_proxy_config_reply'. -type DHCPProxyConfigReply struct { - Retval int32 -} - -func (m *DHCPProxyConfigReply) Reset() { *m = DHCPProxyConfigReply{} } -func (*DHCPProxyConfigReply) GetMessageName() string { return "dhcp_proxy_config_reply" } -func (*DHCPProxyConfigReply) GetCrcString() string { return "e8d4e804" } -func (*DHCPProxyConfigReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCPProxyDetails represents VPP binary API message 'dhcp_proxy_details'. -type DHCPProxyDetails struct { - RxVrfID uint32 - VssOui uint32 - VssFibID uint32 - VssType VssType - IsIPv6 bool - VssVPNAsciiID string `struc:"[129]byte"` - DHCPSrcAddress Address - Count uint8 `struc:"sizeof=Servers"` - Servers []DHCPServer -} - -func (m *DHCPProxyDetails) Reset() { *m = DHCPProxyDetails{} } -func (*DHCPProxyDetails) GetMessageName() string { return "dhcp_proxy_details" } -func (*DHCPProxyDetails) GetCrcString() string { return "ce16f044" } -func (*DHCPProxyDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DHCPProxyDump represents VPP binary API message 'dhcp_proxy_dump'. -type DHCPProxyDump struct { - IsIP6 bool -} - -func (m *DHCPProxyDump) Reset() { *m = DHCPProxyDump{} } -func (*DHCPProxyDump) GetMessageName() string { return "dhcp_proxy_dump" } -func (*DHCPProxyDump) GetCrcString() string { return "5c5b063f" } -func (*DHCPProxyDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCPProxySetVss represents VPP binary API message 'dhcp_proxy_set_vss'. -type DHCPProxySetVss struct { - TblID uint32 - VssType VssType - VPNAsciiID string `struc:"[129]byte"` - Oui uint32 - VPNIndex uint32 - IsIPv6 bool - IsAdd bool -} - -func (m *DHCPProxySetVss) Reset() { *m = DHCPProxySetVss{} } -func (*DHCPProxySetVss) GetMessageName() string { return "dhcp_proxy_set_vss" } -func (*DHCPProxySetVss) GetCrcString() string { return "50537301" } -func (*DHCPProxySetVss) GetMessageType() api.MessageType { return api.RequestMessage } - -// DHCPProxySetVssReply represents VPP binary API message 'dhcp_proxy_set_vss_reply'. -type DHCPProxySetVssReply struct { - Retval int32 -} - -func (m *DHCPProxySetVssReply) Reset() { *m = DHCPProxySetVssReply{} } -func (*DHCPProxySetVssReply) GetMessageName() string { return "dhcp_proxy_set_vss_reply" } -func (*DHCPProxySetVssReply) GetCrcString() string { return "e8d4e804" } -func (*DHCPProxySetVssReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// WantDHCP6PdReplyEvents represents VPP binary API message 'want_dhcp6_pd_reply_events'. -type WantDHCP6PdReplyEvents struct { - EnableDisable bool - PID uint32 -} - -func (m *WantDHCP6PdReplyEvents) Reset() { *m = WantDHCP6PdReplyEvents{} } -func (*WantDHCP6PdReplyEvents) GetMessageName() string { return "want_dhcp6_pd_reply_events" } -func (*WantDHCP6PdReplyEvents) GetCrcString() string { return "c5e2af94" } -func (*WantDHCP6PdReplyEvents) GetMessageType() api.MessageType { return api.RequestMessage } - -// WantDHCP6PdReplyEventsReply represents VPP binary API message 'want_dhcp6_pd_reply_events_reply'. -type WantDHCP6PdReplyEventsReply struct { - Retval int32 -} - -func (m *WantDHCP6PdReplyEventsReply) Reset() { *m = WantDHCP6PdReplyEventsReply{} } -func (*WantDHCP6PdReplyEventsReply) GetMessageName() string { - return "want_dhcp6_pd_reply_events_reply" -} -func (*WantDHCP6PdReplyEventsReply) GetCrcString() string { return "e8d4e804" } -func (*WantDHCP6PdReplyEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// WantDHCP6ReplyEvents represents VPP binary API message 'want_dhcp6_reply_events'. -type WantDHCP6ReplyEvents struct { - EnableDisable uint8 - PID uint32 -} - -func (m *WantDHCP6ReplyEvents) Reset() { *m = WantDHCP6ReplyEvents{} } -func (*WantDHCP6ReplyEvents) GetMessageName() string { return "want_dhcp6_reply_events" } -func (*WantDHCP6ReplyEvents) GetCrcString() string { return "05b454b5" } -func (*WantDHCP6ReplyEvents) GetMessageType() api.MessageType { return api.RequestMessage } - -// WantDHCP6ReplyEventsReply represents VPP binary API message 'want_dhcp6_reply_events_reply'. -type WantDHCP6ReplyEventsReply struct { - Retval int32 -} - -func (m *WantDHCP6ReplyEventsReply) Reset() { *m = WantDHCP6ReplyEventsReply{} } -func (*WantDHCP6ReplyEventsReply) GetMessageName() string { return "want_dhcp6_reply_events_reply" } -func (*WantDHCP6ReplyEventsReply) GetCrcString() string { return "e8d4e804" } -func (*WantDHCP6ReplyEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*DHCP6ClientsEnableDisable)(nil), "dhcp.DHCP6ClientsEnableDisable") - api.RegisterMessage((*DHCP6ClientsEnableDisableReply)(nil), "dhcp.DHCP6ClientsEnableDisableReply") - api.RegisterMessage((*DHCP6DuidLlSet)(nil), "dhcp.DHCP6DuidLlSet") - api.RegisterMessage((*DHCP6DuidLlSetReply)(nil), "dhcp.DHCP6DuidLlSetReply") - api.RegisterMessage((*DHCP6PdReplyEvent)(nil), "dhcp.DHCP6PdReplyEvent") - api.RegisterMessage((*DHCP6PdSendClientMessage)(nil), "dhcp.DHCP6PdSendClientMessage") - api.RegisterMessage((*DHCP6PdSendClientMessageReply)(nil), "dhcp.DHCP6PdSendClientMessageReply") - api.RegisterMessage((*DHCP6ReplyEvent)(nil), "dhcp.DHCP6ReplyEvent") - api.RegisterMessage((*DHCP6SendClientMessage)(nil), "dhcp.DHCP6SendClientMessage") - api.RegisterMessage((*DHCP6SendClientMessageReply)(nil), "dhcp.DHCP6SendClientMessageReply") - api.RegisterMessage((*DHCPClientConfig)(nil), "dhcp.DHCPClientConfig") - api.RegisterMessage((*DHCPClientConfigReply)(nil), "dhcp.DHCPClientConfigReply") - api.RegisterMessage((*DHCPClientDetails)(nil), "dhcp.DHCPClientDetails") - api.RegisterMessage((*DHCPClientDump)(nil), "dhcp.DHCPClientDump") - api.RegisterMessage((*DHCPComplEvent)(nil), "dhcp.DHCPComplEvent") - api.RegisterMessage((*DHCPPluginControlPing)(nil), "dhcp.DHCPPluginControlPing") - api.RegisterMessage((*DHCPPluginControlPingReply)(nil), "dhcp.DHCPPluginControlPingReply") - api.RegisterMessage((*DHCPPluginGetVersion)(nil), "dhcp.DHCPPluginGetVersion") - api.RegisterMessage((*DHCPPluginGetVersionReply)(nil), "dhcp.DHCPPluginGetVersionReply") - api.RegisterMessage((*DHCPProxyConfig)(nil), "dhcp.DHCPProxyConfig") - api.RegisterMessage((*DHCPProxyConfigReply)(nil), "dhcp.DHCPProxyConfigReply") - api.RegisterMessage((*DHCPProxyDetails)(nil), "dhcp.DHCPProxyDetails") - api.RegisterMessage((*DHCPProxyDump)(nil), "dhcp.DHCPProxyDump") - api.RegisterMessage((*DHCPProxySetVss)(nil), "dhcp.DHCPProxySetVss") - api.RegisterMessage((*DHCPProxySetVssReply)(nil), "dhcp.DHCPProxySetVssReply") - api.RegisterMessage((*WantDHCP6PdReplyEvents)(nil), "dhcp.WantDHCP6PdReplyEvents") - api.RegisterMessage((*WantDHCP6PdReplyEventsReply)(nil), "dhcp.WantDHCP6PdReplyEventsReply") - api.RegisterMessage((*WantDHCP6ReplyEvents)(nil), "dhcp.WantDHCP6ReplyEvents") - api.RegisterMessage((*WantDHCP6ReplyEventsReply)(nil), "dhcp.WantDHCP6ReplyEventsReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*DHCP6ClientsEnableDisable)(nil), - (*DHCP6ClientsEnableDisableReply)(nil), - (*DHCP6DuidLlSet)(nil), - (*DHCP6DuidLlSetReply)(nil), - (*DHCP6PdReplyEvent)(nil), - (*DHCP6PdSendClientMessage)(nil), - (*DHCP6PdSendClientMessageReply)(nil), - (*DHCP6ReplyEvent)(nil), - (*DHCP6SendClientMessage)(nil), - (*DHCP6SendClientMessageReply)(nil), - (*DHCPClientConfig)(nil), - (*DHCPClientConfigReply)(nil), - (*DHCPClientDetails)(nil), - (*DHCPClientDump)(nil), - (*DHCPComplEvent)(nil), - (*DHCPPluginControlPing)(nil), - (*DHCPPluginControlPingReply)(nil), - (*DHCPPluginGetVersion)(nil), - (*DHCPPluginGetVersionReply)(nil), - (*DHCPProxyConfig)(nil), - (*DHCPProxyConfigReply)(nil), - (*DHCPProxyDetails)(nil), - (*DHCPProxyDump)(nil), - (*DHCPProxySetVss)(nil), - (*DHCPProxySetVssReply)(nil), - (*WantDHCP6PdReplyEvents)(nil), - (*WantDHCP6PdReplyEventsReply)(nil), - (*WantDHCP6ReplyEvents)(nil), - (*WantDHCP6ReplyEventsReply)(nil), - } -} - -// RPCService represents RPC service API for dhcp module. -type RPCService interface { - DumpDHCPClient(ctx context.Context, in *DHCPClientDump) (RPCService_DumpDHCPClientClient, error) - DumpDHCPProxy(ctx context.Context, in *DHCPProxyDump) (RPCService_DumpDHCPProxyClient, error) - DHCP6ClientsEnableDisable(ctx context.Context, in *DHCP6ClientsEnableDisable) (*DHCP6ClientsEnableDisableReply, error) - DHCP6DuidLlSet(ctx context.Context, in *DHCP6DuidLlSet) (*DHCP6DuidLlSetReply, error) - DHCP6PdSendClientMessage(ctx context.Context, in *DHCP6PdSendClientMessage) (*DHCP6PdSendClientMessageReply, error) - DHCP6SendClientMessage(ctx context.Context, in *DHCP6SendClientMessage) (*DHCP6SendClientMessageReply, error) - DHCPClientConfig(ctx context.Context, in *DHCPClientConfig) (*DHCPClientConfigReply, error) - DHCPPluginControlPing(ctx context.Context, in *DHCPPluginControlPing) (*DHCPPluginControlPingReply, error) - DHCPPluginGetVersion(ctx context.Context, in *DHCPPluginGetVersion) (*DHCPPluginGetVersionReply, error) - DHCPProxyConfig(ctx context.Context, in *DHCPProxyConfig) (*DHCPProxyConfigReply, error) - DHCPProxySetVss(ctx context.Context, in *DHCPProxySetVss) (*DHCPProxySetVssReply, error) - WantDHCP6PdReplyEvents(ctx context.Context, in *WantDHCP6PdReplyEvents) (*WantDHCP6PdReplyEventsReply, error) - WantDHCP6ReplyEvents(ctx context.Context, in *WantDHCP6ReplyEvents) (*WantDHCP6ReplyEventsReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpDHCPClient(ctx context.Context, in *DHCPClientDump) (RPCService_DumpDHCPClientClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpDHCPClientClient{stream} - return x, nil -} - -type RPCService_DumpDHCPClientClient interface { - Recv() (*DHCPClientDetails, error) -} - -type serviceClient_DumpDHCPClientClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpDHCPClientClient) Recv() (*DHCPClientDetails, error) { - m := new(DHCPClientDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpDHCPProxy(ctx context.Context, in *DHCPProxyDump) (RPCService_DumpDHCPProxyClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpDHCPProxyClient{stream} - return x, nil -} - -type RPCService_DumpDHCPProxyClient interface { - Recv() (*DHCPProxyDetails, error) -} - -type serviceClient_DumpDHCPProxyClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpDHCPProxyClient) Recv() (*DHCPProxyDetails, error) { - m := new(DHCPProxyDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DHCP6ClientsEnableDisable(ctx context.Context, in *DHCP6ClientsEnableDisable) (*DHCP6ClientsEnableDisableReply, error) { - out := new(DHCP6ClientsEnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCP6DuidLlSet(ctx context.Context, in *DHCP6DuidLlSet) (*DHCP6DuidLlSetReply, error) { - out := new(DHCP6DuidLlSetReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCP6PdSendClientMessage(ctx context.Context, in *DHCP6PdSendClientMessage) (*DHCP6PdSendClientMessageReply, error) { - out := new(DHCP6PdSendClientMessageReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCP6SendClientMessage(ctx context.Context, in *DHCP6SendClientMessage) (*DHCP6SendClientMessageReply, error) { - out := new(DHCP6SendClientMessageReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCPClientConfig(ctx context.Context, in *DHCPClientConfig) (*DHCPClientConfigReply, error) { - out := new(DHCPClientConfigReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCPPluginControlPing(ctx context.Context, in *DHCPPluginControlPing) (*DHCPPluginControlPingReply, error) { - out := new(DHCPPluginControlPingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCPPluginGetVersion(ctx context.Context, in *DHCPPluginGetVersion) (*DHCPPluginGetVersionReply, error) { - out := new(DHCPPluginGetVersionReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCPProxyConfig(ctx context.Context, in *DHCPProxyConfig) (*DHCPProxyConfigReply, error) { - out := new(DHCPProxyConfigReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DHCPProxySetVss(ctx context.Context, in *DHCPProxySetVss) (*DHCPProxySetVssReply, error) { - out := new(DHCPProxySetVssReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) WantDHCP6PdReplyEvents(ctx context.Context, in *WantDHCP6PdReplyEvents) (*WantDHCP6PdReplyEventsReply, error) { - out := new(WantDHCP6PdReplyEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) WantDHCP6ReplyEvents(ctx context.Context, in *WantDHCP6ReplyEvents) (*WantDHCP6ReplyEventsReply, error) { - out := new(WantDHCP6ReplyEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/dns/dns.ba.go b/plugins/vpp/binapi/vpp2001/dns/dns.ba.go deleted file mode 100644 index 310b55d14a..0000000000 --- a/plugins/vpp/binapi/vpp2001/dns/dns.ba.go +++ /dev/null @@ -1,209 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/dns.api.json - -/* -Package dns is a generated VPP binary API for 'dns' module. - -It consists of: - 8 messages - 4 services -*/ -package dns - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "dns" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x269575cd -) - -// DNSEnableDisable represents VPP binary API message 'dns_enable_disable'. -type DNSEnableDisable struct { - Enable uint8 -} - -func (m *DNSEnableDisable) Reset() { *m = DNSEnableDisable{} } -func (*DNSEnableDisable) GetMessageName() string { return "dns_enable_disable" } -func (*DNSEnableDisable) GetCrcString() string { return "8050327d" } -func (*DNSEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// DNSEnableDisableReply represents VPP binary API message 'dns_enable_disable_reply'. -type DNSEnableDisableReply struct { - Retval int32 -} - -func (m *DNSEnableDisableReply) Reset() { *m = DNSEnableDisableReply{} } -func (*DNSEnableDisableReply) GetMessageName() string { return "dns_enable_disable_reply" } -func (*DNSEnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*DNSEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DNSNameServerAddDel represents VPP binary API message 'dns_name_server_add_del'. -type DNSNameServerAddDel struct { - IsIP6 uint8 - IsAdd uint8 - ServerAddress []byte `struc:"[16]byte"` -} - -func (m *DNSNameServerAddDel) Reset() { *m = DNSNameServerAddDel{} } -func (*DNSNameServerAddDel) GetMessageName() string { return "dns_name_server_add_del" } -func (*DNSNameServerAddDel) GetCrcString() string { return "3bb05d8c" } -func (*DNSNameServerAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// DNSNameServerAddDelReply represents VPP binary API message 'dns_name_server_add_del_reply'. -type DNSNameServerAddDelReply struct { - Retval int32 -} - -func (m *DNSNameServerAddDelReply) Reset() { *m = DNSNameServerAddDelReply{} } -func (*DNSNameServerAddDelReply) GetMessageName() string { return "dns_name_server_add_del_reply" } -func (*DNSNameServerAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*DNSNameServerAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DNSResolveIP represents VPP binary API message 'dns_resolve_ip'. -type DNSResolveIP struct { - IsIP6 uint8 - Address []byte `struc:"[16]byte"` -} - -func (m *DNSResolveIP) Reset() { *m = DNSResolveIP{} } -func (*DNSResolveIP) GetMessageName() string { return "dns_resolve_ip" } -func (*DNSResolveIP) GetCrcString() string { return "ae96a1a3" } -func (*DNSResolveIP) GetMessageType() api.MessageType { return api.RequestMessage } - -// DNSResolveIPReply represents VPP binary API message 'dns_resolve_ip_reply'. -type DNSResolveIPReply struct { - Retval int32 - Name []byte `struc:"[256]byte"` -} - -func (m *DNSResolveIPReply) Reset() { *m = DNSResolveIPReply{} } -func (*DNSResolveIPReply) GetMessageName() string { return "dns_resolve_ip_reply" } -func (*DNSResolveIPReply) GetCrcString() string { return "49ed78d6" } -func (*DNSResolveIPReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DNSResolveName represents VPP binary API message 'dns_resolve_name'. -type DNSResolveName struct { - Name []byte `struc:"[256]byte"` -} - -func (m *DNSResolveName) Reset() { *m = DNSResolveName{} } -func (*DNSResolveName) GetMessageName() string { return "dns_resolve_name" } -func (*DNSResolveName) GetCrcString() string { return "c6566676" } -func (*DNSResolveName) GetMessageType() api.MessageType { return api.RequestMessage } - -// DNSResolveNameReply represents VPP binary API message 'dns_resolve_name_reply'. -type DNSResolveNameReply struct { - Retval int32 - IP4Set uint8 - IP6Set uint8 - IP4Address []byte `struc:"[4]byte"` - IP6Address []byte `struc:"[16]byte"` -} - -func (m *DNSResolveNameReply) Reset() { *m = DNSResolveNameReply{} } -func (*DNSResolveNameReply) GetMessageName() string { return "dns_resolve_name_reply" } -func (*DNSResolveNameReply) GetCrcString() string { return "c2d758c3" } -func (*DNSResolveNameReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*DNSEnableDisable)(nil), "dns.DNSEnableDisable") - api.RegisterMessage((*DNSEnableDisableReply)(nil), "dns.DNSEnableDisableReply") - api.RegisterMessage((*DNSNameServerAddDel)(nil), "dns.DNSNameServerAddDel") - api.RegisterMessage((*DNSNameServerAddDelReply)(nil), "dns.DNSNameServerAddDelReply") - api.RegisterMessage((*DNSResolveIP)(nil), "dns.DNSResolveIP") - api.RegisterMessage((*DNSResolveIPReply)(nil), "dns.DNSResolveIPReply") - api.RegisterMessage((*DNSResolveName)(nil), "dns.DNSResolveName") - api.RegisterMessage((*DNSResolveNameReply)(nil), "dns.DNSResolveNameReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*DNSEnableDisable)(nil), - (*DNSEnableDisableReply)(nil), - (*DNSNameServerAddDel)(nil), - (*DNSNameServerAddDelReply)(nil), - (*DNSResolveIP)(nil), - (*DNSResolveIPReply)(nil), - (*DNSResolveName)(nil), - (*DNSResolveNameReply)(nil), - } -} - -// RPCService represents RPC service API for dns module. -type RPCService interface { - DNSEnableDisable(ctx context.Context, in *DNSEnableDisable) (*DNSEnableDisableReply, error) - DNSNameServerAddDel(ctx context.Context, in *DNSNameServerAddDel) (*DNSNameServerAddDelReply, error) - DNSResolveIP(ctx context.Context, in *DNSResolveIP) (*DNSResolveIPReply, error) - DNSResolveName(ctx context.Context, in *DNSResolveName) (*DNSResolveNameReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DNSEnableDisable(ctx context.Context, in *DNSEnableDisable) (*DNSEnableDisableReply, error) { - out := new(DNSEnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DNSNameServerAddDel(ctx context.Context, in *DNSNameServerAddDel) (*DNSNameServerAddDelReply, error) { - out := new(DNSNameServerAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DNSResolveIP(ctx context.Context, in *DNSResolveIP) (*DNSResolveIPReply, error) { - out := new(DNSResolveIPReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DNSResolveName(ctx context.Context, in *DNSResolveName) (*DNSResolveNameReply, error) { - out := new(DNSResolveNameReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ethernet_types/ethernet_types.ba.go b/plugins/vpp/binapi/vpp2001/ethernet_types/ethernet_types.ba.go deleted file mode 100644 index fffa6b16f5..0000000000 --- a/plugins/vpp/binapi/vpp2001/ethernet_types/ethernet_types.ba.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ethernet_types.api.json - -/* -Package ethernet_types is a generated VPP binary API for 'ethernet_types' module. - -It consists of: - 1 alias -*/ -package ethernet_types - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ethernet_types" - // VersionCrc is the CRC of this module. - VersionCrc = 0xd4ff2808 -) - -// MacAddress represents VPP binary API alias 'mac_address'. -type MacAddress [6]uint8 - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/fib_types.patch b/plugins/vpp/binapi/vpp2001/fib_types.patch deleted file mode 100644 index 1a10a35227..0000000000 --- a/plugins/vpp/binapi/vpp2001/fib_types.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/plugins/vpp/binapi/vpp2001/fib_types/fib_types.ba.go b/plugins/vpp/binapi/vpp2001/fib_types/fib_types.ba.go -index 3bdb5510a..191e53c00 100644 ---- a/plugins/vpp/binapi/vpp2001/fib_types/fib_types.ba.go -+++ b/plugins/vpp/binapi/vpp2001/fib_types/fib_types.ba.go -@@ -458,8 +458,8 @@ type FibPath struct { - Flags FibPathFlags - Proto FibPathNhProto - Nh FibPathNh -- NLabels uint8 -- LabelStack []FibMplsLabel `struc:"[16]FibMplsLabel"` -+ NLabels uint8 `struc:"sizeof=LabelStack"` // MANUALLY FIXED, see https://jira.fd.io/browse/VPP-1261 -+ LabelStack []FibMplsLabel - } - - func (*FibPath) GetTypeName() string { diff --git a/plugins/vpp/binapi/vpp2001/fib_types/fib_types.ba.go b/plugins/vpp/binapi/vpp2001/fib_types/fib_types.ba.go deleted file mode 100644 index d3212ff000..0000000000 --- a/plugins/vpp/binapi/vpp2001/fib_types/fib_types.ba.go +++ /dev/null @@ -1,237 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/fib_types.api.json - -/* -Package fib_types is a generated VPP binary API for 'fib_types' module. - -It consists of: - 7 enums - 5 aliases - 9 types - 1 union -*/ -package fib_types - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "fib_types" - // APIVersion is the API version of this module. - APIVersion = "2.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x57387845 -) - -type AddressFamily = ip_types.AddressFamily - -// FibPathFlags represents VPP binary API enum 'fib_path_flags'. -type FibPathFlags uint32 - -const ( - FIB_API_PATH_FLAG_NONE FibPathFlags = 0 - FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED FibPathFlags = 1 - FIB_API_PATH_FLAG_RESOLVE_VIA_HOST FibPathFlags = 2 - FIB_API_PATH_FLAG_POP_PW_CW FibPathFlags = 4 -) - -var FibPathFlags_name = map[uint32]string{ - 0: "FIB_API_PATH_FLAG_NONE", - 1: "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED", - 2: "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST", - 4: "FIB_API_PATH_FLAG_POP_PW_CW", -} - -var FibPathFlags_value = map[string]uint32{ - "FIB_API_PATH_FLAG_NONE": 0, - "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED": 1, - "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST": 2, - "FIB_API_PATH_FLAG_POP_PW_CW": 4, -} - -func (x FibPathFlags) String() string { - s, ok := FibPathFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// FibPathNhProto represents VPP binary API enum 'fib_path_nh_proto'. -type FibPathNhProto uint32 - -const ( - FIB_API_PATH_NH_PROTO_IP4 FibPathNhProto = 0 - FIB_API_PATH_NH_PROTO_IP6 FibPathNhProto = 1 - FIB_API_PATH_NH_PROTO_MPLS FibPathNhProto = 2 - FIB_API_PATH_NH_PROTO_ETHERNET FibPathNhProto = 3 - FIB_API_PATH_NH_PROTO_BIER FibPathNhProto = 4 -) - -var FibPathNhProto_name = map[uint32]string{ - 0: "FIB_API_PATH_NH_PROTO_IP4", - 1: "FIB_API_PATH_NH_PROTO_IP6", - 2: "FIB_API_PATH_NH_PROTO_MPLS", - 3: "FIB_API_PATH_NH_PROTO_ETHERNET", - 4: "FIB_API_PATH_NH_PROTO_BIER", -} - -var FibPathNhProto_value = map[string]uint32{ - "FIB_API_PATH_NH_PROTO_IP4": 0, - "FIB_API_PATH_NH_PROTO_IP6": 1, - "FIB_API_PATH_NH_PROTO_MPLS": 2, - "FIB_API_PATH_NH_PROTO_ETHERNET": 3, - "FIB_API_PATH_NH_PROTO_BIER": 4, -} - -func (x FibPathNhProto) String() string { - s, ok := FibPathNhProto_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// FibPathType represents VPP binary API enum 'fib_path_type'. -type FibPathType uint32 - -const ( - FIB_API_PATH_TYPE_NORMAL FibPathType = 0 - FIB_API_PATH_TYPE_LOCAL FibPathType = 1 - FIB_API_PATH_TYPE_DROP FibPathType = 2 - FIB_API_PATH_TYPE_UDP_ENCAP FibPathType = 3 - FIB_API_PATH_TYPE_BIER_IMP FibPathType = 4 - FIB_API_PATH_TYPE_ICMP_UNREACH FibPathType = 5 - FIB_API_PATH_TYPE_ICMP_PROHIBIT FibPathType = 6 - FIB_API_PATH_TYPE_SOURCE_LOOKUP FibPathType = 7 - FIB_API_PATH_TYPE_DVR FibPathType = 8 - FIB_API_PATH_TYPE_INTERFACE_RX FibPathType = 9 - FIB_API_PATH_TYPE_CLASSIFY FibPathType = 10 -) - -var FibPathType_name = map[uint32]string{ - 0: "FIB_API_PATH_TYPE_NORMAL", - 1: "FIB_API_PATH_TYPE_LOCAL", - 2: "FIB_API_PATH_TYPE_DROP", - 3: "FIB_API_PATH_TYPE_UDP_ENCAP", - 4: "FIB_API_PATH_TYPE_BIER_IMP", - 5: "FIB_API_PATH_TYPE_ICMP_UNREACH", - 6: "FIB_API_PATH_TYPE_ICMP_PROHIBIT", - 7: "FIB_API_PATH_TYPE_SOURCE_LOOKUP", - 8: "FIB_API_PATH_TYPE_DVR", - 9: "FIB_API_PATH_TYPE_INTERFACE_RX", - 10: "FIB_API_PATH_TYPE_CLASSIFY", -} - -var FibPathType_value = map[string]uint32{ - "FIB_API_PATH_TYPE_NORMAL": 0, - "FIB_API_PATH_TYPE_LOCAL": 1, - "FIB_API_PATH_TYPE_DROP": 2, - "FIB_API_PATH_TYPE_UDP_ENCAP": 3, - "FIB_API_PATH_TYPE_BIER_IMP": 4, - "FIB_API_PATH_TYPE_ICMP_UNREACH": 5, - "FIB_API_PATH_TYPE_ICMP_PROHIBIT": 6, - "FIB_API_PATH_TYPE_SOURCE_LOOKUP": 7, - "FIB_API_PATH_TYPE_DVR": 8, - "FIB_API_PATH_TYPE_INTERFACE_RX": 9, - "FIB_API_PATH_TYPE_CLASSIFY": 10, -} - -func (x FibPathType) String() string { - s, ok := FibPathType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -// FibMplsLabel represents VPP binary API type 'fib_mpls_label'. -type FibMplsLabel struct { - IsUniform uint8 - Label uint32 - TTL uint8 - Exp uint8 -} - -func (*FibMplsLabel) GetTypeName() string { return "fib_mpls_label" } - -// FibPath represents VPP binary API type 'fib_path'. -type FibPath struct { - SwIfIndex uint32 - TableID uint32 - RpfID uint32 - Weight uint8 - Preference uint8 - Type FibPathType - Flags FibPathFlags - Proto FibPathNhProto - Nh FibPathNh - NLabels uint8 `struc:"sizeof=LabelStack"` // MANUALLY FIXED, see https://jira.fd.io/browse/VPP-1261 - LabelStack []FibMplsLabel -} - -func (*FibPath) GetTypeName() string { return "fib_path" } - -// FibPathNh represents VPP binary API type 'fib_path_nh'. -type FibPathNh struct { - Address AddressUnion - ViaLabel uint32 - ObjID uint32 - ClassifyTableIndex uint32 -} - -func (*FibPathNh) GetTypeName() string { return "fib_path_nh" } - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/flowprobe/flowprobe.ba.go b/plugins/vpp/binapi/vpp2001/flowprobe/flowprobe.ba.go deleted file mode 100644 index 7b515b129b..0000000000 --- a/plugins/vpp/binapi/vpp2001/flowprobe/flowprobe.ba.go +++ /dev/null @@ -1,215 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/flowprobe.api.json - -/* -Package flowprobe is a generated VPP binary API for 'flowprobe' module. - -It consists of: - 8 enums - 1 alias - 4 messages - 2 services -*/ -package flowprobe - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "flowprobe" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xbb4dfc0d -) - -// FlowprobeRecordFlags represents VPP binary API enum 'flowprobe_record_flags'. -type FlowprobeRecordFlags uint8 - -const ( - FLOWPROBE_RECORD_FLAG_L2 FlowprobeRecordFlags = 1 - FLOWPROBE_RECORD_FLAG_L3 FlowprobeRecordFlags = 2 - FLOWPROBE_RECORD_FLAG_L4 FlowprobeRecordFlags = 4 -) - -var FlowprobeRecordFlags_name = map[uint8]string{ - 1: "FLOWPROBE_RECORD_FLAG_L2", - 2: "FLOWPROBE_RECORD_FLAG_L3", - 4: "FLOWPROBE_RECORD_FLAG_L4", -} - -var FlowprobeRecordFlags_value = map[string]uint8{ - "FLOWPROBE_RECORD_FLAG_L2": 1, - "FLOWPROBE_RECORD_FLAG_L3": 2, - "FLOWPROBE_RECORD_FLAG_L4": 4, -} - -func (x FlowprobeRecordFlags) String() string { - s, ok := FlowprobeRecordFlags_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// FlowprobeWhichFlags represents VPP binary API enum 'flowprobe_which_flags'. -type FlowprobeWhichFlags uint8 - -const ( - FLOWPROBE_WHICH_FLAG_IP4 FlowprobeWhichFlags = 1 - FLOWPROBE_WHICH_FLAG_L2 FlowprobeWhichFlags = 2 - FLOWPROBE_WHICH_FLAG_IP6 FlowprobeWhichFlags = 4 -) - -var FlowprobeWhichFlags_name = map[uint8]string{ - 1: "FLOWPROBE_WHICH_FLAG_IP4", - 2: "FLOWPROBE_WHICH_FLAG_L2", - 4: "FLOWPROBE_WHICH_FLAG_IP6", -} - -var FlowprobeWhichFlags_value = map[string]uint8{ - "FLOWPROBE_WHICH_FLAG_IP4": 1, - "FLOWPROBE_WHICH_FLAG_L2": 2, - "FLOWPROBE_WHICH_FLAG_IP6": 4, -} - -func (x FlowprobeWhichFlags) String() string { - s, ok := FlowprobeWhichFlags_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type InterfaceIndex = interface_types.InterfaceIndex - -// FlowprobeParams represents VPP binary API message 'flowprobe_params'. -type FlowprobeParams struct { - RecordFlags FlowprobeRecordFlags - ActiveTimer uint32 - PassiveTimer uint32 -} - -func (m *FlowprobeParams) Reset() { *m = FlowprobeParams{} } -func (*FlowprobeParams) GetMessageName() string { return "flowprobe_params" } -func (*FlowprobeParams) GetCrcString() string { return "baa46c09" } -func (*FlowprobeParams) GetMessageType() api.MessageType { return api.RequestMessage } - -// FlowprobeParamsReply represents VPP binary API message 'flowprobe_params_reply'. -type FlowprobeParamsReply struct { - Retval int32 -} - -func (m *FlowprobeParamsReply) Reset() { *m = FlowprobeParamsReply{} } -func (*FlowprobeParamsReply) GetMessageName() string { return "flowprobe_params_reply" } -func (*FlowprobeParamsReply) GetCrcString() string { return "e8d4e804" } -func (*FlowprobeParamsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// FlowprobeTxInterfaceAddDel represents VPP binary API message 'flowprobe_tx_interface_add_del'. -type FlowprobeTxInterfaceAddDel struct { - IsAdd bool - Which FlowprobeWhichFlags - SwIfIndex InterfaceIndex -} - -func (m *FlowprobeTxInterfaceAddDel) Reset() { *m = FlowprobeTxInterfaceAddDel{} } -func (*FlowprobeTxInterfaceAddDel) GetMessageName() string { return "flowprobe_tx_interface_add_del" } -func (*FlowprobeTxInterfaceAddDel) GetCrcString() string { return "b782c976" } -func (*FlowprobeTxInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// FlowprobeTxInterfaceAddDelReply represents VPP binary API message 'flowprobe_tx_interface_add_del_reply'. -type FlowprobeTxInterfaceAddDelReply struct { - Retval int32 -} - -func (m *FlowprobeTxInterfaceAddDelReply) Reset() { *m = FlowprobeTxInterfaceAddDelReply{} } -func (*FlowprobeTxInterfaceAddDelReply) GetMessageName() string { - return "flowprobe_tx_interface_add_del_reply" -} -func (*FlowprobeTxInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*FlowprobeTxInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*FlowprobeParams)(nil), "flowprobe.FlowprobeParams") - api.RegisterMessage((*FlowprobeParamsReply)(nil), "flowprobe.FlowprobeParamsReply") - api.RegisterMessage((*FlowprobeTxInterfaceAddDel)(nil), "flowprobe.FlowprobeTxInterfaceAddDel") - api.RegisterMessage((*FlowprobeTxInterfaceAddDelReply)(nil), "flowprobe.FlowprobeTxInterfaceAddDelReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*FlowprobeParams)(nil), - (*FlowprobeParamsReply)(nil), - (*FlowprobeTxInterfaceAddDel)(nil), - (*FlowprobeTxInterfaceAddDelReply)(nil), - } -} - -// RPCService represents RPC service API for flowprobe module. -type RPCService interface { - FlowprobeParams(ctx context.Context, in *FlowprobeParams) (*FlowprobeParamsReply, error) - FlowprobeTxInterfaceAddDel(ctx context.Context, in *FlowprobeTxInterfaceAddDel) (*FlowprobeTxInterfaceAddDelReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) FlowprobeParams(ctx context.Context, in *FlowprobeParams) (*FlowprobeParamsReply, error) { - out := new(FlowprobeParamsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) FlowprobeTxInterfaceAddDel(ctx context.Context, in *FlowprobeTxInterfaceAddDel) (*FlowprobeTxInterfaceAddDelReply, error) { - out := new(FlowprobeTxInterfaceAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/gre/gre.ba.go b/plugins/vpp/binapi/vpp2001/gre/gre.ba.go deleted file mode 100644 index 2f9e73ea80..0000000000 --- a/plugins/vpp/binapi/vpp2001/gre/gre.ba.go +++ /dev/null @@ -1,274 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/gre.api.json - -/* -Package gre is a generated VPP binary API for 'gre' module. - -It consists of: - 12 enums - 6 aliases - 7 types - 1 union - 4 messages - 2 services -*/ -package gre - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "gre" - // APIVersion is the API version of this module. - APIVersion = "2.0.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0xb7663194 -) - -type AddressFamily = ip_types.AddressFamily - -// GreTunnelMode represents VPP binary API enum 'gre_tunnel_mode'. -type GreTunnelMode uint8 - -const ( - GRE_API_TUNNEL_MODE_P2P GreTunnelMode = 1 - GRE_API_TUNNEL_MODE_MP GreTunnelMode = 2 -) - -var GreTunnelMode_name = map[uint8]string{ - 1: "GRE_API_TUNNEL_MODE_P2P", - 2: "GRE_API_TUNNEL_MODE_MP", -} - -var GreTunnelMode_value = map[string]uint8{ - "GRE_API_TUNNEL_MODE_P2P": 1, - "GRE_API_TUNNEL_MODE_MP": 2, -} - -func (x GreTunnelMode) String() string { - s, ok := GreTunnelMode_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// GreTunnelType represents VPP binary API enum 'gre_tunnel_type'. -type GreTunnelType uint8 - -const ( - GRE_API_TUNNEL_TYPE_L3 GreTunnelType = 0 - GRE_API_TUNNEL_TYPE_TEB GreTunnelType = 1 - GRE_API_TUNNEL_TYPE_ERSPAN GreTunnelType = 2 -) - -var GreTunnelType_name = map[uint8]string{ - 0: "GRE_API_TUNNEL_TYPE_L3", - 1: "GRE_API_TUNNEL_TYPE_TEB", - 2: "GRE_API_TUNNEL_TYPE_ERSPAN", -} - -var GreTunnelType_value = map[string]uint8{ - "GRE_API_TUNNEL_TYPE_L3": 0, - "GRE_API_TUNNEL_TYPE_TEB": 1, - "GRE_API_TUNNEL_TYPE_ERSPAN": 2, -} - -func (x GreTunnelType) String() string { - s, ok := GreTunnelType_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -// GreTunnel represents VPP binary API type 'gre_tunnel'. -type GreTunnel struct { - Type GreTunnelType - Mode GreTunnelMode - SessionID uint16 - Instance uint32 - OuterTableID uint32 - SwIfIndex InterfaceIndex - Src Address - Dst Address -} - -func (*GreTunnel) GetTypeName() string { return "gre_tunnel" } - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// GreTunnelAddDel represents VPP binary API message 'gre_tunnel_add_del'. -type GreTunnelAddDel struct { - IsAdd bool - Tunnel GreTunnel -} - -func (m *GreTunnelAddDel) Reset() { *m = GreTunnelAddDel{} } -func (*GreTunnelAddDel) GetMessageName() string { return "gre_tunnel_add_del" } -func (*GreTunnelAddDel) GetCrcString() string { return "f9c4059d" } -func (*GreTunnelAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// GreTunnelAddDelReply represents VPP binary API message 'gre_tunnel_add_del_reply'. -type GreTunnelAddDelReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *GreTunnelAddDelReply) Reset() { *m = GreTunnelAddDelReply{} } -func (*GreTunnelAddDelReply) GetMessageName() string { return "gre_tunnel_add_del_reply" } -func (*GreTunnelAddDelReply) GetCrcString() string { return "5383d31f" } -func (*GreTunnelAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GreTunnelDetails represents VPP binary API message 'gre_tunnel_details'. -type GreTunnelDetails struct { - Tunnel GreTunnel -} - -func (m *GreTunnelDetails) Reset() { *m = GreTunnelDetails{} } -func (*GreTunnelDetails) GetMessageName() string { return "gre_tunnel_details" } -func (*GreTunnelDetails) GetCrcString() string { return "066f8369" } -func (*GreTunnelDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GreTunnelDump represents VPP binary API message 'gre_tunnel_dump'. -type GreTunnelDump struct { - SwIfIndex InterfaceIndex -} - -func (m *GreTunnelDump) Reset() { *m = GreTunnelDump{} } -func (*GreTunnelDump) GetMessageName() string { return "gre_tunnel_dump" } -func (*GreTunnelDump) GetCrcString() string { return "f9e6675e" } -func (*GreTunnelDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*GreTunnelAddDel)(nil), "gre.GreTunnelAddDel") - api.RegisterMessage((*GreTunnelAddDelReply)(nil), "gre.GreTunnelAddDelReply") - api.RegisterMessage((*GreTunnelDetails)(nil), "gre.GreTunnelDetails") - api.RegisterMessage((*GreTunnelDump)(nil), "gre.GreTunnelDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*GreTunnelAddDel)(nil), - (*GreTunnelAddDelReply)(nil), - (*GreTunnelDetails)(nil), - (*GreTunnelDump)(nil), - } -} - -// RPCService represents RPC service API for gre module. -type RPCService interface { - DumpGreTunnel(ctx context.Context, in *GreTunnelDump) (RPCService_DumpGreTunnelClient, error) - GreTunnelAddDel(ctx context.Context, in *GreTunnelAddDel) (*GreTunnelAddDelReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpGreTunnel(ctx context.Context, in *GreTunnelDump) (RPCService_DumpGreTunnelClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpGreTunnelClient{stream} - return x, nil -} - -type RPCService_DumpGreTunnelClient interface { - Recv() (*GreTunnelDetails, error) -} - -type serviceClient_DumpGreTunnelClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpGreTunnelClient) Recv() (*GreTunnelDetails, error) { - m := new(GreTunnelDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) GreTunnelAddDel(ctx context.Context, in *GreTunnelAddDel) (*GreTunnelAddDelReply, error) { - out := new(GreTunnelAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/gtpu/gtpu.ba.go b/plugins/vpp/binapi/vpp2001/gtpu/gtpu.ba.go deleted file mode 100644 index 546de04012..0000000000 --- a/plugins/vpp/binapi/vpp2001/gtpu/gtpu.ba.go +++ /dev/null @@ -1,254 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/gtpu.api.json - -/* -Package gtpu is a generated VPP binary API for 'gtpu' module. - -It consists of: - 10 enums - 6 aliases - 6 types - 1 union - 6 messages - 3 services -*/ -package gtpu - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "gtpu" - // APIVersion is the API version of this module. - APIVersion = "2.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x6305cc01 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// GtpuAddDelTunnel represents VPP binary API message 'gtpu_add_del_tunnel'. -type GtpuAddDelTunnel struct { - IsAdd bool - SrcAddress Address - DstAddress Address - McastSwIfIndex InterfaceIndex - EncapVrfID uint32 - DecapNextIndex uint32 - Teid uint32 -} - -func (m *GtpuAddDelTunnel) Reset() { *m = GtpuAddDelTunnel{} } -func (*GtpuAddDelTunnel) GetMessageName() string { return "gtpu_add_del_tunnel" } -func (*GtpuAddDelTunnel) GetCrcString() string { return "9a26a51c" } -func (*GtpuAddDelTunnel) GetMessageType() api.MessageType { return api.RequestMessage } - -// GtpuAddDelTunnelReply represents VPP binary API message 'gtpu_add_del_tunnel_reply'. -type GtpuAddDelTunnelReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *GtpuAddDelTunnelReply) Reset() { *m = GtpuAddDelTunnelReply{} } -func (*GtpuAddDelTunnelReply) GetMessageName() string { return "gtpu_add_del_tunnel_reply" } -func (*GtpuAddDelTunnelReply) GetCrcString() string { return "5383d31f" } -func (*GtpuAddDelTunnelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GtpuTunnelDetails represents VPP binary API message 'gtpu_tunnel_details'. -type GtpuTunnelDetails struct { - SwIfIndex InterfaceIndex - SrcAddress Address - DstAddress Address - McastSwIfIndex InterfaceIndex - EncapVrfID uint32 - DecapNextIndex uint32 - Teid uint32 -} - -func (m *GtpuTunnelDetails) Reset() { *m = GtpuTunnelDetails{} } -func (*GtpuTunnelDetails) GetMessageName() string { return "gtpu_tunnel_details" } -func (*GtpuTunnelDetails) GetCrcString() string { return "a4d81a09" } -func (*GtpuTunnelDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GtpuTunnelDump represents VPP binary API message 'gtpu_tunnel_dump'. -type GtpuTunnelDump struct { - SwIfIndex InterfaceIndex -} - -func (m *GtpuTunnelDump) Reset() { *m = GtpuTunnelDump{} } -func (*GtpuTunnelDump) GetMessageName() string { return "gtpu_tunnel_dump" } -func (*GtpuTunnelDump) GetCrcString() string { return "f9e6675e" } -func (*GtpuTunnelDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetGtpuBypass represents VPP binary API message 'sw_interface_set_gtpu_bypass'. -type SwInterfaceSetGtpuBypass struct { - SwIfIndex InterfaceIndex - IsIPv6 bool - Enable bool -} - -func (m *SwInterfaceSetGtpuBypass) Reset() { *m = SwInterfaceSetGtpuBypass{} } -func (*SwInterfaceSetGtpuBypass) GetMessageName() string { return "sw_interface_set_gtpu_bypass" } -func (*SwInterfaceSetGtpuBypass) GetCrcString() string { return "65247409" } -func (*SwInterfaceSetGtpuBypass) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetGtpuBypassReply represents VPP binary API message 'sw_interface_set_gtpu_bypass_reply'. -type SwInterfaceSetGtpuBypassReply struct { - Retval int32 -} - -func (m *SwInterfaceSetGtpuBypassReply) Reset() { *m = SwInterfaceSetGtpuBypassReply{} } -func (*SwInterfaceSetGtpuBypassReply) GetMessageName() string { - return "sw_interface_set_gtpu_bypass_reply" -} -func (*SwInterfaceSetGtpuBypassReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetGtpuBypassReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*GtpuAddDelTunnel)(nil), "gtpu.GtpuAddDelTunnel") - api.RegisterMessage((*GtpuAddDelTunnelReply)(nil), "gtpu.GtpuAddDelTunnelReply") - api.RegisterMessage((*GtpuTunnelDetails)(nil), "gtpu.GtpuTunnelDetails") - api.RegisterMessage((*GtpuTunnelDump)(nil), "gtpu.GtpuTunnelDump") - api.RegisterMessage((*SwInterfaceSetGtpuBypass)(nil), "gtpu.SwInterfaceSetGtpuBypass") - api.RegisterMessage((*SwInterfaceSetGtpuBypassReply)(nil), "gtpu.SwInterfaceSetGtpuBypassReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*GtpuAddDelTunnel)(nil), - (*GtpuAddDelTunnelReply)(nil), - (*GtpuTunnelDetails)(nil), - (*GtpuTunnelDump)(nil), - (*SwInterfaceSetGtpuBypass)(nil), - (*SwInterfaceSetGtpuBypassReply)(nil), - } -} - -// RPCService represents RPC service API for gtpu module. -type RPCService interface { - DumpGtpuTunnel(ctx context.Context, in *GtpuTunnelDump) (RPCService_DumpGtpuTunnelClient, error) - GtpuAddDelTunnel(ctx context.Context, in *GtpuAddDelTunnel) (*GtpuAddDelTunnelReply, error) - SwInterfaceSetGtpuBypass(ctx context.Context, in *SwInterfaceSetGtpuBypass) (*SwInterfaceSetGtpuBypassReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpGtpuTunnel(ctx context.Context, in *GtpuTunnelDump) (RPCService_DumpGtpuTunnelClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpGtpuTunnelClient{stream} - return x, nil -} - -type RPCService_DumpGtpuTunnelClient interface { - Recv() (*GtpuTunnelDetails, error) -} - -type serviceClient_DumpGtpuTunnelClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpGtpuTunnelClient) Recv() (*GtpuTunnelDetails, error) { - m := new(GtpuTunnelDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) GtpuAddDelTunnel(ctx context.Context, in *GtpuAddDelTunnel) (*GtpuAddDelTunnelReply, error) { - out := new(GtpuAddDelTunnelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetGtpuBypass(ctx context.Context, in *SwInterfaceSetGtpuBypass) (*SwInterfaceSetGtpuBypassReply, error) { - out := new(SwInterfaceSetGtpuBypassReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/interface_types/interface_types.ba.go b/plugins/vpp/binapi/vpp2001/interface_types/interface_types.ba.go deleted file mode 100644 index a9a34d12d7..0000000000 --- a/plugins/vpp/binapi/vpp2001/interface_types/interface_types.ba.go +++ /dev/null @@ -1,252 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/interface_types.api.json - -/* -Package interface_types is a generated VPP binary API for 'interface_types' module. - -It consists of: - 6 enums - 1 alias -*/ -package interface_types - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "interface_types" - // VersionCrc is the CRC of this module. - VersionCrc = 0xc97be83d -) - -// IfStatusFlags represents VPP binary API enum 'if_status_flags'. -type IfStatusFlags uint32 - -const ( - IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 - IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 -) - -var IfStatusFlags_name = map[uint32]string{ - 1: "IF_STATUS_API_FLAG_ADMIN_UP", - 2: "IF_STATUS_API_FLAG_LINK_UP", -} - -var IfStatusFlags_value = map[string]uint32{ - "IF_STATUS_API_FLAG_ADMIN_UP": 1, - "IF_STATUS_API_FLAG_LINK_UP": 2, -} - -func (x IfStatusFlags) String() string { - s, ok := IfStatusFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IfType represents VPP binary API enum 'if_type'. -type IfType uint32 - -const ( - IF_API_TYPE_HARDWARE IfType = 1 - IF_API_TYPE_SUB IfType = 2 - IF_API_TYPE_P2P IfType = 3 - IF_API_TYPE_PIPE IfType = 4 -) - -var IfType_name = map[uint32]string{ - 1: "IF_API_TYPE_HARDWARE", - 2: "IF_API_TYPE_SUB", - 3: "IF_API_TYPE_P2P", - 4: "IF_API_TYPE_PIPE", -} - -var IfType_value = map[string]uint32{ - "IF_API_TYPE_HARDWARE": 1, - "IF_API_TYPE_SUB": 2, - "IF_API_TYPE_P2P": 3, - "IF_API_TYPE_PIPE": 4, -} - -func (x IfType) String() string { - s, ok := IfType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// LinkDuplex represents VPP binary API enum 'link_duplex'. -type LinkDuplex uint32 - -const ( - LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 - LINK_DUPLEX_API_HALF LinkDuplex = 1 - LINK_DUPLEX_API_FULL LinkDuplex = 2 -) - -var LinkDuplex_name = map[uint32]string{ - 0: "LINK_DUPLEX_API_UNKNOWN", - 1: "LINK_DUPLEX_API_HALF", - 2: "LINK_DUPLEX_API_FULL", -} - -var LinkDuplex_value = map[string]uint32{ - "LINK_DUPLEX_API_UNKNOWN": 0, - "LINK_DUPLEX_API_HALF": 1, - "LINK_DUPLEX_API_FULL": 2, -} - -func (x LinkDuplex) String() string { - s, ok := LinkDuplex_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// MtuProto represents VPP binary API enum 'mtu_proto'. -type MtuProto uint32 - -const ( - MTU_PROTO_API_L3 MtuProto = 1 - MTU_PROTO_API_IP4 MtuProto = 2 - MTU_PROTO_API_IP6 MtuProto = 3 - MTU_PROTO_API_MPLS MtuProto = 4 - MTU_PROTO_API_N MtuProto = 5 -) - -var MtuProto_name = map[uint32]string{ - 1: "MTU_PROTO_API_L3", - 2: "MTU_PROTO_API_IP4", - 3: "MTU_PROTO_API_IP6", - 4: "MTU_PROTO_API_MPLS", - 5: "MTU_PROTO_API_N", -} - -var MtuProto_value = map[string]uint32{ - "MTU_PROTO_API_L3": 1, - "MTU_PROTO_API_IP4": 2, - "MTU_PROTO_API_IP6": 3, - "MTU_PROTO_API_MPLS": 4, - "MTU_PROTO_API_N": 5, -} - -func (x MtuProto) String() string { - s, ok := MtuProto_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// RxMode represents VPP binary API enum 'rx_mode'. -type RxMode uint32 - -const ( - RX_MODE_API_UNKNOWN RxMode = 0 - RX_MODE_API_POLLING RxMode = 1 - RX_MODE_API_INTERRUPT RxMode = 2 - RX_MODE_API_ADAPTIVE RxMode = 3 - RX_MODE_API_DEFAULT RxMode = 4 -) - -var RxMode_name = map[uint32]string{ - 0: "RX_MODE_API_UNKNOWN", - 1: "RX_MODE_API_POLLING", - 2: "RX_MODE_API_INTERRUPT", - 3: "RX_MODE_API_ADAPTIVE", - 4: "RX_MODE_API_DEFAULT", -} - -var RxMode_value = map[string]uint32{ - "RX_MODE_API_UNKNOWN": 0, - "RX_MODE_API_POLLING": 1, - "RX_MODE_API_INTERRUPT": 2, - "RX_MODE_API_ADAPTIVE": 3, - "RX_MODE_API_DEFAULT": 4, -} - -func (x RxMode) String() string { - s, ok := RxMode_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// SubIfFlags represents VPP binary API enum 'sub_if_flags'. -type SubIfFlags uint32 - -const ( - SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1 - SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2 - SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4 - SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8 - SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16 - SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32 - SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64 - SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128 - SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254 - SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256 -) - -var SubIfFlags_name = map[uint32]string{ - 1: "SUB_IF_API_FLAG_NO_TAGS", - 2: "SUB_IF_API_FLAG_ONE_TAG", - 4: "SUB_IF_API_FLAG_TWO_TAGS", - 8: "SUB_IF_API_FLAG_DOT1AD", - 16: "SUB_IF_API_FLAG_EXACT_MATCH", - 32: "SUB_IF_API_FLAG_DEFAULT", - 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", - 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", - 254: "SUB_IF_API_FLAG_MASK_VNET", - 256: "SUB_IF_API_FLAG_DOT1AH", -} - -var SubIfFlags_value = map[string]uint32{ - "SUB_IF_API_FLAG_NO_TAGS": 1, - "SUB_IF_API_FLAG_ONE_TAG": 2, - "SUB_IF_API_FLAG_TWO_TAGS": 4, - "SUB_IF_API_FLAG_DOT1AD": 8, - "SUB_IF_API_FLAG_EXACT_MATCH": 16, - "SUB_IF_API_FLAG_DEFAULT": 32, - "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64, - "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128, - "SUB_IF_API_FLAG_MASK_VNET": 254, - "SUB_IF_API_FLAG_DOT1AH": 256, -} - -func (x SubIfFlags) String() string { - s, ok := SubIfFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// InterfaceIndex represents VPP binary API alias 'interface_index'. -type InterfaceIndex uint32 - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/interfaces/interfaces.ba.go b/plugins/vpp/binapi/vpp2001/interfaces/interfaces.ba.go deleted file mode 100644 index ae55c51121..0000000000 --- a/plugins/vpp/binapi/vpp2001/interfaces/interfaces.ba.go +++ /dev/null @@ -1,1152 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/interface.api.json - -/* -Package interfaces is a generated VPP binary API for 'interface' module. - -It consists of: - 10 enums - 7 aliases - 6 types - 1 union - 53 messages - 26 services -*/ -package interfaces - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "interface" - // APIVersion is the API version of this module. - APIVersion = "3.2.2" - // VersionCrc is the CRC of this module. - VersionCrc = 0xfebc3ffa -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type MacAddress = ethernet_types.MacAddress - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// CollectDetailedInterfaceStats represents VPP binary API message 'collect_detailed_interface_stats'. -type CollectDetailedInterfaceStats struct { - SwIfIndex InterfaceIndex - EnableDisable bool -} - -func (m *CollectDetailedInterfaceStats) Reset() { *m = CollectDetailedInterfaceStats{} } -func (*CollectDetailedInterfaceStats) GetMessageName() string { - return "collect_detailed_interface_stats" -} -func (*CollectDetailedInterfaceStats) GetCrcString() string { return "5501adee" } -func (*CollectDetailedInterfaceStats) GetMessageType() api.MessageType { return api.RequestMessage } - -// CollectDetailedInterfaceStatsReply represents VPP binary API message 'collect_detailed_interface_stats_reply'. -type CollectDetailedInterfaceStatsReply struct { - Retval int32 -} - -func (m *CollectDetailedInterfaceStatsReply) Reset() { *m = CollectDetailedInterfaceStatsReply{} } -func (*CollectDetailedInterfaceStatsReply) GetMessageName() string { - return "collect_detailed_interface_stats_reply" -} -func (*CollectDetailedInterfaceStatsReply) GetCrcString() string { return "e8d4e804" } -func (*CollectDetailedInterfaceStatsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// CreateLoopback represents VPP binary API message 'create_loopback'. -type CreateLoopback struct { - MacAddress MacAddress -} - -func (m *CreateLoopback) Reset() { *m = CreateLoopback{} } -func (*CreateLoopback) GetMessageName() string { return "create_loopback" } -func (*CreateLoopback) GetCrcString() string { return "42bb5d22" } -func (*CreateLoopback) GetMessageType() api.MessageType { return api.RequestMessage } - -// CreateLoopbackInstance represents VPP binary API message 'create_loopback_instance'. -type CreateLoopbackInstance struct { - MacAddress MacAddress - IsSpecified bool - UserInstance uint32 -} - -func (m *CreateLoopbackInstance) Reset() { *m = CreateLoopbackInstance{} } -func (*CreateLoopbackInstance) GetMessageName() string { return "create_loopback_instance" } -func (*CreateLoopbackInstance) GetCrcString() string { return "d36a3ee2" } -func (*CreateLoopbackInstance) GetMessageType() api.MessageType { return api.RequestMessage } - -// CreateLoopbackInstanceReply represents VPP binary API message 'create_loopback_instance_reply'. -type CreateLoopbackInstanceReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *CreateLoopbackInstanceReply) Reset() { *m = CreateLoopbackInstanceReply{} } -func (*CreateLoopbackInstanceReply) GetMessageName() string { return "create_loopback_instance_reply" } -func (*CreateLoopbackInstanceReply) GetCrcString() string { return "5383d31f" } -func (*CreateLoopbackInstanceReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// CreateLoopbackReply represents VPP binary API message 'create_loopback_reply'. -type CreateLoopbackReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *CreateLoopbackReply) Reset() { *m = CreateLoopbackReply{} } -func (*CreateLoopbackReply) GetMessageName() string { return "create_loopback_reply" } -func (*CreateLoopbackReply) GetCrcString() string { return "5383d31f" } -func (*CreateLoopbackReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// CreateSubif represents VPP binary API message 'create_subif'. -type CreateSubif struct { - SwIfIndex InterfaceIndex - SubID uint32 - SubIfFlags SubIfFlags - OuterVlanID uint16 - InnerVlanID uint16 -} - -func (m *CreateSubif) Reset() { *m = CreateSubif{} } -func (*CreateSubif) GetMessageName() string { return "create_subif" } -func (*CreateSubif) GetCrcString() string { return "cb371063" } -func (*CreateSubif) GetMessageType() api.MessageType { return api.RequestMessage } - -// CreateSubifReply represents VPP binary API message 'create_subif_reply'. -type CreateSubifReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *CreateSubifReply) Reset() { *m = CreateSubifReply{} } -func (*CreateSubifReply) GetMessageName() string { return "create_subif_reply" } -func (*CreateSubifReply) GetCrcString() string { return "5383d31f" } -func (*CreateSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// CreateVlanSubif represents VPP binary API message 'create_vlan_subif'. -type CreateVlanSubif struct { - SwIfIndex InterfaceIndex - VlanID uint32 -} - -func (m *CreateVlanSubif) Reset() { *m = CreateVlanSubif{} } -func (*CreateVlanSubif) GetMessageName() string { return "create_vlan_subif" } -func (*CreateVlanSubif) GetCrcString() string { return "af34ac8b" } -func (*CreateVlanSubif) GetMessageType() api.MessageType { return api.RequestMessage } - -// CreateVlanSubifReply represents VPP binary API message 'create_vlan_subif_reply'. -type CreateVlanSubifReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *CreateVlanSubifReply) Reset() { *m = CreateVlanSubifReply{} } -func (*CreateVlanSubifReply) GetMessageName() string { return "create_vlan_subif_reply" } -func (*CreateVlanSubifReply) GetCrcString() string { return "5383d31f" } -func (*CreateVlanSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DeleteLoopback represents VPP binary API message 'delete_loopback'. -type DeleteLoopback struct { - SwIfIndex InterfaceIndex -} - -func (m *DeleteLoopback) Reset() { *m = DeleteLoopback{} } -func (*DeleteLoopback) GetMessageName() string { return "delete_loopback" } -func (*DeleteLoopback) GetCrcString() string { return "f9e6675e" } -func (*DeleteLoopback) GetMessageType() api.MessageType { return api.RequestMessage } - -// DeleteLoopbackReply represents VPP binary API message 'delete_loopback_reply'. -type DeleteLoopbackReply struct { - Retval int32 -} - -func (m *DeleteLoopbackReply) Reset() { *m = DeleteLoopbackReply{} } -func (*DeleteLoopbackReply) GetMessageName() string { return "delete_loopback_reply" } -func (*DeleteLoopbackReply) GetCrcString() string { return "e8d4e804" } -func (*DeleteLoopbackReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DeleteSubif represents VPP binary API message 'delete_subif'. -type DeleteSubif struct { - SwIfIndex InterfaceIndex -} - -func (m *DeleteSubif) Reset() { *m = DeleteSubif{} } -func (*DeleteSubif) GetMessageName() string { return "delete_subif" } -func (*DeleteSubif) GetCrcString() string { return "f9e6675e" } -func (*DeleteSubif) GetMessageType() api.MessageType { return api.RequestMessage } - -// DeleteSubifReply represents VPP binary API message 'delete_subif_reply'. -type DeleteSubifReply struct { - Retval int32 -} - -func (m *DeleteSubifReply) Reset() { *m = DeleteSubifReply{} } -func (*DeleteSubifReply) GetMessageName() string { return "delete_subif_reply" } -func (*DeleteSubifReply) GetCrcString() string { return "e8d4e804" } -func (*DeleteSubifReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// HwInterfaceSetMtu represents VPP binary API message 'hw_interface_set_mtu'. -type HwInterfaceSetMtu struct { - SwIfIndex InterfaceIndex - Mtu uint16 -} - -func (m *HwInterfaceSetMtu) Reset() { *m = HwInterfaceSetMtu{} } -func (*HwInterfaceSetMtu) GetMessageName() string { return "hw_interface_set_mtu" } -func (*HwInterfaceSetMtu) GetCrcString() string { return "e6746899" } -func (*HwInterfaceSetMtu) GetMessageType() api.MessageType { return api.RequestMessage } - -// HwInterfaceSetMtuReply represents VPP binary API message 'hw_interface_set_mtu_reply'. -type HwInterfaceSetMtuReply struct { - Retval int32 -} - -func (m *HwInterfaceSetMtuReply) Reset() { *m = HwInterfaceSetMtuReply{} } -func (*HwInterfaceSetMtuReply) GetMessageName() string { return "hw_interface_set_mtu_reply" } -func (*HwInterfaceSetMtuReply) GetCrcString() string { return "e8d4e804" } -func (*HwInterfaceSetMtuReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// InterfaceNameRenumber represents VPP binary API message 'interface_name_renumber'. -type InterfaceNameRenumber struct { - SwIfIndex InterfaceIndex - NewShowDevInstance uint32 -} - -func (m *InterfaceNameRenumber) Reset() { *m = InterfaceNameRenumber{} } -func (*InterfaceNameRenumber) GetMessageName() string { return "interface_name_renumber" } -func (*InterfaceNameRenumber) GetCrcString() string { return "2b8858b8" } -func (*InterfaceNameRenumber) GetMessageType() api.MessageType { return api.RequestMessage } - -// InterfaceNameRenumberReply represents VPP binary API message 'interface_name_renumber_reply'. -type InterfaceNameRenumberReply struct { - Retval int32 -} - -func (m *InterfaceNameRenumberReply) Reset() { *m = InterfaceNameRenumberReply{} } -func (*InterfaceNameRenumberReply) GetMessageName() string { return "interface_name_renumber_reply" } -func (*InterfaceNameRenumberReply) GetCrcString() string { return "e8d4e804" } -func (*InterfaceNameRenumberReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceAddDelAddress represents VPP binary API message 'sw_interface_add_del_address'. -type SwInterfaceAddDelAddress struct { - SwIfIndex InterfaceIndex - IsAdd bool - DelAll bool - Prefix AddressWithPrefix -} - -func (m *SwInterfaceAddDelAddress) Reset() { *m = SwInterfaceAddDelAddress{} } -func (*SwInterfaceAddDelAddress) GetMessageName() string { return "sw_interface_add_del_address" } -func (*SwInterfaceAddDelAddress) GetCrcString() string { return "5803d5c4" } -func (*SwInterfaceAddDelAddress) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceAddDelAddressReply represents VPP binary API message 'sw_interface_add_del_address_reply'. -type SwInterfaceAddDelAddressReply struct { - Retval int32 -} - -func (m *SwInterfaceAddDelAddressReply) Reset() { *m = SwInterfaceAddDelAddressReply{} } -func (*SwInterfaceAddDelAddressReply) GetMessageName() string { - return "sw_interface_add_del_address_reply" -} -func (*SwInterfaceAddDelAddressReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceAddDelAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceAddDelMacAddress represents VPP binary API message 'sw_interface_add_del_mac_address'. -type SwInterfaceAddDelMacAddress struct { - SwIfIndex uint32 - Addr MacAddress - IsAdd uint8 -} - -func (m *SwInterfaceAddDelMacAddress) Reset() { *m = SwInterfaceAddDelMacAddress{} } -func (*SwInterfaceAddDelMacAddress) GetMessageName() string { - return "sw_interface_add_del_mac_address" -} -func (*SwInterfaceAddDelMacAddress) GetCrcString() string { return "638bb9f4" } -func (*SwInterfaceAddDelMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceAddDelMacAddressReply represents VPP binary API message 'sw_interface_add_del_mac_address_reply'. -type SwInterfaceAddDelMacAddressReply struct { - Retval int32 -} - -func (m *SwInterfaceAddDelMacAddressReply) Reset() { *m = SwInterfaceAddDelMacAddressReply{} } -func (*SwInterfaceAddDelMacAddressReply) GetMessageName() string { - return "sw_interface_add_del_mac_address_reply" -} -func (*SwInterfaceAddDelMacAddressReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceAddDelMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceClearStats represents VPP binary API message 'sw_interface_clear_stats'. -type SwInterfaceClearStats struct { - SwIfIndex InterfaceIndex -} - -func (m *SwInterfaceClearStats) Reset() { *m = SwInterfaceClearStats{} } -func (*SwInterfaceClearStats) GetMessageName() string { return "sw_interface_clear_stats" } -func (*SwInterfaceClearStats) GetCrcString() string { return "f9e6675e" } -func (*SwInterfaceClearStats) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceClearStatsReply represents VPP binary API message 'sw_interface_clear_stats_reply'. -type SwInterfaceClearStatsReply struct { - Retval int32 -} - -func (m *SwInterfaceClearStatsReply) Reset() { *m = SwInterfaceClearStatsReply{} } -func (*SwInterfaceClearStatsReply) GetMessageName() string { return "sw_interface_clear_stats_reply" } -func (*SwInterfaceClearStatsReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceClearStatsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceDetails represents VPP binary API message 'sw_interface_details'. -type SwInterfaceDetails struct { - SwIfIndex InterfaceIndex - SupSwIfIndex uint32 - L2Address MacAddress - Flags IfStatusFlags - Type IfType - LinkDuplex LinkDuplex - LinkSpeed uint32 - LinkMtu uint16 - Mtu []uint32 `struc:"[4]uint32"` - SubID uint32 - SubNumberOfTags uint8 - SubOuterVlanID uint16 - SubInnerVlanID uint16 - SubIfFlags SubIfFlags - VtrOp uint32 - VtrPushDot1q uint32 - VtrTag1 uint32 - VtrTag2 uint32 - OuterTag uint16 - BDmac MacAddress - BSmac MacAddress - BVlanid uint16 - ISid uint32 - InterfaceName string `struc:"[64]byte"` - InterfaceDevType string `struc:"[64]byte"` - Tag string `struc:"[64]byte"` -} - -func (m *SwInterfaceDetails) Reset() { *m = SwInterfaceDetails{} } -func (*SwInterfaceDetails) GetMessageName() string { return "sw_interface_details" } -func (*SwInterfaceDetails) GetCrcString() string { return "17b69fa2" } -func (*SwInterfaceDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceDump represents VPP binary API message 'sw_interface_dump'. -type SwInterfaceDump struct { - SwIfIndex InterfaceIndex - NameFilterValid bool - XXX_NameFilterLen uint32 `struc:"sizeof=NameFilter"` - NameFilter string -} - -func (m *SwInterfaceDump) Reset() { *m = SwInterfaceDump{} } -func (*SwInterfaceDump) GetMessageName() string { return "sw_interface_dump" } -func (*SwInterfaceDump) GetCrcString() string { return "aa610c27" } -func (*SwInterfaceDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceEvent represents VPP binary API message 'sw_interface_event'. -type SwInterfaceEvent struct { - PID uint32 - SwIfIndex InterfaceIndex - Flags IfStatusFlags - Deleted bool -} - -func (m *SwInterfaceEvent) Reset() { *m = SwInterfaceEvent{} } -func (*SwInterfaceEvent) GetMessageName() string { return "sw_interface_event" } -func (*SwInterfaceEvent) GetCrcString() string { return "f709f78d" } -func (*SwInterfaceEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// SwInterfaceGetMacAddress represents VPP binary API message 'sw_interface_get_mac_address'. -type SwInterfaceGetMacAddress struct { - SwIfIndex InterfaceIndex -} - -func (m *SwInterfaceGetMacAddress) Reset() { *m = SwInterfaceGetMacAddress{} } -func (*SwInterfaceGetMacAddress) GetMessageName() string { return "sw_interface_get_mac_address" } -func (*SwInterfaceGetMacAddress) GetCrcString() string { return "f9e6675e" } -func (*SwInterfaceGetMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceGetMacAddressReply represents VPP binary API message 'sw_interface_get_mac_address_reply'. -type SwInterfaceGetMacAddressReply struct { - Retval int32 - MacAddress MacAddress -} - -func (m *SwInterfaceGetMacAddressReply) Reset() { *m = SwInterfaceGetMacAddressReply{} } -func (*SwInterfaceGetMacAddressReply) GetMessageName() string { - return "sw_interface_get_mac_address_reply" -} -func (*SwInterfaceGetMacAddressReply) GetCrcString() string { return "40ef2c08" } -func (*SwInterfaceGetMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceGetTable represents VPP binary API message 'sw_interface_get_table'. -type SwInterfaceGetTable struct { - SwIfIndex InterfaceIndex - IsIPv6 bool -} - -func (m *SwInterfaceGetTable) Reset() { *m = SwInterfaceGetTable{} } -func (*SwInterfaceGetTable) GetMessageName() string { return "sw_interface_get_table" } -func (*SwInterfaceGetTable) GetCrcString() string { return "2d033de4" } -func (*SwInterfaceGetTable) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceGetTableReply represents VPP binary API message 'sw_interface_get_table_reply'. -type SwInterfaceGetTableReply struct { - Retval int32 - VrfID uint32 -} - -func (m *SwInterfaceGetTableReply) Reset() { *m = SwInterfaceGetTableReply{} } -func (*SwInterfaceGetTableReply) GetMessageName() string { return "sw_interface_get_table_reply" } -func (*SwInterfaceGetTableReply) GetCrcString() string { return "a6eb0109" } -func (*SwInterfaceGetTableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceRxPlacementDetails represents VPP binary API message 'sw_interface_rx_placement_details'. -type SwInterfaceRxPlacementDetails struct { - SwIfIndex InterfaceIndex - QueueID uint32 - WorkerID uint32 - Mode RxMode -} - -func (m *SwInterfaceRxPlacementDetails) Reset() { *m = SwInterfaceRxPlacementDetails{} } -func (*SwInterfaceRxPlacementDetails) GetMessageName() string { - return "sw_interface_rx_placement_details" -} -func (*SwInterfaceRxPlacementDetails) GetCrcString() string { return "f6d7d024" } -func (*SwInterfaceRxPlacementDetails) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceRxPlacementDump represents VPP binary API message 'sw_interface_rx_placement_dump'. -type SwInterfaceRxPlacementDump struct { - SwIfIndex InterfaceIndex -} - -func (m *SwInterfaceRxPlacementDump) Reset() { *m = SwInterfaceRxPlacementDump{} } -func (*SwInterfaceRxPlacementDump) GetMessageName() string { return "sw_interface_rx_placement_dump" } -func (*SwInterfaceRxPlacementDump) GetCrcString() string { return "f9e6675e" } -func (*SwInterfaceRxPlacementDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetFlags represents VPP binary API message 'sw_interface_set_flags'. -type SwInterfaceSetFlags struct { - SwIfIndex InterfaceIndex - Flags IfStatusFlags -} - -func (m *SwInterfaceSetFlags) Reset() { *m = SwInterfaceSetFlags{} } -func (*SwInterfaceSetFlags) GetMessageName() string { return "sw_interface_set_flags" } -func (*SwInterfaceSetFlags) GetCrcString() string { return "6a2b491a" } -func (*SwInterfaceSetFlags) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetFlagsReply represents VPP binary API message 'sw_interface_set_flags_reply'. -type SwInterfaceSetFlagsReply struct { - Retval int32 -} - -func (m *SwInterfaceSetFlagsReply) Reset() { *m = SwInterfaceSetFlagsReply{} } -func (*SwInterfaceSetFlagsReply) GetMessageName() string { return "sw_interface_set_flags_reply" } -func (*SwInterfaceSetFlagsReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetFlagsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetIPDirectedBroadcast represents VPP binary API message 'sw_interface_set_ip_directed_broadcast'. -type SwInterfaceSetIPDirectedBroadcast struct { - SwIfIndex InterfaceIndex - Enable bool -} - -func (m *SwInterfaceSetIPDirectedBroadcast) Reset() { *m = SwInterfaceSetIPDirectedBroadcast{} } -func (*SwInterfaceSetIPDirectedBroadcast) GetMessageName() string { - return "sw_interface_set_ip_directed_broadcast" -} -func (*SwInterfaceSetIPDirectedBroadcast) GetCrcString() string { return "ae6cfcfb" } -func (*SwInterfaceSetIPDirectedBroadcast) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetIPDirectedBroadcastReply represents VPP binary API message 'sw_interface_set_ip_directed_broadcast_reply'. -type SwInterfaceSetIPDirectedBroadcastReply struct { - Retval int32 -} - -func (m *SwInterfaceSetIPDirectedBroadcastReply) Reset() { - *m = SwInterfaceSetIPDirectedBroadcastReply{} -} -func (*SwInterfaceSetIPDirectedBroadcastReply) GetMessageName() string { - return "sw_interface_set_ip_directed_broadcast_reply" -} -func (*SwInterfaceSetIPDirectedBroadcastReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetIPDirectedBroadcastReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// SwInterfaceSetMacAddress represents VPP binary API message 'sw_interface_set_mac_address'. -type SwInterfaceSetMacAddress struct { - SwIfIndex InterfaceIndex - MacAddress MacAddress -} - -func (m *SwInterfaceSetMacAddress) Reset() { *m = SwInterfaceSetMacAddress{} } -func (*SwInterfaceSetMacAddress) GetMessageName() string { return "sw_interface_set_mac_address" } -func (*SwInterfaceSetMacAddress) GetCrcString() string { return "6aca746a" } -func (*SwInterfaceSetMacAddress) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetMacAddressReply represents VPP binary API message 'sw_interface_set_mac_address_reply'. -type SwInterfaceSetMacAddressReply struct { - Retval int32 -} - -func (m *SwInterfaceSetMacAddressReply) Reset() { *m = SwInterfaceSetMacAddressReply{} } -func (*SwInterfaceSetMacAddressReply) GetMessageName() string { - return "sw_interface_set_mac_address_reply" -} -func (*SwInterfaceSetMacAddressReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetMacAddressReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetMtu represents VPP binary API message 'sw_interface_set_mtu'. -type SwInterfaceSetMtu struct { - SwIfIndex InterfaceIndex - Mtu []uint32 `struc:"[4]uint32"` -} - -func (m *SwInterfaceSetMtu) Reset() { *m = SwInterfaceSetMtu{} } -func (*SwInterfaceSetMtu) GetMessageName() string { return "sw_interface_set_mtu" } -func (*SwInterfaceSetMtu) GetCrcString() string { return "5cbe85e5" } -func (*SwInterfaceSetMtu) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetMtuReply represents VPP binary API message 'sw_interface_set_mtu_reply'. -type SwInterfaceSetMtuReply struct { - Retval int32 -} - -func (m *SwInterfaceSetMtuReply) Reset() { *m = SwInterfaceSetMtuReply{} } -func (*SwInterfaceSetMtuReply) GetMessageName() string { return "sw_interface_set_mtu_reply" } -func (*SwInterfaceSetMtuReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetMtuReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetRxMode represents VPP binary API message 'sw_interface_set_rx_mode'. -type SwInterfaceSetRxMode struct { - SwIfIndex InterfaceIndex - QueueIDValid bool - QueueID uint32 - Mode RxMode -} - -func (m *SwInterfaceSetRxMode) Reset() { *m = SwInterfaceSetRxMode{} } -func (*SwInterfaceSetRxMode) GetMessageName() string { return "sw_interface_set_rx_mode" } -func (*SwInterfaceSetRxMode) GetCrcString() string { return "780f5cee" } -func (*SwInterfaceSetRxMode) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetRxModeReply represents VPP binary API message 'sw_interface_set_rx_mode_reply'. -type SwInterfaceSetRxModeReply struct { - Retval int32 -} - -func (m *SwInterfaceSetRxModeReply) Reset() { *m = SwInterfaceSetRxModeReply{} } -func (*SwInterfaceSetRxModeReply) GetMessageName() string { return "sw_interface_set_rx_mode_reply" } -func (*SwInterfaceSetRxModeReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetRxModeReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetRxPlacement represents VPP binary API message 'sw_interface_set_rx_placement'. -type SwInterfaceSetRxPlacement struct { - SwIfIndex InterfaceIndex - QueueID uint32 - WorkerID uint32 - IsMain bool -} - -func (m *SwInterfaceSetRxPlacement) Reset() { *m = SwInterfaceSetRxPlacement{} } -func (*SwInterfaceSetRxPlacement) GetMessageName() string { return "sw_interface_set_rx_placement" } -func (*SwInterfaceSetRxPlacement) GetCrcString() string { return "db65f3c9" } -func (*SwInterfaceSetRxPlacement) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetRxPlacementReply represents VPP binary API message 'sw_interface_set_rx_placement_reply'. -type SwInterfaceSetRxPlacementReply struct { - Retval int32 -} - -func (m *SwInterfaceSetRxPlacementReply) Reset() { *m = SwInterfaceSetRxPlacementReply{} } -func (*SwInterfaceSetRxPlacementReply) GetMessageName() string { - return "sw_interface_set_rx_placement_reply" -} -func (*SwInterfaceSetRxPlacementReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetRxPlacementReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetTable represents VPP binary API message 'sw_interface_set_table'. -type SwInterfaceSetTable struct { - SwIfIndex InterfaceIndex - IsIPv6 bool - VrfID uint32 -} - -func (m *SwInterfaceSetTable) Reset() { *m = SwInterfaceSetTable{} } -func (*SwInterfaceSetTable) GetMessageName() string { return "sw_interface_set_table" } -func (*SwInterfaceSetTable) GetCrcString() string { return "df42a577" } -func (*SwInterfaceSetTable) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetTableReply represents VPP binary API message 'sw_interface_set_table_reply'. -type SwInterfaceSetTableReply struct { - Retval int32 -} - -func (m *SwInterfaceSetTableReply) Reset() { *m = SwInterfaceSetTableReply{} } -func (*SwInterfaceSetTableReply) GetMessageName() string { return "sw_interface_set_table_reply" } -func (*SwInterfaceSetTableReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetTableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetUnnumbered represents VPP binary API message 'sw_interface_set_unnumbered'. -type SwInterfaceSetUnnumbered struct { - SwIfIndex InterfaceIndex - UnnumberedSwIfIndex InterfaceIndex - IsAdd bool -} - -func (m *SwInterfaceSetUnnumbered) Reset() { *m = SwInterfaceSetUnnumbered{} } -func (*SwInterfaceSetUnnumbered) GetMessageName() string { return "sw_interface_set_unnumbered" } -func (*SwInterfaceSetUnnumbered) GetCrcString() string { return "938ef33b" } -func (*SwInterfaceSetUnnumbered) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetUnnumberedReply represents VPP binary API message 'sw_interface_set_unnumbered_reply'. -type SwInterfaceSetUnnumberedReply struct { - Retval int32 -} - -func (m *SwInterfaceSetUnnumberedReply) Reset() { *m = SwInterfaceSetUnnumberedReply{} } -func (*SwInterfaceSetUnnumberedReply) GetMessageName() string { - return "sw_interface_set_unnumbered_reply" -} -func (*SwInterfaceSetUnnumberedReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetUnnumberedReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceTagAddDel represents VPP binary API message 'sw_interface_tag_add_del'. -type SwInterfaceTagAddDel struct { - IsAdd bool - SwIfIndex InterfaceIndex - Tag string `struc:"[64]byte"` -} - -func (m *SwInterfaceTagAddDel) Reset() { *m = SwInterfaceTagAddDel{} } -func (*SwInterfaceTagAddDel) GetMessageName() string { return "sw_interface_tag_add_del" } -func (*SwInterfaceTagAddDel) GetCrcString() string { return "426f8bc1" } -func (*SwInterfaceTagAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceTagAddDelReply represents VPP binary API message 'sw_interface_tag_add_del_reply'. -type SwInterfaceTagAddDelReply struct { - Retval int32 -} - -func (m *SwInterfaceTagAddDelReply) Reset() { *m = SwInterfaceTagAddDelReply{} } -func (*SwInterfaceTagAddDelReply) GetMessageName() string { return "sw_interface_tag_add_del_reply" } -func (*SwInterfaceTagAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceTagAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// WantInterfaceEvents represents VPP binary API message 'want_interface_events'. -type WantInterfaceEvents struct { - EnableDisable uint32 - PID uint32 -} - -func (m *WantInterfaceEvents) Reset() { *m = WantInterfaceEvents{} } -func (*WantInterfaceEvents) GetMessageName() string { return "want_interface_events" } -func (*WantInterfaceEvents) GetCrcString() string { return "476f5a08" } -func (*WantInterfaceEvents) GetMessageType() api.MessageType { return api.RequestMessage } - -// WantInterfaceEventsReply represents VPP binary API message 'want_interface_events_reply'. -type WantInterfaceEventsReply struct { - Retval int32 -} - -func (m *WantInterfaceEventsReply) Reset() { *m = WantInterfaceEventsReply{} } -func (*WantInterfaceEventsReply) GetMessageName() string { return "want_interface_events_reply" } -func (*WantInterfaceEventsReply) GetCrcString() string { return "e8d4e804" } -func (*WantInterfaceEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*CollectDetailedInterfaceStats)(nil), "interface.CollectDetailedInterfaceStats") - api.RegisterMessage((*CollectDetailedInterfaceStatsReply)(nil), "interface.CollectDetailedInterfaceStatsReply") - api.RegisterMessage((*CreateLoopback)(nil), "interface.CreateLoopback") - api.RegisterMessage((*CreateLoopbackInstance)(nil), "interface.CreateLoopbackInstance") - api.RegisterMessage((*CreateLoopbackInstanceReply)(nil), "interface.CreateLoopbackInstanceReply") - api.RegisterMessage((*CreateLoopbackReply)(nil), "interface.CreateLoopbackReply") - api.RegisterMessage((*CreateSubif)(nil), "interface.CreateSubif") - api.RegisterMessage((*CreateSubifReply)(nil), "interface.CreateSubifReply") - api.RegisterMessage((*CreateVlanSubif)(nil), "interface.CreateVlanSubif") - api.RegisterMessage((*CreateVlanSubifReply)(nil), "interface.CreateVlanSubifReply") - api.RegisterMessage((*DeleteLoopback)(nil), "interface.DeleteLoopback") - api.RegisterMessage((*DeleteLoopbackReply)(nil), "interface.DeleteLoopbackReply") - api.RegisterMessage((*DeleteSubif)(nil), "interface.DeleteSubif") - api.RegisterMessage((*DeleteSubifReply)(nil), "interface.DeleteSubifReply") - api.RegisterMessage((*HwInterfaceSetMtu)(nil), "interface.HwInterfaceSetMtu") - api.RegisterMessage((*HwInterfaceSetMtuReply)(nil), "interface.HwInterfaceSetMtuReply") - api.RegisterMessage((*InterfaceNameRenumber)(nil), "interface.InterfaceNameRenumber") - api.RegisterMessage((*InterfaceNameRenumberReply)(nil), "interface.InterfaceNameRenumberReply") - api.RegisterMessage((*SwInterfaceAddDelAddress)(nil), "interface.SwInterfaceAddDelAddress") - api.RegisterMessage((*SwInterfaceAddDelAddressReply)(nil), "interface.SwInterfaceAddDelAddressReply") - api.RegisterMessage((*SwInterfaceAddDelMacAddress)(nil), "interface.SwInterfaceAddDelMacAddress") - api.RegisterMessage((*SwInterfaceAddDelMacAddressReply)(nil), "interface.SwInterfaceAddDelMacAddressReply") - api.RegisterMessage((*SwInterfaceClearStats)(nil), "interface.SwInterfaceClearStats") - api.RegisterMessage((*SwInterfaceClearStatsReply)(nil), "interface.SwInterfaceClearStatsReply") - api.RegisterMessage((*SwInterfaceDetails)(nil), "interface.SwInterfaceDetails") - api.RegisterMessage((*SwInterfaceDump)(nil), "interface.SwInterfaceDump") - api.RegisterMessage((*SwInterfaceEvent)(nil), "interface.SwInterfaceEvent") - api.RegisterMessage((*SwInterfaceGetMacAddress)(nil), "interface.SwInterfaceGetMacAddress") - api.RegisterMessage((*SwInterfaceGetMacAddressReply)(nil), "interface.SwInterfaceGetMacAddressReply") - api.RegisterMessage((*SwInterfaceGetTable)(nil), "interface.SwInterfaceGetTable") - api.RegisterMessage((*SwInterfaceGetTableReply)(nil), "interface.SwInterfaceGetTableReply") - api.RegisterMessage((*SwInterfaceRxPlacementDetails)(nil), "interface.SwInterfaceRxPlacementDetails") - api.RegisterMessage((*SwInterfaceRxPlacementDump)(nil), "interface.SwInterfaceRxPlacementDump") - api.RegisterMessage((*SwInterfaceSetFlags)(nil), "interface.SwInterfaceSetFlags") - api.RegisterMessage((*SwInterfaceSetFlagsReply)(nil), "interface.SwInterfaceSetFlagsReply") - api.RegisterMessage((*SwInterfaceSetIPDirectedBroadcast)(nil), "interface.SwInterfaceSetIPDirectedBroadcast") - api.RegisterMessage((*SwInterfaceSetIPDirectedBroadcastReply)(nil), "interface.SwInterfaceSetIPDirectedBroadcastReply") - api.RegisterMessage((*SwInterfaceSetMacAddress)(nil), "interface.SwInterfaceSetMacAddress") - api.RegisterMessage((*SwInterfaceSetMacAddressReply)(nil), "interface.SwInterfaceSetMacAddressReply") - api.RegisterMessage((*SwInterfaceSetMtu)(nil), "interface.SwInterfaceSetMtu") - api.RegisterMessage((*SwInterfaceSetMtuReply)(nil), "interface.SwInterfaceSetMtuReply") - api.RegisterMessage((*SwInterfaceSetRxMode)(nil), "interface.SwInterfaceSetRxMode") - api.RegisterMessage((*SwInterfaceSetRxModeReply)(nil), "interface.SwInterfaceSetRxModeReply") - api.RegisterMessage((*SwInterfaceSetRxPlacement)(nil), "interface.SwInterfaceSetRxPlacement") - api.RegisterMessage((*SwInterfaceSetRxPlacementReply)(nil), "interface.SwInterfaceSetRxPlacementReply") - api.RegisterMessage((*SwInterfaceSetTable)(nil), "interface.SwInterfaceSetTable") - api.RegisterMessage((*SwInterfaceSetTableReply)(nil), "interface.SwInterfaceSetTableReply") - api.RegisterMessage((*SwInterfaceSetUnnumbered)(nil), "interface.SwInterfaceSetUnnumbered") - api.RegisterMessage((*SwInterfaceSetUnnumberedReply)(nil), "interface.SwInterfaceSetUnnumberedReply") - api.RegisterMessage((*SwInterfaceTagAddDel)(nil), "interface.SwInterfaceTagAddDel") - api.RegisterMessage((*SwInterfaceTagAddDelReply)(nil), "interface.SwInterfaceTagAddDelReply") - api.RegisterMessage((*WantInterfaceEvents)(nil), "interface.WantInterfaceEvents") - api.RegisterMessage((*WantInterfaceEventsReply)(nil), "interface.WantInterfaceEventsReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*CollectDetailedInterfaceStats)(nil), - (*CollectDetailedInterfaceStatsReply)(nil), - (*CreateLoopback)(nil), - (*CreateLoopbackInstance)(nil), - (*CreateLoopbackInstanceReply)(nil), - (*CreateLoopbackReply)(nil), - (*CreateSubif)(nil), - (*CreateSubifReply)(nil), - (*CreateVlanSubif)(nil), - (*CreateVlanSubifReply)(nil), - (*DeleteLoopback)(nil), - (*DeleteLoopbackReply)(nil), - (*DeleteSubif)(nil), - (*DeleteSubifReply)(nil), - (*HwInterfaceSetMtu)(nil), - (*HwInterfaceSetMtuReply)(nil), - (*InterfaceNameRenumber)(nil), - (*InterfaceNameRenumberReply)(nil), - (*SwInterfaceAddDelAddress)(nil), - (*SwInterfaceAddDelAddressReply)(nil), - (*SwInterfaceAddDelMacAddress)(nil), - (*SwInterfaceAddDelMacAddressReply)(nil), - (*SwInterfaceClearStats)(nil), - (*SwInterfaceClearStatsReply)(nil), - (*SwInterfaceDetails)(nil), - (*SwInterfaceDump)(nil), - (*SwInterfaceEvent)(nil), - (*SwInterfaceGetMacAddress)(nil), - (*SwInterfaceGetMacAddressReply)(nil), - (*SwInterfaceGetTable)(nil), - (*SwInterfaceGetTableReply)(nil), - (*SwInterfaceRxPlacementDetails)(nil), - (*SwInterfaceRxPlacementDump)(nil), - (*SwInterfaceSetFlags)(nil), - (*SwInterfaceSetFlagsReply)(nil), - (*SwInterfaceSetIPDirectedBroadcast)(nil), - (*SwInterfaceSetIPDirectedBroadcastReply)(nil), - (*SwInterfaceSetMacAddress)(nil), - (*SwInterfaceSetMacAddressReply)(nil), - (*SwInterfaceSetMtu)(nil), - (*SwInterfaceSetMtuReply)(nil), - (*SwInterfaceSetRxMode)(nil), - (*SwInterfaceSetRxModeReply)(nil), - (*SwInterfaceSetRxPlacement)(nil), - (*SwInterfaceSetRxPlacementReply)(nil), - (*SwInterfaceSetTable)(nil), - (*SwInterfaceSetTableReply)(nil), - (*SwInterfaceSetUnnumbered)(nil), - (*SwInterfaceSetUnnumberedReply)(nil), - (*SwInterfaceTagAddDel)(nil), - (*SwInterfaceTagAddDelReply)(nil), - (*WantInterfaceEvents)(nil), - (*WantInterfaceEventsReply)(nil), - } -} - -// RPCService represents RPC service API for interface module. -type RPCService interface { - DumpSwInterface(ctx context.Context, in *SwInterfaceDump) (RPCService_DumpSwInterfaceClient, error) - DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_DumpSwInterfaceRxPlacementClient, error) - CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) - CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) - CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) - CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubifReply, error) - CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*CreateVlanSubifReply, error) - DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*DeleteLoopbackReply, error) - DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubifReply, error) - HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) (*HwInterfaceSetMtuReply, error) - InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) - SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) - SwInterfaceAddDelMacAddress(ctx context.Context, in *SwInterfaceAddDelMacAddress) (*SwInterfaceAddDelMacAddressReply, error) - SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) - SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) - SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) - SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) - SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) - SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) - SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) (*SwInterfaceSetMtuReply, error) - SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRxMode) (*SwInterfaceSetRxModeReply, error) - SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterfaceSetRxPlacement) (*SwInterfaceSetRxPlacementReply, error) - SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTable) (*SwInterfaceSetTableReply, error) - SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) - SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) - WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpSwInterface(ctx context.Context, in *SwInterfaceDump) (RPCService_DumpSwInterfaceClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceClient{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceClient interface { - Recv() (*SwInterfaceDetails, error) -} - -type serviceClient_DumpSwInterfaceClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSwInterfaceClient) Recv() (*SwInterfaceDetails, error) { - m := new(SwInterfaceDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_DumpSwInterfaceRxPlacementClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceRxPlacementClient{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceRxPlacementClient interface { - Recv() (*SwInterfaceRxPlacementDetails, error) -} - -type serviceClient_DumpSwInterfaceRxPlacementClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSwInterfaceRxPlacementClient) Recv() (*SwInterfaceRxPlacementDetails, error) { - m := new(SwInterfaceRxPlacementDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) { - out := new(CollectDetailedInterfaceStatsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) { - out := new(CreateLoopbackReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) { - out := new(CreateLoopbackInstanceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubifReply, error) { - out := new(CreateSubifReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*CreateVlanSubifReply, error) { - out := new(CreateVlanSubifReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*DeleteLoopbackReply, error) { - out := new(DeleteLoopbackReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubifReply, error) { - out := new(DeleteSubifReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) (*HwInterfaceSetMtuReply, error) { - out := new(HwInterfaceSetMtuReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) { - out := new(InterfaceNameRenumberReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) { - out := new(SwInterfaceAddDelAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwInterfaceAddDelMacAddress) (*SwInterfaceAddDelMacAddressReply, error) { - out := new(SwInterfaceAddDelMacAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) { - out := new(SwInterfaceClearStatsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) { - out := new(SwInterfaceGetMacAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) { - out := new(SwInterfaceGetTableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) { - out := new(SwInterfaceSetFlagsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) { - out := new(SwInterfaceSetIPDirectedBroadcastReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) { - out := new(SwInterfaceSetMacAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) (*SwInterfaceSetMtuReply, error) { - out := new(SwInterfaceSetMtuReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRxMode) (*SwInterfaceSetRxModeReply, error) { - out := new(SwInterfaceSetRxModeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterfaceSetRxPlacement) (*SwInterfaceSetRxPlacementReply, error) { - out := new(SwInterfaceSetRxPlacementReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTable) (*SwInterfaceSetTableReply, error) { - out := new(SwInterfaceSetTableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) { - out := new(SwInterfaceSetUnnumberedReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) { - out := new(SwInterfaceTagAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) { - out := new(WantInterfaceEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ip/ip.ba.go b/plugins/vpp/binapi/vpp2001/ip/ip.ba.go deleted file mode 100644 index df4e820d19..0000000000 --- a/plugins/vpp/binapi/vpp2001/ip/ip.ba.go +++ /dev/null @@ -1,1528 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ip.api.json - -/* -Package ip is a generated VPP binary API for 'ip' module. - -It consists of: - 15 enums - 7 aliases - 14 types - 1 union - 60 messages - 30 services -*/ -package ip - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - fib_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ip" - // APIVersion is the API version of this module. - APIVersion = "3.0.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0xfc3fea46 -) - -type AddressFamily = ip_types.AddressFamily - -type FibPathFlags = fib_types.FibPathFlags - -type FibPathNhProto = fib_types.FibPathNhProto - -type FibPathType = fib_types.FibPathType - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -// IPReassType represents VPP binary API enum 'ip_reass_type'. -type IPReassType uint32 - -const ( - IP_REASS_TYPE_FULL IPReassType = 0 - IP_REASS_TYPE_SHALLOW_VIRTUAL IPReassType = 1 -) - -var IPReassType_name = map[uint32]string{ - 0: "IP_REASS_TYPE_FULL", - 1: "IP_REASS_TYPE_SHALLOW_VIRTUAL", -} - -var IPReassType_value = map[string]uint32{ - "IP_REASS_TYPE_FULL": 0, - "IP_REASS_TYPE_SHALLOW_VIRTUAL": 1, -} - -func (x IPReassType) String() string { - s, ok := IPReassType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type LinkDuplex = interface_types.LinkDuplex - -// MfibItfFlags represents VPP binary API enum 'mfib_itf_flags'. -type MfibItfFlags uint32 - -const ( - MFIB_API_ITF_FLAG_NONE MfibItfFlags = 0 - MFIB_API_ITF_FLAG_NEGATE_SIGNAL MfibItfFlags = 1 - MFIB_API_ITF_FLAG_ACCEPT MfibItfFlags = 2 - MFIB_API_ITF_FLAG_FORWARD MfibItfFlags = 4 - MFIB_API_ITF_FLAG_SIGNAL_PRESENT MfibItfFlags = 8 - MFIB_API_ITF_FLAG_DONT_PRESERVE MfibItfFlags = 16 -) - -var MfibItfFlags_name = map[uint32]string{ - 0: "MFIB_API_ITF_FLAG_NONE", - 1: "MFIB_API_ITF_FLAG_NEGATE_SIGNAL", - 2: "MFIB_API_ITF_FLAG_ACCEPT", - 4: "MFIB_API_ITF_FLAG_FORWARD", - 8: "MFIB_API_ITF_FLAG_SIGNAL_PRESENT", - 16: "MFIB_API_ITF_FLAG_DONT_PRESERVE", -} - -var MfibItfFlags_value = map[string]uint32{ - "MFIB_API_ITF_FLAG_NONE": 0, - "MFIB_API_ITF_FLAG_NEGATE_SIGNAL": 1, - "MFIB_API_ITF_FLAG_ACCEPT": 2, - "MFIB_API_ITF_FLAG_FORWARD": 4, - "MFIB_API_ITF_FLAG_SIGNAL_PRESENT": 8, - "MFIB_API_ITF_FLAG_DONT_PRESERVE": 16, -} - -func (x MfibItfFlags) String() string { - s, ok := MfibItfFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type MacAddress = ethernet_types.MacAddress - -type Address = ip_types.Address - -type FibMplsLabel = fib_types.FibMplsLabel - -type FibPath = fib_types.FibPath - -type FibPathNh = fib_types.FibPathNh - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -// IPMroute represents VPP binary API type 'ip_mroute'. -type IPMroute struct { - TableID uint32 - EntryFlags uint32 - RpfID uint32 - Prefix Mprefix - NPaths uint8 `struc:"sizeof=Paths"` - Paths []MfibPath -} - -func (*IPMroute) GetTypeName() string { return "ip_mroute" } - -// IPRoute represents VPP binary API type 'ip_route'. -type IPRoute struct { - TableID uint32 - StatsIndex uint32 - Prefix Prefix - NPaths uint8 `struc:"sizeof=Paths"` - Paths []FibPath -} - -func (*IPRoute) GetTypeName() string { return "ip_route" } - -// IPTable represents VPP binary API type 'ip_table'. -type IPTable struct { - TableID uint32 - IsIP6 bool - Name string `struc:"[64]byte"` -} - -func (*IPTable) GetTypeName() string { return "ip_table" } - -// MfibPath represents VPP binary API type 'mfib_path'. -type MfibPath struct { - ItfFlags MfibItfFlags - Path FibPath -} - -func (*MfibPath) GetTypeName() string { return "mfib_path" } - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -// PuntRedirect represents VPP binary API type 'punt_redirect'. -type PuntRedirect struct { - RxSwIfIndex InterfaceIndex - TxSwIfIndex InterfaceIndex - Nh Address -} - -func (*PuntRedirect) GetTypeName() string { return "punt_redirect" } - -type AddressUnion = ip_types.AddressUnion - -// IoamDisable represents VPP binary API message 'ioam_disable'. -type IoamDisable struct { - ID uint16 -} - -func (m *IoamDisable) Reset() { *m = IoamDisable{} } -func (*IoamDisable) GetMessageName() string { return "ioam_disable" } -func (*IoamDisable) GetCrcString() string { return "6b16a45e" } -func (*IoamDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// IoamDisableReply represents VPP binary API message 'ioam_disable_reply'. -type IoamDisableReply struct { - Retval int32 -} - -func (m *IoamDisableReply) Reset() { *m = IoamDisableReply{} } -func (*IoamDisableReply) GetMessageName() string { return "ioam_disable_reply" } -func (*IoamDisableReply) GetCrcString() string { return "e8d4e804" } -func (*IoamDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IoamEnable represents VPP binary API message 'ioam_enable'. -type IoamEnable struct { - ID uint16 - Seqno bool - Analyse bool - PotEnable bool - TraceEnable bool - NodeID uint32 -} - -func (m *IoamEnable) Reset() { *m = IoamEnable{} } -func (*IoamEnable) GetMessageName() string { return "ioam_enable" } -func (*IoamEnable) GetCrcString() string { return "51ccd868" } -func (*IoamEnable) GetMessageType() api.MessageType { return api.RequestMessage } - -// IoamEnableReply represents VPP binary API message 'ioam_enable_reply'. -type IoamEnableReply struct { - Retval int32 -} - -func (m *IoamEnableReply) Reset() { *m = IoamEnableReply{} } -func (*IoamEnableReply) GetMessageName() string { return "ioam_enable_reply" } -func (*IoamEnableReply) GetCrcString() string { return "e8d4e804" } -func (*IoamEnableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPAddressDetails represents VPP binary API message 'ip_address_details'. -type IPAddressDetails struct { - SwIfIndex InterfaceIndex - Prefix AddressWithPrefix -} - -func (m *IPAddressDetails) Reset() { *m = IPAddressDetails{} } -func (*IPAddressDetails) GetMessageName() string { return "ip_address_details" } -func (*IPAddressDetails) GetCrcString() string { return "b1199745" } -func (*IPAddressDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPAddressDump represents VPP binary API message 'ip_address_dump'. -type IPAddressDump struct { - SwIfIndex InterfaceIndex - IsIPv6 bool -} - -func (m *IPAddressDump) Reset() { *m = IPAddressDump{} } -func (*IPAddressDump) GetMessageName() string { return "ip_address_dump" } -func (*IPAddressDump) GetCrcString() string { return "2d033de4" } -func (*IPAddressDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPContainerProxyAddDel represents VPP binary API message 'ip_container_proxy_add_del'. -type IPContainerProxyAddDel struct { - Pfx Prefix - SwIfIndex InterfaceIndex - IsAdd bool -} - -func (m *IPContainerProxyAddDel) Reset() { *m = IPContainerProxyAddDel{} } -func (*IPContainerProxyAddDel) GetMessageName() string { return "ip_container_proxy_add_del" } -func (*IPContainerProxyAddDel) GetCrcString() string { return "91189f40" } -func (*IPContainerProxyAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPContainerProxyAddDelReply represents VPP binary API message 'ip_container_proxy_add_del_reply'. -type IPContainerProxyAddDelReply struct { - Retval int32 -} - -func (m *IPContainerProxyAddDelReply) Reset() { *m = IPContainerProxyAddDelReply{} } -func (*IPContainerProxyAddDelReply) GetMessageName() string { - return "ip_container_proxy_add_del_reply" -} -func (*IPContainerProxyAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IPContainerProxyAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPContainerProxyDetails represents VPP binary API message 'ip_container_proxy_details'. -type IPContainerProxyDetails struct { - SwIfIndex InterfaceIndex - Prefix Prefix -} - -func (m *IPContainerProxyDetails) Reset() { *m = IPContainerProxyDetails{} } -func (*IPContainerProxyDetails) GetMessageName() string { return "ip_container_proxy_details" } -func (*IPContainerProxyDetails) GetCrcString() string { return "0ee460e8" } -func (*IPContainerProxyDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPContainerProxyDump represents VPP binary API message 'ip_container_proxy_dump'. -type IPContainerProxyDump struct{} - -func (m *IPContainerProxyDump) Reset() { *m = IPContainerProxyDump{} } -func (*IPContainerProxyDump) GetMessageName() string { return "ip_container_proxy_dump" } -func (*IPContainerProxyDump) GetCrcString() string { return "51077d14" } -func (*IPContainerProxyDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPDetails represents VPP binary API message 'ip_details'. -type IPDetails struct { - SwIfIndex InterfaceIndex - IsIPv6 bool -} - -func (m *IPDetails) Reset() { *m = IPDetails{} } -func (*IPDetails) GetMessageName() string { return "ip_details" } -func (*IPDetails) GetCrcString() string { return "eb152d07" } -func (*IPDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPDump represents VPP binary API message 'ip_dump'. -type IPDump struct { - IsIPv6 bool -} - -func (m *IPDump) Reset() { *m = IPDump{} } -func (*IPDump) GetMessageName() string { return "ip_dump" } -func (*IPDump) GetCrcString() string { return "98d231ca" } -func (*IPDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPMrouteAddDel represents VPP binary API message 'ip_mroute_add_del'. -type IPMrouteAddDel struct { - IsAdd bool - IsMultipath bool - Route IPMroute -} - -func (m *IPMrouteAddDel) Reset() { *m = IPMrouteAddDel{} } -func (*IPMrouteAddDel) GetMessageName() string { return "ip_mroute_add_del" } -func (*IPMrouteAddDel) GetCrcString() string { return "f6627d17" } -func (*IPMrouteAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPMrouteAddDelReply represents VPP binary API message 'ip_mroute_add_del_reply'. -type IPMrouteAddDelReply struct { - Retval int32 - StatsIndex uint32 -} - -func (m *IPMrouteAddDelReply) Reset() { *m = IPMrouteAddDelReply{} } -func (*IPMrouteAddDelReply) GetMessageName() string { return "ip_mroute_add_del_reply" } -func (*IPMrouteAddDelReply) GetCrcString() string { return "1992deab" } -func (*IPMrouteAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPMrouteDetails represents VPP binary API message 'ip_mroute_details'. -type IPMrouteDetails struct { - Route IPMroute -} - -func (m *IPMrouteDetails) Reset() { *m = IPMrouteDetails{} } -func (*IPMrouteDetails) GetMessageName() string { return "ip_mroute_details" } -func (*IPMrouteDetails) GetCrcString() string { return "c1cb4b44" } -func (*IPMrouteDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPMrouteDump represents VPP binary API message 'ip_mroute_dump'. -type IPMrouteDump struct { - Table IPTable -} - -func (m *IPMrouteDump) Reset() { *m = IPMrouteDump{} } -func (*IPMrouteDump) GetMessageName() string { return "ip_mroute_dump" } -func (*IPMrouteDump) GetCrcString() string { return "b9d2e09e" } -func (*IPMrouteDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPMtableDetails represents VPP binary API message 'ip_mtable_details'. -type IPMtableDetails struct { - Table IPTable -} - -func (m *IPMtableDetails) Reset() { *m = IPMtableDetails{} } -func (*IPMtableDetails) GetMessageName() string { return "ip_mtable_details" } -func (*IPMtableDetails) GetCrcString() string { return "b9d2e09e" } -func (*IPMtableDetails) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPMtableDump represents VPP binary API message 'ip_mtable_dump'. -type IPMtableDump struct{} - -func (m *IPMtableDump) Reset() { *m = IPMtableDump{} } -func (*IPMtableDump) GetMessageName() string { return "ip_mtable_dump" } -func (*IPMtableDump) GetCrcString() string { return "51077d14" } -func (*IPMtableDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPPuntPolice represents VPP binary API message 'ip_punt_police'. -type IPPuntPolice struct { - PolicerIndex uint32 - IsAdd bool - IsIP6 bool -} - -func (m *IPPuntPolice) Reset() { *m = IPPuntPolice{} } -func (*IPPuntPolice) GetMessageName() string { return "ip_punt_police" } -func (*IPPuntPolice) GetCrcString() string { return "db867cea" } -func (*IPPuntPolice) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPPuntPoliceReply represents VPP binary API message 'ip_punt_police_reply'. -type IPPuntPoliceReply struct { - Retval int32 -} - -func (m *IPPuntPoliceReply) Reset() { *m = IPPuntPoliceReply{} } -func (*IPPuntPoliceReply) GetMessageName() string { return "ip_punt_police_reply" } -func (*IPPuntPoliceReply) GetCrcString() string { return "e8d4e804" } -func (*IPPuntPoliceReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPPuntRedirect represents VPP binary API message 'ip_punt_redirect'. -type IPPuntRedirect struct { - Punt PuntRedirect - IsAdd bool -} - -func (m *IPPuntRedirect) Reset() { *m = IPPuntRedirect{} } -func (*IPPuntRedirect) GetMessageName() string { return "ip_punt_redirect" } -func (*IPPuntRedirect) GetCrcString() string { return "a9a5592c" } -func (*IPPuntRedirect) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPPuntRedirectDetails represents VPP binary API message 'ip_punt_redirect_details'. -type IPPuntRedirectDetails struct { - Punt PuntRedirect -} - -func (m *IPPuntRedirectDetails) Reset() { *m = IPPuntRedirectDetails{} } -func (*IPPuntRedirectDetails) GetMessageName() string { return "ip_punt_redirect_details" } -func (*IPPuntRedirectDetails) GetCrcString() string { return "3924f5d3" } -func (*IPPuntRedirectDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPPuntRedirectDump represents VPP binary API message 'ip_punt_redirect_dump'. -type IPPuntRedirectDump struct { - SwIfIndex InterfaceIndex - IsIPv6 bool -} - -func (m *IPPuntRedirectDump) Reset() { *m = IPPuntRedirectDump{} } -func (*IPPuntRedirectDump) GetMessageName() string { return "ip_punt_redirect_dump" } -func (*IPPuntRedirectDump) GetCrcString() string { return "2d033de4" } -func (*IPPuntRedirectDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPPuntRedirectReply represents VPP binary API message 'ip_punt_redirect_reply'. -type IPPuntRedirectReply struct { - Retval int32 -} - -func (m *IPPuntRedirectReply) Reset() { *m = IPPuntRedirectReply{} } -func (*IPPuntRedirectReply) GetMessageName() string { return "ip_punt_redirect_reply" } -func (*IPPuntRedirectReply) GetCrcString() string { return "e8d4e804" } -func (*IPPuntRedirectReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPReassemblyEnableDisable represents VPP binary API message 'ip_reassembly_enable_disable'. -type IPReassemblyEnableDisable struct { - SwIfIndex InterfaceIndex - EnableIP4 bool - EnableIP6 bool - Type IPReassType -} - -func (m *IPReassemblyEnableDisable) Reset() { *m = IPReassemblyEnableDisable{} } -func (*IPReassemblyEnableDisable) GetMessageName() string { return "ip_reassembly_enable_disable" } -func (*IPReassemblyEnableDisable) GetCrcString() string { return "885c85a6" } -func (*IPReassemblyEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPReassemblyEnableDisableReply represents VPP binary API message 'ip_reassembly_enable_disable_reply'. -type IPReassemblyEnableDisableReply struct { - Retval int32 -} - -func (m *IPReassemblyEnableDisableReply) Reset() { *m = IPReassemblyEnableDisableReply{} } -func (*IPReassemblyEnableDisableReply) GetMessageName() string { - return "ip_reassembly_enable_disable_reply" -} -func (*IPReassemblyEnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*IPReassemblyEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPReassemblyGet represents VPP binary API message 'ip_reassembly_get'. -type IPReassemblyGet struct { - IsIP6 bool - Type IPReassType -} - -func (m *IPReassemblyGet) Reset() { *m = IPReassemblyGet{} } -func (*IPReassemblyGet) GetMessageName() string { return "ip_reassembly_get" } -func (*IPReassemblyGet) GetCrcString() string { return "ea13ff63" } -func (*IPReassemblyGet) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPReassemblyGetReply represents VPP binary API message 'ip_reassembly_get_reply'. -type IPReassemblyGetReply struct { - Retval int32 - TimeoutMs uint32 - MaxReassemblies uint32 - MaxReassemblyLength uint32 - ExpireWalkIntervalMs uint32 - IsIP6 bool -} - -func (m *IPReassemblyGetReply) Reset() { *m = IPReassemblyGetReply{} } -func (*IPReassemblyGetReply) GetMessageName() string { return "ip_reassembly_get_reply" } -func (*IPReassemblyGetReply) GetCrcString() string { return "d5eb8d34" } -func (*IPReassemblyGetReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPReassemblySet represents VPP binary API message 'ip_reassembly_set'. -type IPReassemblySet struct { - TimeoutMs uint32 - MaxReassemblies uint32 - MaxReassemblyLength uint32 - ExpireWalkIntervalMs uint32 - IsIP6 bool - Type IPReassType -} - -func (m *IPReassemblySet) Reset() { *m = IPReassemblySet{} } -func (*IPReassemblySet) GetMessageName() string { return "ip_reassembly_set" } -func (*IPReassemblySet) GetCrcString() string { return "16467d25" } -func (*IPReassemblySet) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPReassemblySetReply represents VPP binary API message 'ip_reassembly_set_reply'. -type IPReassemblySetReply struct { - Retval int32 -} - -func (m *IPReassemblySetReply) Reset() { *m = IPReassemblySetReply{} } -func (*IPReassemblySetReply) GetMessageName() string { return "ip_reassembly_set_reply" } -func (*IPReassemblySetReply) GetCrcString() string { return "e8d4e804" } -func (*IPReassemblySetReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPRouteAddDel represents VPP binary API message 'ip_route_add_del'. -type IPRouteAddDel struct { - IsAdd bool - IsMultipath bool - Route IPRoute -} - -func (m *IPRouteAddDel) Reset() { *m = IPRouteAddDel{} } -func (*IPRouteAddDel) GetMessageName() string { return "ip_route_add_del" } -func (*IPRouteAddDel) GetCrcString() string { return "c1ff832d" } -func (*IPRouteAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPRouteAddDelReply represents VPP binary API message 'ip_route_add_del_reply'. -type IPRouteAddDelReply struct { - Retval int32 - StatsIndex uint32 -} - -func (m *IPRouteAddDelReply) Reset() { *m = IPRouteAddDelReply{} } -func (*IPRouteAddDelReply) GetMessageName() string { return "ip_route_add_del_reply" } -func (*IPRouteAddDelReply) GetCrcString() string { return "1992deab" } -func (*IPRouteAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPRouteDetails represents VPP binary API message 'ip_route_details'. -type IPRouteDetails struct { - Route IPRoute -} - -func (m *IPRouteDetails) Reset() { *m = IPRouteDetails{} } -func (*IPRouteDetails) GetMessageName() string { return "ip_route_details" } -func (*IPRouteDetails) GetCrcString() string { return "d1ffaae1" } -func (*IPRouteDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPRouteDump represents VPP binary API message 'ip_route_dump'. -type IPRouteDump struct { - Table IPTable -} - -func (m *IPRouteDump) Reset() { *m = IPRouteDump{} } -func (*IPRouteDump) GetMessageName() string { return "ip_route_dump" } -func (*IPRouteDump) GetCrcString() string { return "b9d2e09e" } -func (*IPRouteDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPSourceAndPortRangeCheckAddDel represents VPP binary API message 'ip_source_and_port_range_check_add_del'. -type IPSourceAndPortRangeCheckAddDel struct { - IsAdd bool - Prefix Prefix - NumberOfRanges uint8 - LowPorts []uint16 `struc:"[32]uint16"` - HighPorts []uint16 `struc:"[32]uint16"` - VrfID uint32 -} - -func (m *IPSourceAndPortRangeCheckAddDel) Reset() { *m = IPSourceAndPortRangeCheckAddDel{} } -func (*IPSourceAndPortRangeCheckAddDel) GetMessageName() string { - return "ip_source_and_port_range_check_add_del" -} -func (*IPSourceAndPortRangeCheckAddDel) GetCrcString() string { return "8bfc76f2" } -func (*IPSourceAndPortRangeCheckAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPSourceAndPortRangeCheckAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_add_del_reply'. -type IPSourceAndPortRangeCheckAddDelReply struct { - Retval int32 -} - -func (m *IPSourceAndPortRangeCheckAddDelReply) Reset() { *m = IPSourceAndPortRangeCheckAddDelReply{} } -func (*IPSourceAndPortRangeCheckAddDelReply) GetMessageName() string { - return "ip_source_and_port_range_check_add_del_reply" -} -func (*IPSourceAndPortRangeCheckAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IPSourceAndPortRangeCheckAddDelReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// IPSourceAndPortRangeCheckInterfaceAddDel represents VPP binary API message 'ip_source_and_port_range_check_interface_add_del'. -type IPSourceAndPortRangeCheckInterfaceAddDel struct { - IsAdd bool - SwIfIndex InterfaceIndex - TCPInVrfID uint32 - TCPOutVrfID uint32 - UDPInVrfID uint32 - UDPOutVrfID uint32 -} - -func (m *IPSourceAndPortRangeCheckInterfaceAddDel) Reset() { - *m = IPSourceAndPortRangeCheckInterfaceAddDel{} -} -func (*IPSourceAndPortRangeCheckInterfaceAddDel) GetMessageName() string { - return "ip_source_and_port_range_check_interface_add_del" -} -func (*IPSourceAndPortRangeCheckInterfaceAddDel) GetCrcString() string { return "e1ba8987" } -func (*IPSourceAndPortRangeCheckInterfaceAddDel) GetMessageType() api.MessageType { - return api.RequestMessage -} - -// IPSourceAndPortRangeCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_and_port_range_check_interface_add_del_reply'. -type IPSourceAndPortRangeCheckInterfaceAddDelReply struct { - Retval int32 -} - -func (m *IPSourceAndPortRangeCheckInterfaceAddDelReply) Reset() { - *m = IPSourceAndPortRangeCheckInterfaceAddDelReply{} -} -func (*IPSourceAndPortRangeCheckInterfaceAddDelReply) GetMessageName() string { - return "ip_source_and_port_range_check_interface_add_del_reply" -} -func (*IPSourceAndPortRangeCheckInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IPSourceAndPortRangeCheckInterfaceAddDelReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// IPSourceCheckInterfaceAddDel represents VPP binary API message 'ip_source_check_interface_add_del'. -type IPSourceCheckInterfaceAddDel struct { - IsAdd bool - Loose bool - SwIfIndex InterfaceIndex -} - -func (m *IPSourceCheckInterfaceAddDel) Reset() { *m = IPSourceCheckInterfaceAddDel{} } -func (*IPSourceCheckInterfaceAddDel) GetMessageName() string { - return "ip_source_check_interface_add_del" -} -func (*IPSourceCheckInterfaceAddDel) GetCrcString() string { return "6612356b" } -func (*IPSourceCheckInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPSourceCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_check_interface_add_del_reply'. -type IPSourceCheckInterfaceAddDelReply struct { - Retval int32 -} - -func (m *IPSourceCheckInterfaceAddDelReply) Reset() { *m = IPSourceCheckInterfaceAddDelReply{} } -func (*IPSourceCheckInterfaceAddDelReply) GetMessageName() string { - return "ip_source_check_interface_add_del_reply" -} -func (*IPSourceCheckInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IPSourceCheckInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPTableAddDel represents VPP binary API message 'ip_table_add_del'. -type IPTableAddDel struct { - IsAdd bool - Table IPTable -} - -func (m *IPTableAddDel) Reset() { *m = IPTableAddDel{} } -func (*IPTableAddDel) GetMessageName() string { return "ip_table_add_del" } -func (*IPTableAddDel) GetCrcString() string { return "0ffdaec0" } -func (*IPTableAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPTableAddDelReply represents VPP binary API message 'ip_table_add_del_reply'. -type IPTableAddDelReply struct { - Retval int32 -} - -func (m *IPTableAddDelReply) Reset() { *m = IPTableAddDelReply{} } -func (*IPTableAddDelReply) GetMessageName() string { return "ip_table_add_del_reply" } -func (*IPTableAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IPTableAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPTableDetails represents VPP binary API message 'ip_table_details'. -type IPTableDetails struct { - Table IPTable -} - -func (m *IPTableDetails) Reset() { *m = IPTableDetails{} } -func (*IPTableDetails) GetMessageName() string { return "ip_table_details" } -func (*IPTableDetails) GetCrcString() string { return "c79fca0f" } -func (*IPTableDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPTableDump represents VPP binary API message 'ip_table_dump'. -type IPTableDump struct{} - -func (m *IPTableDump) Reset() { *m = IPTableDump{} } -func (*IPTableDump) GetMessageName() string { return "ip_table_dump" } -func (*IPTableDump) GetCrcString() string { return "51077d14" } -func (*IPTableDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPTableFlush represents VPP binary API message 'ip_table_flush'. -type IPTableFlush struct { - Table IPTable -} - -func (m *IPTableFlush) Reset() { *m = IPTableFlush{} } -func (*IPTableFlush) GetMessageName() string { return "ip_table_flush" } -func (*IPTableFlush) GetCrcString() string { return "b9d2e09e" } -func (*IPTableFlush) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPTableFlushReply represents VPP binary API message 'ip_table_flush_reply'. -type IPTableFlushReply struct { - Retval int32 -} - -func (m *IPTableFlushReply) Reset() { *m = IPTableFlushReply{} } -func (*IPTableFlushReply) GetMessageName() string { return "ip_table_flush_reply" } -func (*IPTableFlushReply) GetCrcString() string { return "e8d4e804" } -func (*IPTableFlushReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPTableReplaceBegin represents VPP binary API message 'ip_table_replace_begin'. -type IPTableReplaceBegin struct { - Table IPTable -} - -func (m *IPTableReplaceBegin) Reset() { *m = IPTableReplaceBegin{} } -func (*IPTableReplaceBegin) GetMessageName() string { return "ip_table_replace_begin" } -func (*IPTableReplaceBegin) GetCrcString() string { return "b9d2e09e" } -func (*IPTableReplaceBegin) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPTableReplaceBeginReply represents VPP binary API message 'ip_table_replace_begin_reply'. -type IPTableReplaceBeginReply struct { - Retval int32 -} - -func (m *IPTableReplaceBeginReply) Reset() { *m = IPTableReplaceBeginReply{} } -func (*IPTableReplaceBeginReply) GetMessageName() string { return "ip_table_replace_begin_reply" } -func (*IPTableReplaceBeginReply) GetCrcString() string { return "e8d4e804" } -func (*IPTableReplaceBeginReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPTableReplaceEnd represents VPP binary API message 'ip_table_replace_end'. -type IPTableReplaceEnd struct { - Table IPTable -} - -func (m *IPTableReplaceEnd) Reset() { *m = IPTableReplaceEnd{} } -func (*IPTableReplaceEnd) GetMessageName() string { return "ip_table_replace_end" } -func (*IPTableReplaceEnd) GetCrcString() string { return "b9d2e09e" } -func (*IPTableReplaceEnd) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPTableReplaceEndReply represents VPP binary API message 'ip_table_replace_end_reply'. -type IPTableReplaceEndReply struct { - Retval int32 -} - -func (m *IPTableReplaceEndReply) Reset() { *m = IPTableReplaceEndReply{} } -func (*IPTableReplaceEndReply) GetMessageName() string { return "ip_table_replace_end_reply" } -func (*IPTableReplaceEndReply) GetCrcString() string { return "e8d4e804" } -func (*IPTableReplaceEndReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPUnnumberedDetails represents VPP binary API message 'ip_unnumbered_details'. -type IPUnnumberedDetails struct { - SwIfIndex InterfaceIndex - IPSwIfIndex InterfaceIndex -} - -func (m *IPUnnumberedDetails) Reset() { *m = IPUnnumberedDetails{} } -func (*IPUnnumberedDetails) GetMessageName() string { return "ip_unnumbered_details" } -func (*IPUnnumberedDetails) GetCrcString() string { return "aa12a483" } -func (*IPUnnumberedDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPUnnumberedDump represents VPP binary API message 'ip_unnumbered_dump'. -type IPUnnumberedDump struct { - SwIfIndex InterfaceIndex -} - -func (m *IPUnnumberedDump) Reset() { *m = IPUnnumberedDump{} } -func (*IPUnnumberedDump) GetMessageName() string { return "ip_unnumbered_dump" } -func (*IPUnnumberedDump) GetCrcString() string { return "f9e6675e" } -func (*IPUnnumberedDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// MfibSignalDetails represents VPP binary API message 'mfib_signal_details'. -type MfibSignalDetails struct { - SwIfIndex InterfaceIndex - TableID uint32 - Prefix Mprefix - IPPacketLen uint16 - IPPacketData []byte `struc:"[256]byte"` -} - -func (m *MfibSignalDetails) Reset() { *m = MfibSignalDetails{} } -func (*MfibSignalDetails) GetMessageName() string { return "mfib_signal_details" } -func (*MfibSignalDetails) GetCrcString() string { return "64398a9a" } -func (*MfibSignalDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MfibSignalDump represents VPP binary API message 'mfib_signal_dump'. -type MfibSignalDump struct{} - -func (m *MfibSignalDump) Reset() { *m = MfibSignalDump{} } -func (*MfibSignalDump) GetMessageName() string { return "mfib_signal_dump" } -func (*MfibSignalDump) GetCrcString() string { return "51077d14" } -func (*MfibSignalDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SetIPFlowHash represents VPP binary API message 'set_ip_flow_hash'. -type SetIPFlowHash struct { - VrfID uint32 - IsIPv6 bool - Src bool - Dst bool - Sport bool - Dport bool - Proto bool - Reverse bool - Symmetric bool -} - -func (m *SetIPFlowHash) Reset() { *m = SetIPFlowHash{} } -func (*SetIPFlowHash) GetMessageName() string { return "set_ip_flow_hash" } -func (*SetIPFlowHash) GetCrcString() string { return "084ee09e" } -func (*SetIPFlowHash) GetMessageType() api.MessageType { return api.RequestMessage } - -// SetIPFlowHashReply represents VPP binary API message 'set_ip_flow_hash_reply'. -type SetIPFlowHashReply struct { - Retval int32 -} - -func (m *SetIPFlowHashReply) Reset() { *m = SetIPFlowHashReply{} } -func (*SetIPFlowHashReply) GetMessageName() string { return "set_ip_flow_hash_reply" } -func (*SetIPFlowHashReply) GetCrcString() string { return "e8d4e804" } -func (*SetIPFlowHashReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceIP6EnableDisable represents VPP binary API message 'sw_interface_ip6_enable_disable'. -type SwInterfaceIP6EnableDisable struct { - SwIfIndex InterfaceIndex - Enable bool -} - -func (m *SwInterfaceIP6EnableDisable) Reset() { *m = SwInterfaceIP6EnableDisable{} } -func (*SwInterfaceIP6EnableDisable) GetMessageName() string { return "sw_interface_ip6_enable_disable" } -func (*SwInterfaceIP6EnableDisable) GetCrcString() string { return "ae6cfcfb" } -func (*SwInterfaceIP6EnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceIP6EnableDisableReply represents VPP binary API message 'sw_interface_ip6_enable_disable_reply'. -type SwInterfaceIP6EnableDisableReply struct { - Retval int32 -} - -func (m *SwInterfaceIP6EnableDisableReply) Reset() { *m = SwInterfaceIP6EnableDisableReply{} } -func (*SwInterfaceIP6EnableDisableReply) GetMessageName() string { - return "sw_interface_ip6_enable_disable_reply" -} -func (*SwInterfaceIP6EnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceIP6EnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceIP6SetLinkLocalAddress represents VPP binary API message 'sw_interface_ip6_set_link_local_address'. -type SwInterfaceIP6SetLinkLocalAddress struct { - SwIfIndex InterfaceIndex - IP IP6Address -} - -func (m *SwInterfaceIP6SetLinkLocalAddress) Reset() { *m = SwInterfaceIP6SetLinkLocalAddress{} } -func (*SwInterfaceIP6SetLinkLocalAddress) GetMessageName() string { - return "sw_interface_ip6_set_link_local_address" -} -func (*SwInterfaceIP6SetLinkLocalAddress) GetCrcString() string { return "2931d9fa" } -func (*SwInterfaceIP6SetLinkLocalAddress) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceIP6SetLinkLocalAddressReply represents VPP binary API message 'sw_interface_ip6_set_link_local_address_reply'. -type SwInterfaceIP6SetLinkLocalAddressReply struct { - Retval int32 -} - -func (m *SwInterfaceIP6SetLinkLocalAddressReply) Reset() { - *m = SwInterfaceIP6SetLinkLocalAddressReply{} -} -func (*SwInterfaceIP6SetLinkLocalAddressReply) GetMessageName() string { - return "sw_interface_ip6_set_link_local_address_reply" -} -func (*SwInterfaceIP6SetLinkLocalAddressReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceIP6SetLinkLocalAddressReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -func init() { - api.RegisterMessage((*IoamDisable)(nil), "ip.IoamDisable") - api.RegisterMessage((*IoamDisableReply)(nil), "ip.IoamDisableReply") - api.RegisterMessage((*IoamEnable)(nil), "ip.IoamEnable") - api.RegisterMessage((*IoamEnableReply)(nil), "ip.IoamEnableReply") - api.RegisterMessage((*IPAddressDetails)(nil), "ip.IPAddressDetails") - api.RegisterMessage((*IPAddressDump)(nil), "ip.IPAddressDump") - api.RegisterMessage((*IPContainerProxyAddDel)(nil), "ip.IPContainerProxyAddDel") - api.RegisterMessage((*IPContainerProxyAddDelReply)(nil), "ip.IPContainerProxyAddDelReply") - api.RegisterMessage((*IPContainerProxyDetails)(nil), "ip.IPContainerProxyDetails") - api.RegisterMessage((*IPContainerProxyDump)(nil), "ip.IPContainerProxyDump") - api.RegisterMessage((*IPDetails)(nil), "ip.IPDetails") - api.RegisterMessage((*IPDump)(nil), "ip.IPDump") - api.RegisterMessage((*IPMrouteAddDel)(nil), "ip.IPMrouteAddDel") - api.RegisterMessage((*IPMrouteAddDelReply)(nil), "ip.IPMrouteAddDelReply") - api.RegisterMessage((*IPMrouteDetails)(nil), "ip.IPMrouteDetails") - api.RegisterMessage((*IPMrouteDump)(nil), "ip.IPMrouteDump") - api.RegisterMessage((*IPMtableDetails)(nil), "ip.IPMtableDetails") - api.RegisterMessage((*IPMtableDump)(nil), "ip.IPMtableDump") - api.RegisterMessage((*IPPuntPolice)(nil), "ip.IPPuntPolice") - api.RegisterMessage((*IPPuntPoliceReply)(nil), "ip.IPPuntPoliceReply") - api.RegisterMessage((*IPPuntRedirect)(nil), "ip.IPPuntRedirect") - api.RegisterMessage((*IPPuntRedirectDetails)(nil), "ip.IPPuntRedirectDetails") - api.RegisterMessage((*IPPuntRedirectDump)(nil), "ip.IPPuntRedirectDump") - api.RegisterMessage((*IPPuntRedirectReply)(nil), "ip.IPPuntRedirectReply") - api.RegisterMessage((*IPReassemblyEnableDisable)(nil), "ip.IPReassemblyEnableDisable") - api.RegisterMessage((*IPReassemblyEnableDisableReply)(nil), "ip.IPReassemblyEnableDisableReply") - api.RegisterMessage((*IPReassemblyGet)(nil), "ip.IPReassemblyGet") - api.RegisterMessage((*IPReassemblyGetReply)(nil), "ip.IPReassemblyGetReply") - api.RegisterMessage((*IPReassemblySet)(nil), "ip.IPReassemblySet") - api.RegisterMessage((*IPReassemblySetReply)(nil), "ip.IPReassemblySetReply") - api.RegisterMessage((*IPRouteAddDel)(nil), "ip.IPRouteAddDel") - api.RegisterMessage((*IPRouteAddDelReply)(nil), "ip.IPRouteAddDelReply") - api.RegisterMessage((*IPRouteDetails)(nil), "ip.IPRouteDetails") - api.RegisterMessage((*IPRouteDump)(nil), "ip.IPRouteDump") - api.RegisterMessage((*IPSourceAndPortRangeCheckAddDel)(nil), "ip.IPSourceAndPortRangeCheckAddDel") - api.RegisterMessage((*IPSourceAndPortRangeCheckAddDelReply)(nil), "ip.IPSourceAndPortRangeCheckAddDelReply") - api.RegisterMessage((*IPSourceAndPortRangeCheckInterfaceAddDel)(nil), "ip.IPSourceAndPortRangeCheckInterfaceAddDel") - api.RegisterMessage((*IPSourceAndPortRangeCheckInterfaceAddDelReply)(nil), "ip.IPSourceAndPortRangeCheckInterfaceAddDelReply") - api.RegisterMessage((*IPSourceCheckInterfaceAddDel)(nil), "ip.IPSourceCheckInterfaceAddDel") - api.RegisterMessage((*IPSourceCheckInterfaceAddDelReply)(nil), "ip.IPSourceCheckInterfaceAddDelReply") - api.RegisterMessage((*IPTableAddDel)(nil), "ip.IPTableAddDel") - api.RegisterMessage((*IPTableAddDelReply)(nil), "ip.IPTableAddDelReply") - api.RegisterMessage((*IPTableDetails)(nil), "ip.IPTableDetails") - api.RegisterMessage((*IPTableDump)(nil), "ip.IPTableDump") - api.RegisterMessage((*IPTableFlush)(nil), "ip.IPTableFlush") - api.RegisterMessage((*IPTableFlushReply)(nil), "ip.IPTableFlushReply") - api.RegisterMessage((*IPTableReplaceBegin)(nil), "ip.IPTableReplaceBegin") - api.RegisterMessage((*IPTableReplaceBeginReply)(nil), "ip.IPTableReplaceBeginReply") - api.RegisterMessage((*IPTableReplaceEnd)(nil), "ip.IPTableReplaceEnd") - api.RegisterMessage((*IPTableReplaceEndReply)(nil), "ip.IPTableReplaceEndReply") - api.RegisterMessage((*IPUnnumberedDetails)(nil), "ip.IPUnnumberedDetails") - api.RegisterMessage((*IPUnnumberedDump)(nil), "ip.IPUnnumberedDump") - api.RegisterMessage((*MfibSignalDetails)(nil), "ip.MfibSignalDetails") - api.RegisterMessage((*MfibSignalDump)(nil), "ip.MfibSignalDump") - api.RegisterMessage((*SetIPFlowHash)(nil), "ip.SetIPFlowHash") - api.RegisterMessage((*SetIPFlowHashReply)(nil), "ip.SetIPFlowHashReply") - api.RegisterMessage((*SwInterfaceIP6EnableDisable)(nil), "ip.SwInterfaceIP6EnableDisable") - api.RegisterMessage((*SwInterfaceIP6EnableDisableReply)(nil), "ip.SwInterfaceIP6EnableDisableReply") - api.RegisterMessage((*SwInterfaceIP6SetLinkLocalAddress)(nil), "ip.SwInterfaceIP6SetLinkLocalAddress") - api.RegisterMessage((*SwInterfaceIP6SetLinkLocalAddressReply)(nil), "ip.SwInterfaceIP6SetLinkLocalAddressReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*IoamDisable)(nil), - (*IoamDisableReply)(nil), - (*IoamEnable)(nil), - (*IoamEnableReply)(nil), - (*IPAddressDetails)(nil), - (*IPAddressDump)(nil), - (*IPContainerProxyAddDel)(nil), - (*IPContainerProxyAddDelReply)(nil), - (*IPContainerProxyDetails)(nil), - (*IPContainerProxyDump)(nil), - (*IPDetails)(nil), - (*IPDump)(nil), - (*IPMrouteAddDel)(nil), - (*IPMrouteAddDelReply)(nil), - (*IPMrouteDetails)(nil), - (*IPMrouteDump)(nil), - (*IPMtableDetails)(nil), - (*IPMtableDump)(nil), - (*IPPuntPolice)(nil), - (*IPPuntPoliceReply)(nil), - (*IPPuntRedirect)(nil), - (*IPPuntRedirectDetails)(nil), - (*IPPuntRedirectDump)(nil), - (*IPPuntRedirectReply)(nil), - (*IPReassemblyEnableDisable)(nil), - (*IPReassemblyEnableDisableReply)(nil), - (*IPReassemblyGet)(nil), - (*IPReassemblyGetReply)(nil), - (*IPReassemblySet)(nil), - (*IPReassemblySetReply)(nil), - (*IPRouteAddDel)(nil), - (*IPRouteAddDelReply)(nil), - (*IPRouteDetails)(nil), - (*IPRouteDump)(nil), - (*IPSourceAndPortRangeCheckAddDel)(nil), - (*IPSourceAndPortRangeCheckAddDelReply)(nil), - (*IPSourceAndPortRangeCheckInterfaceAddDel)(nil), - (*IPSourceAndPortRangeCheckInterfaceAddDelReply)(nil), - (*IPSourceCheckInterfaceAddDel)(nil), - (*IPSourceCheckInterfaceAddDelReply)(nil), - (*IPTableAddDel)(nil), - (*IPTableAddDelReply)(nil), - (*IPTableDetails)(nil), - (*IPTableDump)(nil), - (*IPTableFlush)(nil), - (*IPTableFlushReply)(nil), - (*IPTableReplaceBegin)(nil), - (*IPTableReplaceBeginReply)(nil), - (*IPTableReplaceEnd)(nil), - (*IPTableReplaceEndReply)(nil), - (*IPUnnumberedDetails)(nil), - (*IPUnnumberedDump)(nil), - (*MfibSignalDetails)(nil), - (*MfibSignalDump)(nil), - (*SetIPFlowHash)(nil), - (*SetIPFlowHashReply)(nil), - (*SwInterfaceIP6EnableDisable)(nil), - (*SwInterfaceIP6EnableDisableReply)(nil), - (*SwInterfaceIP6SetLinkLocalAddress)(nil), - (*SwInterfaceIP6SetLinkLocalAddressReply)(nil), - } -} - -// RPCService represents RPC service API for ip module. -type RPCService interface { - DumpIPAddress(ctx context.Context, in *IPAddressDump) (RPCService_DumpIPAddressClient, error) - DumpIPContainerProxy(ctx context.Context, in *IPContainerProxyDump) (RPCService_DumpIPContainerProxyClient, error) - DumpIP(ctx context.Context, in *IPDump) (RPCService_DumpIPClient, error) - DumpIPMroute(ctx context.Context, in *IPMrouteDump) (RPCService_DumpIPMrouteClient, error) - DumpIPMtable(ctx context.Context, in *IPMtableDump) (RPCService_DumpIPMtableClient, error) - DumpIPPuntRedirect(ctx context.Context, in *IPPuntRedirectDump) (RPCService_DumpIPPuntRedirectClient, error) - DumpIPRoute(ctx context.Context, in *IPRouteDump) (RPCService_DumpIPRouteClient, error) - DumpIPTable(ctx context.Context, in *IPTableDump) (RPCService_DumpIPTableClient, error) - DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) (RPCService_DumpIPUnnumberedClient, error) - DumpMfibSignal(ctx context.Context, in *MfibSignalDump) (RPCService_DumpMfibSignalClient, error) - IoamDisable(ctx context.Context, in *IoamDisable) (*IoamDisableReply, error) - IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) - IPContainerProxyAddDel(ctx context.Context, in *IPContainerProxyAddDel) (*IPContainerProxyAddDelReply, error) - IPMrouteAddDel(ctx context.Context, in *IPMrouteAddDel) (*IPMrouteAddDelReply, error) - IPPuntPolice(ctx context.Context, in *IPPuntPolice) (*IPPuntPoliceReply, error) - IPPuntRedirect(ctx context.Context, in *IPPuntRedirect) (*IPPuntRedirectReply, error) - IPReassemblyEnableDisable(ctx context.Context, in *IPReassemblyEnableDisable) (*IPReassemblyEnableDisableReply, error) - IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IPReassemblyGetReply, error) - IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IPReassemblySetReply, error) - IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (*IPRouteAddDelReply, error) - IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) - IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) - IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSourceCheckInterfaceAddDel) (*IPSourceCheckInterfaceAddDelReply, error) - IPTableAddDel(ctx context.Context, in *IPTableAddDel) (*IPTableAddDelReply, error) - IPTableFlush(ctx context.Context, in *IPTableFlush) (*IPTableFlushReply, error) - IPTableReplaceBegin(ctx context.Context, in *IPTableReplaceBegin) (*IPTableReplaceBeginReply, error) - IPTableReplaceEnd(ctx context.Context, in *IPTableReplaceEnd) (*IPTableReplaceEndReply, error) - SetIPFlowHash(ctx context.Context, in *SetIPFlowHash) (*SetIPFlowHashReply, error) - SwInterfaceIP6EnableDisable(ctx context.Context, in *SwInterfaceIP6EnableDisable) (*SwInterfaceIP6EnableDisableReply, error) - SwInterfaceIP6SetLinkLocalAddress(ctx context.Context, in *SwInterfaceIP6SetLinkLocalAddress) (*SwInterfaceIP6SetLinkLocalAddressReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpIPAddress(ctx context.Context, in *IPAddressDump) (RPCService_DumpIPAddressClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPAddressClient{stream} - return x, nil -} - -type RPCService_DumpIPAddressClient interface { - Recv() (*IPAddressDetails, error) -} - -type serviceClient_DumpIPAddressClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPAddressClient) Recv() (*IPAddressDetails, error) { - m := new(IPAddressDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIPContainerProxy(ctx context.Context, in *IPContainerProxyDump) (RPCService_DumpIPContainerProxyClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPContainerProxyClient{stream} - return x, nil -} - -type RPCService_DumpIPContainerProxyClient interface { - Recv() (*IPContainerProxyDetails, error) -} - -type serviceClient_DumpIPContainerProxyClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPContainerProxyClient) Recv() (*IPContainerProxyDetails, error) { - m := new(IPContainerProxyDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIP(ctx context.Context, in *IPDump) (RPCService_DumpIPClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPClient{stream} - return x, nil -} - -type RPCService_DumpIPClient interface { - Recv() (*IPDetails, error) -} - -type serviceClient_DumpIPClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPClient) Recv() (*IPDetails, error) { - m := new(IPDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIPMroute(ctx context.Context, in *IPMrouteDump) (RPCService_DumpIPMrouteClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPMrouteClient{stream} - return x, nil -} - -type RPCService_DumpIPMrouteClient interface { - Recv() (*IPMrouteDetails, error) -} - -type serviceClient_DumpIPMrouteClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPMrouteClient) Recv() (*IPMrouteDetails, error) { - m := new(IPMrouteDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIPMtable(ctx context.Context, in *IPMtableDump) (RPCService_DumpIPMtableClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPMtableClient{stream} - return x, nil -} - -type RPCService_DumpIPMtableClient interface { - Recv() (*IPMtableDetails, error) -} - -type serviceClient_DumpIPMtableClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPMtableClient) Recv() (*IPMtableDetails, error) { - m := new(IPMtableDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIPPuntRedirect(ctx context.Context, in *IPPuntRedirectDump) (RPCService_DumpIPPuntRedirectClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPPuntRedirectClient{stream} - return x, nil -} - -type RPCService_DumpIPPuntRedirectClient interface { - Recv() (*IPPuntRedirectDetails, error) -} - -type serviceClient_DumpIPPuntRedirectClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPPuntRedirectClient) Recv() (*IPPuntRedirectDetails, error) { - m := new(IPPuntRedirectDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIPRoute(ctx context.Context, in *IPRouteDump) (RPCService_DumpIPRouteClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPRouteClient{stream} - return x, nil -} - -type RPCService_DumpIPRouteClient interface { - Recv() (*IPRouteDetails, error) -} - -type serviceClient_DumpIPRouteClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPRouteClient) Recv() (*IPRouteDetails, error) { - m := new(IPRouteDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIPTable(ctx context.Context, in *IPTableDump) (RPCService_DumpIPTableClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPTableClient{stream} - return x, nil -} - -type RPCService_DumpIPTableClient interface { - Recv() (*IPTableDetails, error) -} - -type serviceClient_DumpIPTableClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPTableClient) Recv() (*IPTableDetails, error) { - m := new(IPTableDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIPUnnumbered(ctx context.Context, in *IPUnnumberedDump) (RPCService_DumpIPUnnumberedClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPUnnumberedClient{stream} - return x, nil -} - -type RPCService_DumpIPUnnumberedClient interface { - Recv() (*IPUnnumberedDetails, error) -} - -type serviceClient_DumpIPUnnumberedClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPUnnumberedClient) Recv() (*IPUnnumberedDetails, error) { - m := new(IPUnnumberedDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpMfibSignal(ctx context.Context, in *MfibSignalDump) (RPCService_DumpMfibSignalClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpMfibSignalClient{stream} - return x, nil -} - -type RPCService_DumpMfibSignalClient interface { - Recv() (*MfibSignalDetails, error) -} - -type serviceClient_DumpMfibSignalClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpMfibSignalClient) Recv() (*MfibSignalDetails, error) { - m := new(MfibSignalDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) IoamDisable(ctx context.Context, in *IoamDisable) (*IoamDisableReply, error) { - out := new(IoamDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IoamEnable(ctx context.Context, in *IoamEnable) (*IoamEnableReply, error) { - out := new(IoamEnableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPContainerProxyAddDel(ctx context.Context, in *IPContainerProxyAddDel) (*IPContainerProxyAddDelReply, error) { - out := new(IPContainerProxyAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPMrouteAddDel(ctx context.Context, in *IPMrouteAddDel) (*IPMrouteAddDelReply, error) { - out := new(IPMrouteAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPPuntPolice(ctx context.Context, in *IPPuntPolice) (*IPPuntPoliceReply, error) { - out := new(IPPuntPoliceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPPuntRedirect(ctx context.Context, in *IPPuntRedirect) (*IPPuntRedirectReply, error) { - out := new(IPPuntRedirectReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPReassemblyEnableDisable(ctx context.Context, in *IPReassemblyEnableDisable) (*IPReassemblyEnableDisableReply, error) { - out := new(IPReassemblyEnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IPReassemblyGetReply, error) { - out := new(IPReassemblyGetReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IPReassemblySetReply, error) { - out := new(IPReassemblySetReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (*IPRouteAddDelReply, error) { - out := new(IPRouteAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) { - out := new(IPSourceAndPortRangeCheckAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) { - out := new(IPSourceAndPortRangeCheckInterfaceAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSourceCheckInterfaceAddDel) (*IPSourceCheckInterfaceAddDelReply, error) { - out := new(IPSourceCheckInterfaceAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPTableAddDel(ctx context.Context, in *IPTableAddDel) (*IPTableAddDelReply, error) { - out := new(IPTableAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPTableFlush(ctx context.Context, in *IPTableFlush) (*IPTableFlushReply, error) { - out := new(IPTableFlushReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPTableReplaceBegin(ctx context.Context, in *IPTableReplaceBegin) (*IPTableReplaceBeginReply, error) { - out := new(IPTableReplaceBeginReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPTableReplaceEnd(ctx context.Context, in *IPTableReplaceEnd) (*IPTableReplaceEndReply, error) { - out := new(IPTableReplaceEndReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SetIPFlowHash(ctx context.Context, in *SetIPFlowHash) (*SetIPFlowHashReply, error) { - out := new(SetIPFlowHashReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceIP6EnableDisable(ctx context.Context, in *SwInterfaceIP6EnableDisable) (*SwInterfaceIP6EnableDisableReply, error) { - out := new(SwInterfaceIP6EnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceIP6SetLinkLocalAddress(ctx context.Context, in *SwInterfaceIP6SetLinkLocalAddress) (*SwInterfaceIP6SetLinkLocalAddressReply, error) { - out := new(SwInterfaceIP6SetLinkLocalAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ip6_nd/ip6_nd.ba.go b/plugins/vpp/binapi/vpp2001/ip6_nd/ip6_nd.ba.go deleted file mode 100644 index 501ef4e129..0000000000 --- a/plugins/vpp/binapi/vpp2001/ip6_nd/ip6_nd.ba.go +++ /dev/null @@ -1,405 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ip6_nd.api.json - -/* -Package ip6_nd is a generated VPP binary API for 'ip6_nd' module. - -It consists of: - 10 enums - 6 aliases - 7 types - 1 union - 13 messages - 6 services -*/ -package ip6_nd - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ip6_nd" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xbb8ff0e9 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -// IP6RaPrefixInfo represents VPP binary API type 'ip6_ra_prefix_info'. -type IP6RaPrefixInfo struct { - Prefix Prefix - Flags uint8 - ValidTime uint32 - PreferredTime uint32 -} - -func (*IP6RaPrefixInfo) GetTypeName() string { return "ip6_ra_prefix_info" } - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// IP6RaEvent represents VPP binary API message 'ip6_ra_event'. -type IP6RaEvent struct { - PID uint32 - SwIfIndex InterfaceIndex - RouterAddr IP6Address - CurrentHopLimit uint8 - Flags uint8 - RouterLifetimeInSec uint16 - NeighborReachableTimeInMsec uint32 - TimeInMsecBetweenRetransmittedNeighborSolicitations uint32 - NPrefixes uint32 `struc:"sizeof=Prefixes"` - Prefixes []IP6RaPrefixInfo -} - -func (m *IP6RaEvent) Reset() { *m = IP6RaEvent{} } -func (*IP6RaEvent) GetMessageName() string { return "ip6_ra_event" } -func (*IP6RaEvent) GetCrcString() string { return "47e8cfbe" } -func (*IP6RaEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// IP6ndProxyAddDel represents VPP binary API message 'ip6nd_proxy_add_del'. -type IP6ndProxyAddDel struct { - SwIfIndex InterfaceIndex - IsAdd bool - IP IP6Address -} - -func (m *IP6ndProxyAddDel) Reset() { *m = IP6ndProxyAddDel{} } -func (*IP6ndProxyAddDel) GetMessageName() string { return "ip6nd_proxy_add_del" } -func (*IP6ndProxyAddDel) GetCrcString() string { return "3fdf6659" } -func (*IP6ndProxyAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IP6ndProxyAddDelReply represents VPP binary API message 'ip6nd_proxy_add_del_reply'. -type IP6ndProxyAddDelReply struct { - Retval int32 -} - -func (m *IP6ndProxyAddDelReply) Reset() { *m = IP6ndProxyAddDelReply{} } -func (*IP6ndProxyAddDelReply) GetMessageName() string { return "ip6nd_proxy_add_del_reply" } -func (*IP6ndProxyAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IP6ndProxyAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IP6ndProxyDetails represents VPP binary API message 'ip6nd_proxy_details'. -type IP6ndProxyDetails struct { - SwIfIndex InterfaceIndex - IP IP6Address -} - -func (m *IP6ndProxyDetails) Reset() { *m = IP6ndProxyDetails{} } -func (*IP6ndProxyDetails) GetMessageName() string { return "ip6nd_proxy_details" } -func (*IP6ndProxyDetails) GetCrcString() string { return "d35be8ff" } -func (*IP6ndProxyDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IP6ndProxyDump represents VPP binary API message 'ip6nd_proxy_dump'. -type IP6ndProxyDump struct{} - -func (m *IP6ndProxyDump) Reset() { *m = IP6ndProxyDump{} } -func (*IP6ndProxyDump) GetMessageName() string { return "ip6nd_proxy_dump" } -func (*IP6ndProxyDump) GetCrcString() string { return "51077d14" } -func (*IP6ndProxyDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IP6ndSendRouterSolicitation represents VPP binary API message 'ip6nd_send_router_solicitation'. -type IP6ndSendRouterSolicitation struct { - Irt uint32 - Mrt uint32 - Mrc uint32 - Mrd uint32 - SwIfIndex InterfaceIndex - Stop bool -} - -func (m *IP6ndSendRouterSolicitation) Reset() { *m = IP6ndSendRouterSolicitation{} } -func (*IP6ndSendRouterSolicitation) GetMessageName() string { return "ip6nd_send_router_solicitation" } -func (*IP6ndSendRouterSolicitation) GetCrcString() string { return "e5de609c" } -func (*IP6ndSendRouterSolicitation) GetMessageType() api.MessageType { return api.RequestMessage } - -// IP6ndSendRouterSolicitationReply represents VPP binary API message 'ip6nd_send_router_solicitation_reply'. -type IP6ndSendRouterSolicitationReply struct { - Retval int32 -} - -func (m *IP6ndSendRouterSolicitationReply) Reset() { *m = IP6ndSendRouterSolicitationReply{} } -func (*IP6ndSendRouterSolicitationReply) GetMessageName() string { - return "ip6nd_send_router_solicitation_reply" -} -func (*IP6ndSendRouterSolicitationReply) GetCrcString() string { return "e8d4e804" } -func (*IP6ndSendRouterSolicitationReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceIP6ndRaConfig represents VPP binary API message 'sw_interface_ip6nd_ra_config'. -type SwInterfaceIP6ndRaConfig struct { - SwIfIndex InterfaceIndex - Suppress uint8 - Managed uint8 - Other uint8 - LlOption uint8 - SendUnicast uint8 - Cease uint8 - IsNo bool - DefaultRouter uint8 - MaxInterval uint32 - MinInterval uint32 - Lifetime uint32 - InitialCount uint32 - InitialInterval uint32 -} - -func (m *SwInterfaceIP6ndRaConfig) Reset() { *m = SwInterfaceIP6ndRaConfig{} } -func (*SwInterfaceIP6ndRaConfig) GetMessageName() string { return "sw_interface_ip6nd_ra_config" } -func (*SwInterfaceIP6ndRaConfig) GetCrcString() string { return "3eb00b1c" } -func (*SwInterfaceIP6ndRaConfig) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceIP6ndRaConfigReply represents VPP binary API message 'sw_interface_ip6nd_ra_config_reply'. -type SwInterfaceIP6ndRaConfigReply struct { - Retval int32 -} - -func (m *SwInterfaceIP6ndRaConfigReply) Reset() { *m = SwInterfaceIP6ndRaConfigReply{} } -func (*SwInterfaceIP6ndRaConfigReply) GetMessageName() string { - return "sw_interface_ip6nd_ra_config_reply" -} -func (*SwInterfaceIP6ndRaConfigReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceIP6ndRaConfigReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceIP6ndRaPrefix represents VPP binary API message 'sw_interface_ip6nd_ra_prefix'. -type SwInterfaceIP6ndRaPrefix struct { - SwIfIndex InterfaceIndex - Prefix Prefix - UseDefault bool - NoAdvertise bool - OffLink bool - NoAutoconfig bool - NoOnlink bool - IsNo bool - ValLifetime uint32 - PrefLifetime uint32 -} - -func (m *SwInterfaceIP6ndRaPrefix) Reset() { *m = SwInterfaceIP6ndRaPrefix{} } -func (*SwInterfaceIP6ndRaPrefix) GetMessageName() string { return "sw_interface_ip6nd_ra_prefix" } -func (*SwInterfaceIP6ndRaPrefix) GetCrcString() string { return "e098785f" } -func (*SwInterfaceIP6ndRaPrefix) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceIP6ndRaPrefixReply represents VPP binary API message 'sw_interface_ip6nd_ra_prefix_reply'. -type SwInterfaceIP6ndRaPrefixReply struct { - Retval int32 -} - -func (m *SwInterfaceIP6ndRaPrefixReply) Reset() { *m = SwInterfaceIP6ndRaPrefixReply{} } -func (*SwInterfaceIP6ndRaPrefixReply) GetMessageName() string { - return "sw_interface_ip6nd_ra_prefix_reply" -} -func (*SwInterfaceIP6ndRaPrefixReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceIP6ndRaPrefixReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// WantIP6RaEvents represents VPP binary API message 'want_ip6_ra_events'. -type WantIP6RaEvents struct { - Enable bool - PID uint32 -} - -func (m *WantIP6RaEvents) Reset() { *m = WantIP6RaEvents{} } -func (*WantIP6RaEvents) GetMessageName() string { return "want_ip6_ra_events" } -func (*WantIP6RaEvents) GetCrcString() string { return "3ec6d6c2" } -func (*WantIP6RaEvents) GetMessageType() api.MessageType { return api.RequestMessage } - -// WantIP6RaEventsReply represents VPP binary API message 'want_ip6_ra_events_reply'. -type WantIP6RaEventsReply struct { - Retval int32 -} - -func (m *WantIP6RaEventsReply) Reset() { *m = WantIP6RaEventsReply{} } -func (*WantIP6RaEventsReply) GetMessageName() string { return "want_ip6_ra_events_reply" } -func (*WantIP6RaEventsReply) GetCrcString() string { return "e8d4e804" } -func (*WantIP6RaEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*IP6RaEvent)(nil), "ip6_nd.IP6RaEvent") - api.RegisterMessage((*IP6ndProxyAddDel)(nil), "ip6_nd.IP6ndProxyAddDel") - api.RegisterMessage((*IP6ndProxyAddDelReply)(nil), "ip6_nd.IP6ndProxyAddDelReply") - api.RegisterMessage((*IP6ndProxyDetails)(nil), "ip6_nd.IP6ndProxyDetails") - api.RegisterMessage((*IP6ndProxyDump)(nil), "ip6_nd.IP6ndProxyDump") - api.RegisterMessage((*IP6ndSendRouterSolicitation)(nil), "ip6_nd.IP6ndSendRouterSolicitation") - api.RegisterMessage((*IP6ndSendRouterSolicitationReply)(nil), "ip6_nd.IP6ndSendRouterSolicitationReply") - api.RegisterMessage((*SwInterfaceIP6ndRaConfig)(nil), "ip6_nd.SwInterfaceIP6ndRaConfig") - api.RegisterMessage((*SwInterfaceIP6ndRaConfigReply)(nil), "ip6_nd.SwInterfaceIP6ndRaConfigReply") - api.RegisterMessage((*SwInterfaceIP6ndRaPrefix)(nil), "ip6_nd.SwInterfaceIP6ndRaPrefix") - api.RegisterMessage((*SwInterfaceIP6ndRaPrefixReply)(nil), "ip6_nd.SwInterfaceIP6ndRaPrefixReply") - api.RegisterMessage((*WantIP6RaEvents)(nil), "ip6_nd.WantIP6RaEvents") - api.RegisterMessage((*WantIP6RaEventsReply)(nil), "ip6_nd.WantIP6RaEventsReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*IP6RaEvent)(nil), - (*IP6ndProxyAddDel)(nil), - (*IP6ndProxyAddDelReply)(nil), - (*IP6ndProxyDetails)(nil), - (*IP6ndProxyDump)(nil), - (*IP6ndSendRouterSolicitation)(nil), - (*IP6ndSendRouterSolicitationReply)(nil), - (*SwInterfaceIP6ndRaConfig)(nil), - (*SwInterfaceIP6ndRaConfigReply)(nil), - (*SwInterfaceIP6ndRaPrefix)(nil), - (*SwInterfaceIP6ndRaPrefixReply)(nil), - (*WantIP6RaEvents)(nil), - (*WantIP6RaEventsReply)(nil), - } -} - -// RPCService represents RPC service API for ip6_nd module. -type RPCService interface { - DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) (RPCService_DumpIP6ndProxyClient, error) - IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) - IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSendRouterSolicitation) (*IP6ndSendRouterSolicitationReply, error) - SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) - SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) - WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpIP6ndProxy(ctx context.Context, in *IP6ndProxyDump) (RPCService_DumpIP6ndProxyClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIP6ndProxyClient{stream} - return x, nil -} - -type RPCService_DumpIP6ndProxyClient interface { - Recv() (*IP6ndProxyDetails, error) -} - -type serviceClient_DumpIP6ndProxyClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIP6ndProxyClient) Recv() (*IP6ndProxyDetails, error) { - m := new(IP6ndProxyDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) IP6ndProxyAddDel(ctx context.Context, in *IP6ndProxyAddDel) (*IP6ndProxyAddDelReply, error) { - out := new(IP6ndProxyAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IP6ndSendRouterSolicitation(ctx context.Context, in *IP6ndSendRouterSolicitation) (*IP6ndSendRouterSolicitationReply, error) { - out := new(IP6ndSendRouterSolicitationReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceIP6ndRaConfig(ctx context.Context, in *SwInterfaceIP6ndRaConfig) (*SwInterfaceIP6ndRaConfigReply, error) { - out := new(SwInterfaceIP6ndRaConfigReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceIP6ndRaPrefix(ctx context.Context, in *SwInterfaceIP6ndRaPrefix) (*SwInterfaceIP6ndRaPrefixReply, error) { - out := new(SwInterfaceIP6ndRaPrefixReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) WantIP6RaEvents(ctx context.Context, in *WantIP6RaEvents) (*WantIP6RaEventsReply, error) { - out := new(WantIP6RaEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ip_neighbor/ip_neighbor.ba.go b/plugins/vpp/binapi/vpp2001/ip_neighbor/ip_neighbor.ba.go deleted file mode 100644 index e5ee9172e4..0000000000 --- a/plugins/vpp/binapi/vpp2001/ip_neighbor/ip_neighbor.ba.go +++ /dev/null @@ -1,335 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ip_neighbor.api.json - -/* -Package ip_neighbor is a generated VPP binary API for 'ip_neighbor' module. - -It consists of: - 11 enums - 7 aliases - 7 types - 1 union - 9 messages - 4 services -*/ -package ip_neighbor - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ip_neighbor" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xdae37c55 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -// IPNeighborFlags represents VPP binary API enum 'ip_neighbor_flags'. -type IPNeighborFlags uint8 - -const ( - IP_API_NEIGHBOR_FLAG_NONE IPNeighborFlags = 0 - IP_API_NEIGHBOR_FLAG_STATIC IPNeighborFlags = 1 - IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY IPNeighborFlags = 2 -) - -var IPNeighborFlags_name = map[uint8]string{ - 0: "IP_API_NEIGHBOR_FLAG_NONE", - 1: "IP_API_NEIGHBOR_FLAG_STATIC", - 2: "IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY", -} - -var IPNeighborFlags_value = map[string]uint8{ - "IP_API_NEIGHBOR_FLAG_NONE": 0, - "IP_API_NEIGHBOR_FLAG_STATIC": 1, - "IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY": 2, -} - -func (x IPNeighborFlags) String() string { - s, ok := IPNeighborFlags_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type MacAddress = ethernet_types.MacAddress - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -// IPNeighbor represents VPP binary API type 'ip_neighbor'. -type IPNeighbor struct { - SwIfIndex InterfaceIndex - Flags IPNeighborFlags - MacAddress MacAddress - IPAddress Address -} - -func (*IPNeighbor) GetTypeName() string { return "ip_neighbor" } - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// IPNeighborAddDel represents VPP binary API message 'ip_neighbor_add_del'. -type IPNeighborAddDel struct { - IsAdd bool - Neighbor IPNeighbor -} - -func (m *IPNeighborAddDel) Reset() { *m = IPNeighborAddDel{} } -func (*IPNeighborAddDel) GetMessageName() string { return "ip_neighbor_add_del" } -func (*IPNeighborAddDel) GetCrcString() string { return "105518b6" } -func (*IPNeighborAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPNeighborAddDelReply represents VPP binary API message 'ip_neighbor_add_del_reply'. -type IPNeighborAddDelReply struct { - Retval int32 - StatsIndex uint32 -} - -func (m *IPNeighborAddDelReply) Reset() { *m = IPNeighborAddDelReply{} } -func (*IPNeighborAddDelReply) GetMessageName() string { return "ip_neighbor_add_del_reply" } -func (*IPNeighborAddDelReply) GetCrcString() string { return "1992deab" } -func (*IPNeighborAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPNeighborConfig represents VPP binary API message 'ip_neighbor_config'. -type IPNeighborConfig struct { - Af AddressFamily - MaxNumber uint32 - MaxAge uint32 - Recycle bool -} - -func (m *IPNeighborConfig) Reset() { *m = IPNeighborConfig{} } -func (*IPNeighborConfig) GetMessageName() string { return "ip_neighbor_config" } -func (*IPNeighborConfig) GetCrcString() string { return "f4a5cf44" } -func (*IPNeighborConfig) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPNeighborConfigReply represents VPP binary API message 'ip_neighbor_config_reply'. -type IPNeighborConfigReply struct { - Retval int32 -} - -func (m *IPNeighborConfigReply) Reset() { *m = IPNeighborConfigReply{} } -func (*IPNeighborConfigReply) GetMessageName() string { return "ip_neighbor_config_reply" } -func (*IPNeighborConfigReply) GetCrcString() string { return "e8d4e804" } -func (*IPNeighborConfigReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPNeighborDetails represents VPP binary API message 'ip_neighbor_details'. -type IPNeighborDetails struct { - Neighbor IPNeighbor -} - -func (m *IPNeighborDetails) Reset() { *m = IPNeighborDetails{} } -func (*IPNeighborDetails) GetMessageName() string { return "ip_neighbor_details" } -func (*IPNeighborDetails) GetCrcString() string { return "59121ce9" } -func (*IPNeighborDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IPNeighborDump represents VPP binary API message 'ip_neighbor_dump'. -type IPNeighborDump struct { - SwIfIndex InterfaceIndex - Af AddressFamily -} - -func (m *IPNeighborDump) Reset() { *m = IPNeighborDump{} } -func (*IPNeighborDump) GetMessageName() string { return "ip_neighbor_dump" } -func (*IPNeighborDump) GetCrcString() string { return "cd831298" } -func (*IPNeighborDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IPNeighborEvent represents VPP binary API message 'ip_neighbor_event'. -type IPNeighborEvent struct { - PID uint32 - Neighbor IPNeighbor -} - -func (m *IPNeighborEvent) Reset() { *m = IPNeighborEvent{} } -func (*IPNeighborEvent) GetMessageName() string { return "ip_neighbor_event" } -func (*IPNeighborEvent) GetCrcString() string { return "83933131" } -func (*IPNeighborEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// WantIPNeighborEvents represents VPP binary API message 'want_ip_neighbor_events'. -type WantIPNeighborEvents struct { - Enable bool - PID uint32 - IP Address - SwIfIndex InterfaceIndex -} - -func (m *WantIPNeighborEvents) Reset() { *m = WantIPNeighborEvents{} } -func (*WantIPNeighborEvents) GetMessageName() string { return "want_ip_neighbor_events" } -func (*WantIPNeighborEvents) GetCrcString() string { return "1a312870" } -func (*WantIPNeighborEvents) GetMessageType() api.MessageType { return api.RequestMessage } - -// WantIPNeighborEventsReply represents VPP binary API message 'want_ip_neighbor_events_reply'. -type WantIPNeighborEventsReply struct { - Retval int32 -} - -func (m *WantIPNeighborEventsReply) Reset() { *m = WantIPNeighborEventsReply{} } -func (*WantIPNeighborEventsReply) GetMessageName() string { return "want_ip_neighbor_events_reply" } -func (*WantIPNeighborEventsReply) GetCrcString() string { return "e8d4e804" } -func (*WantIPNeighborEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*IPNeighborAddDel)(nil), "ip_neighbor.IPNeighborAddDel") - api.RegisterMessage((*IPNeighborAddDelReply)(nil), "ip_neighbor.IPNeighborAddDelReply") - api.RegisterMessage((*IPNeighborConfig)(nil), "ip_neighbor.IPNeighborConfig") - api.RegisterMessage((*IPNeighborConfigReply)(nil), "ip_neighbor.IPNeighborConfigReply") - api.RegisterMessage((*IPNeighborDetails)(nil), "ip_neighbor.IPNeighborDetails") - api.RegisterMessage((*IPNeighborDump)(nil), "ip_neighbor.IPNeighborDump") - api.RegisterMessage((*IPNeighborEvent)(nil), "ip_neighbor.IPNeighborEvent") - api.RegisterMessage((*WantIPNeighborEvents)(nil), "ip_neighbor.WantIPNeighborEvents") - api.RegisterMessage((*WantIPNeighborEventsReply)(nil), "ip_neighbor.WantIPNeighborEventsReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*IPNeighborAddDel)(nil), - (*IPNeighborAddDelReply)(nil), - (*IPNeighborConfig)(nil), - (*IPNeighborConfigReply)(nil), - (*IPNeighborDetails)(nil), - (*IPNeighborDump)(nil), - (*IPNeighborEvent)(nil), - (*WantIPNeighborEvents)(nil), - (*WantIPNeighborEventsReply)(nil), - } -} - -// RPCService represents RPC service API for ip_neighbor module. -type RPCService interface { - DumpIPNeighbor(ctx context.Context, in *IPNeighborDump) (RPCService_DumpIPNeighborClient, error) - IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) - IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) - WantIPNeighborEvents(ctx context.Context, in *WantIPNeighborEvents) (*WantIPNeighborEventsReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpIPNeighbor(ctx context.Context, in *IPNeighborDump) (RPCService_DumpIPNeighborClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIPNeighborClient{stream} - return x, nil -} - -type RPCService_DumpIPNeighborClient interface { - Recv() (*IPNeighborDetails, error) -} - -type serviceClient_DumpIPNeighborClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIPNeighborClient) Recv() (*IPNeighborDetails, error) { - m := new(IPNeighborDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) IPNeighborAddDel(ctx context.Context, in *IPNeighborAddDel) (*IPNeighborAddDelReply, error) { - out := new(IPNeighborAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IPNeighborConfig(ctx context.Context, in *IPNeighborConfig) (*IPNeighborConfigReply, error) { - out := new(IPNeighborConfigReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) WantIPNeighborEvents(ctx context.Context, in *WantIPNeighborEvents) (*WantIPNeighborEventsReply, error) { - out := new(WantIPNeighborEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ip_types/ip_types.ba.go b/plugins/vpp/binapi/vpp2001/ip_types/ip_types.ba.go deleted file mode 100644 index e812b8b8a0..0000000000 --- a/plugins/vpp/binapi/vpp2001/ip_types/ip_types.ba.go +++ /dev/null @@ -1,349 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ip_types.api.json - -/* -Package ip_types is a generated VPP binary API for 'ip_types' module. - -It consists of: - 4 enums - 5 aliases - 6 types - 1 union -*/ -package ip_types - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ip_types" - // APIVersion is the API version of this module. - APIVersion = "3.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x80424562 -) - -// AddressFamily represents VPP binary API enum 'address_family'. -type AddressFamily uint32 - -const ( - ADDRESS_IP4 AddressFamily = 0 - ADDRESS_IP6 AddressFamily = 1 -) - -var AddressFamily_name = map[uint32]string{ - 0: "ADDRESS_IP4", - 1: "ADDRESS_IP6", -} - -var AddressFamily_value = map[string]uint32{ - "ADDRESS_IP4": 0, - "ADDRESS_IP6": 1, -} - -func (x AddressFamily) String() string { - s, ok := AddressFamily_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IPDscp represents VPP binary API enum 'ip_dscp'. -type IPDscp uint8 - -const ( - IP_API_DSCP_CS0 IPDscp = 0 - IP_API_DSCP_CS1 IPDscp = 8 - IP_API_DSCP_AF11 IPDscp = 10 - IP_API_DSCP_AF12 IPDscp = 12 - IP_API_DSCP_AF13 IPDscp = 14 - IP_API_DSCP_CS2 IPDscp = 16 - IP_API_DSCP_AF21 IPDscp = 18 - IP_API_DSCP_AF22 IPDscp = 20 - IP_API_DSCP_AF23 IPDscp = 22 - IP_API_DSCP_CS3 IPDscp = 24 - IP_API_DSCP_AF31 IPDscp = 26 - IP_API_DSCP_AF32 IPDscp = 28 - IP_API_DSCP_AF33 IPDscp = 30 - IP_API_DSCP_CS4 IPDscp = 32 - IP_API_DSCP_AF41 IPDscp = 34 - IP_API_DSCP_AF42 IPDscp = 36 - IP_API_DSCP_AF43 IPDscp = 38 - IP_API_DSCP_CS5 IPDscp = 40 - IP_API_DSCP_EF IPDscp = 46 - IP_API_DSCP_CS6 IPDscp = 48 - IP_API_DSCP_CS7 IPDscp = 50 -) - -var IPDscp_name = map[uint8]string{ - 0: "IP_API_DSCP_CS0", - 8: "IP_API_DSCP_CS1", - 10: "IP_API_DSCP_AF11", - 12: "IP_API_DSCP_AF12", - 14: "IP_API_DSCP_AF13", - 16: "IP_API_DSCP_CS2", - 18: "IP_API_DSCP_AF21", - 20: "IP_API_DSCP_AF22", - 22: "IP_API_DSCP_AF23", - 24: "IP_API_DSCP_CS3", - 26: "IP_API_DSCP_AF31", - 28: "IP_API_DSCP_AF32", - 30: "IP_API_DSCP_AF33", - 32: "IP_API_DSCP_CS4", - 34: "IP_API_DSCP_AF41", - 36: "IP_API_DSCP_AF42", - 38: "IP_API_DSCP_AF43", - 40: "IP_API_DSCP_CS5", - 46: "IP_API_DSCP_EF", - 48: "IP_API_DSCP_CS6", - 50: "IP_API_DSCP_CS7", -} - -var IPDscp_value = map[string]uint8{ - "IP_API_DSCP_CS0": 0, - "IP_API_DSCP_CS1": 8, - "IP_API_DSCP_AF11": 10, - "IP_API_DSCP_AF12": 12, - "IP_API_DSCP_AF13": 14, - "IP_API_DSCP_CS2": 16, - "IP_API_DSCP_AF21": 18, - "IP_API_DSCP_AF22": 20, - "IP_API_DSCP_AF23": 22, - "IP_API_DSCP_CS3": 24, - "IP_API_DSCP_AF31": 26, - "IP_API_DSCP_AF32": 28, - "IP_API_DSCP_AF33": 30, - "IP_API_DSCP_CS4": 32, - "IP_API_DSCP_AF41": 34, - "IP_API_DSCP_AF42": 36, - "IP_API_DSCP_AF43": 38, - "IP_API_DSCP_CS5": 40, - "IP_API_DSCP_EF": 46, - "IP_API_DSCP_CS6": 48, - "IP_API_DSCP_CS7": 50, -} - -func (x IPDscp) String() string { - s, ok := IPDscp_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IPEcn represents VPP binary API enum 'ip_ecn'. -type IPEcn uint8 - -const ( - IP_API_ECN_NONE IPEcn = 0 - IP_API_ECN_ECT0 IPEcn = 1 - IP_API_ECN_ECT1 IPEcn = 2 - IP_API_ECN_CE IPEcn = 3 -) - -var IPEcn_name = map[uint8]string{ - 0: "IP_API_ECN_NONE", - 1: "IP_API_ECN_ECT0", - 2: "IP_API_ECN_ECT1", - 3: "IP_API_ECN_CE", -} - -var IPEcn_value = map[string]uint8{ - "IP_API_ECN_NONE": 0, - "IP_API_ECN_ECT0": 1, - "IP_API_ECN_ECT1": 2, - "IP_API_ECN_CE": 3, -} - -func (x IPEcn) String() string { - s, ok := IPEcn_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IPProto represents VPP binary API enum 'ip_proto'. -type IPProto uint32 - -const ( - IP_API_PROTO_HOPOPT IPProto = 0 - IP_API_PROTO_ICMP IPProto = 1 - IP_API_PROTO_IGMP IPProto = 2 - IP_API_PROTO_TCP IPProto = 6 - IP_API_PROTO_UDP IPProto = 17 - IP_API_PROTO_GRE IPProto = 47 - IP_API_PROTO_AH IPProto = 50 - IP_API_PROTO_ESP IPProto = 51 - IP_API_PROTO_EIGRP IPProto = 88 - IP_API_PROTO_OSPF IPProto = 89 - IP_API_PROTO_SCTP IPProto = 132 - IP_API_PROTO_RESERVED IPProto = 255 -) - -var IPProto_name = map[uint32]string{ - 0: "IP_API_PROTO_HOPOPT", - 1: "IP_API_PROTO_ICMP", - 2: "IP_API_PROTO_IGMP", - 6: "IP_API_PROTO_TCP", - 17: "IP_API_PROTO_UDP", - 47: "IP_API_PROTO_GRE", - 50: "IP_API_PROTO_AH", - 51: "IP_API_PROTO_ESP", - 88: "IP_API_PROTO_EIGRP", - 89: "IP_API_PROTO_OSPF", - 132: "IP_API_PROTO_SCTP", - 255: "IP_API_PROTO_RESERVED", -} - -var IPProto_value = map[string]uint32{ - "IP_API_PROTO_HOPOPT": 0, - "IP_API_PROTO_ICMP": 1, - "IP_API_PROTO_IGMP": 2, - "IP_API_PROTO_TCP": 6, - "IP_API_PROTO_UDP": 17, - "IP_API_PROTO_GRE": 47, - "IP_API_PROTO_AH": 50, - "IP_API_PROTO_ESP": 51, - "IP_API_PROTO_EIGRP": 88, - "IP_API_PROTO_OSPF": 89, - "IP_API_PROTO_SCTP": 132, - "IP_API_PROTO_RESERVED": 255, -} - -func (x IPProto) String() string { - s, ok := IPProto_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// AddressWithPrefix represents VPP binary API alias 'address_with_prefix'. -type AddressWithPrefix Prefix - -// IP4Address represents VPP binary API alias 'ip4_address'. -type IP4Address [4]uint8 - -// IP4AddressWithPrefix represents VPP binary API alias 'ip4_address_with_prefix'. -type IP4AddressWithPrefix IP4Prefix - -// IP6Address represents VPP binary API alias 'ip6_address'. -type IP6Address [16]uint8 - -// IP6AddressWithPrefix represents VPP binary API alias 'ip6_address_with_prefix'. -type IP6AddressWithPrefix IP6Prefix - -// Address represents VPP binary API type 'address'. -type Address struct { - Af AddressFamily - Un AddressUnion -} - -func (*Address) GetTypeName() string { return "address" } - -// IP4Prefix represents VPP binary API type 'ip4_prefix'. -type IP4Prefix struct { - Address IP4Address - Len uint8 -} - -func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } - -// IP6Prefix represents VPP binary API type 'ip6_prefix'. -type IP6Prefix struct { - Address IP6Address - Len uint8 -} - -func (*IP6Prefix) GetTypeName() string { return "ip6_prefix" } - -// Mprefix represents VPP binary API type 'mprefix'. -type Mprefix struct { - Af AddressFamily - GrpAddressLength uint16 - GrpAddress AddressUnion - SrcAddress AddressUnion -} - -func (*Mprefix) GetTypeName() string { return "mprefix" } - -// Prefix represents VPP binary API type 'prefix'. -type Prefix struct { - Address Address - Len uint8 -} - -func (*Prefix) GetTypeName() string { return "prefix" } - -// PrefixMatcher represents VPP binary API type 'prefix_matcher'. -type PrefixMatcher struct { - Le uint8 - Ge uint8 -} - -func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" } - -// AddressUnion represents VPP binary API union 'address_union'. -type AddressUnion struct { - XXX_UnionData [16]byte -} - -func (*AddressUnion) GetTypeName() string { return "address_union" } - -func AddressUnionIP4(a IP4Address) (u AddressUnion) { - u.SetIP4(a) - return -} -func (u *AddressUnion) SetIP4(a IP4Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP4() (a IP4Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} - -func AddressUnionIP6(a IP6Address) (u AddressUnion) { - u.SetIP6(a) - return -} -func (u *AddressUnion) SetIP6(a IP6Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP6() (a IP6Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ipfix_export/ipfix_export.ba.go b/plugins/vpp/binapi/vpp2001/ipfix_export/ipfix_export.ba.go deleted file mode 100644 index 57978df7bd..0000000000 --- a/plugins/vpp/binapi/vpp2001/ipfix_export/ipfix_export.ba.go +++ /dev/null @@ -1,405 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ipfix_export.api.json - -/* -Package ipfix_export is a generated VPP binary API for 'ipfix_export' module. - -It consists of: - 4 enums - 5 aliases - 6 types - 1 union - 14 messages - 7 services -*/ -package ipfix_export - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ipfix_export" - // APIVersion is the API version of this module. - APIVersion = "2.0.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0xee6ea488 -) - -type AddressFamily = ip_types.AddressFamily - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// IpfixClassifyStreamDetails represents VPP binary API message 'ipfix_classify_stream_details'. -type IpfixClassifyStreamDetails struct { - DomainID uint32 - SrcPort uint16 -} - -func (m *IpfixClassifyStreamDetails) Reset() { *m = IpfixClassifyStreamDetails{} } -func (*IpfixClassifyStreamDetails) GetMessageName() string { return "ipfix_classify_stream_details" } -func (*IpfixClassifyStreamDetails) GetCrcString() string { return "2903539d" } -func (*IpfixClassifyStreamDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpfixClassifyStreamDump represents VPP binary API message 'ipfix_classify_stream_dump'. -type IpfixClassifyStreamDump struct{} - -func (m *IpfixClassifyStreamDump) Reset() { *m = IpfixClassifyStreamDump{} } -func (*IpfixClassifyStreamDump) GetMessageName() string { return "ipfix_classify_stream_dump" } -func (*IpfixClassifyStreamDump) GetCrcString() string { return "51077d14" } -func (*IpfixClassifyStreamDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpfixClassifyTableAddDel represents VPP binary API message 'ipfix_classify_table_add_del'. -type IpfixClassifyTableAddDel struct { - TableID uint32 - IPVersion AddressFamily - TransportProtocol IPProto - IsAdd bool -} - -func (m *IpfixClassifyTableAddDel) Reset() { *m = IpfixClassifyTableAddDel{} } -func (*IpfixClassifyTableAddDel) GetMessageName() string { return "ipfix_classify_table_add_del" } -func (*IpfixClassifyTableAddDel) GetCrcString() string { return "5118bc5e" } -func (*IpfixClassifyTableAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpfixClassifyTableAddDelReply represents VPP binary API message 'ipfix_classify_table_add_del_reply'. -type IpfixClassifyTableAddDelReply struct { - Retval int32 -} - -func (m *IpfixClassifyTableAddDelReply) Reset() { *m = IpfixClassifyTableAddDelReply{} } -func (*IpfixClassifyTableAddDelReply) GetMessageName() string { - return "ipfix_classify_table_add_del_reply" -} -func (*IpfixClassifyTableAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IpfixClassifyTableAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpfixClassifyTableDetails represents VPP binary API message 'ipfix_classify_table_details'. -type IpfixClassifyTableDetails struct { - TableID uint32 - IPVersion AddressFamily - TransportProtocol IPProto -} - -func (m *IpfixClassifyTableDetails) Reset() { *m = IpfixClassifyTableDetails{} } -func (*IpfixClassifyTableDetails) GetMessageName() string { return "ipfix_classify_table_details" } -func (*IpfixClassifyTableDetails) GetCrcString() string { return "7c8351ec" } -func (*IpfixClassifyTableDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpfixClassifyTableDump represents VPP binary API message 'ipfix_classify_table_dump'. -type IpfixClassifyTableDump struct{} - -func (m *IpfixClassifyTableDump) Reset() { *m = IpfixClassifyTableDump{} } -func (*IpfixClassifyTableDump) GetMessageName() string { return "ipfix_classify_table_dump" } -func (*IpfixClassifyTableDump) GetCrcString() string { return "51077d14" } -func (*IpfixClassifyTableDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpfixExporterDetails represents VPP binary API message 'ipfix_exporter_details'. -type IpfixExporterDetails struct { - CollectorAddress Address - CollectorPort uint16 - SrcAddress Address - VrfID uint32 - PathMtu uint32 - TemplateInterval uint32 - UDPChecksum bool -} - -func (m *IpfixExporterDetails) Reset() { *m = IpfixExporterDetails{} } -func (*IpfixExporterDetails) GetMessageName() string { return "ipfix_exporter_details" } -func (*IpfixExporterDetails) GetCrcString() string { return "11e07413" } -func (*IpfixExporterDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpfixExporterDump represents VPP binary API message 'ipfix_exporter_dump'. -type IpfixExporterDump struct{} - -func (m *IpfixExporterDump) Reset() { *m = IpfixExporterDump{} } -func (*IpfixExporterDump) GetMessageName() string { return "ipfix_exporter_dump" } -func (*IpfixExporterDump) GetCrcString() string { return "51077d14" } -func (*IpfixExporterDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpfixFlush represents VPP binary API message 'ipfix_flush'. -type IpfixFlush struct{} - -func (m *IpfixFlush) Reset() { *m = IpfixFlush{} } -func (*IpfixFlush) GetMessageName() string { return "ipfix_flush" } -func (*IpfixFlush) GetCrcString() string { return "51077d14" } -func (*IpfixFlush) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpfixFlushReply represents VPP binary API message 'ipfix_flush_reply'. -type IpfixFlushReply struct { - Retval int32 -} - -func (m *IpfixFlushReply) Reset() { *m = IpfixFlushReply{} } -func (*IpfixFlushReply) GetMessageName() string { return "ipfix_flush_reply" } -func (*IpfixFlushReply) GetCrcString() string { return "e8d4e804" } -func (*IpfixFlushReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SetIpfixClassifyStream represents VPP binary API message 'set_ipfix_classify_stream'. -type SetIpfixClassifyStream struct { - DomainID uint32 - SrcPort uint16 -} - -func (m *SetIpfixClassifyStream) Reset() { *m = SetIpfixClassifyStream{} } -func (*SetIpfixClassifyStream) GetMessageName() string { return "set_ipfix_classify_stream" } -func (*SetIpfixClassifyStream) GetCrcString() string { return "c9cbe053" } -func (*SetIpfixClassifyStream) GetMessageType() api.MessageType { return api.RequestMessage } - -// SetIpfixClassifyStreamReply represents VPP binary API message 'set_ipfix_classify_stream_reply'. -type SetIpfixClassifyStreamReply struct { - Retval int32 -} - -func (m *SetIpfixClassifyStreamReply) Reset() { *m = SetIpfixClassifyStreamReply{} } -func (*SetIpfixClassifyStreamReply) GetMessageName() string { return "set_ipfix_classify_stream_reply" } -func (*SetIpfixClassifyStreamReply) GetCrcString() string { return "e8d4e804" } -func (*SetIpfixClassifyStreamReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SetIpfixExporter represents VPP binary API message 'set_ipfix_exporter'. -type SetIpfixExporter struct { - CollectorAddress Address - CollectorPort uint16 - SrcAddress Address - VrfID uint32 - PathMtu uint32 - TemplateInterval uint32 - UDPChecksum bool -} - -func (m *SetIpfixExporter) Reset() { *m = SetIpfixExporter{} } -func (*SetIpfixExporter) GetMessageName() string { return "set_ipfix_exporter" } -func (*SetIpfixExporter) GetCrcString() string { return "69284e07" } -func (*SetIpfixExporter) GetMessageType() api.MessageType { return api.RequestMessage } - -// SetIpfixExporterReply represents VPP binary API message 'set_ipfix_exporter_reply'. -type SetIpfixExporterReply struct { - Retval int32 -} - -func (m *SetIpfixExporterReply) Reset() { *m = SetIpfixExporterReply{} } -func (*SetIpfixExporterReply) GetMessageName() string { return "set_ipfix_exporter_reply" } -func (*SetIpfixExporterReply) GetCrcString() string { return "e8d4e804" } -func (*SetIpfixExporterReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*IpfixClassifyStreamDetails)(nil), "ipfix_export.IpfixClassifyStreamDetails") - api.RegisterMessage((*IpfixClassifyStreamDump)(nil), "ipfix_export.IpfixClassifyStreamDump") - api.RegisterMessage((*IpfixClassifyTableAddDel)(nil), "ipfix_export.IpfixClassifyTableAddDel") - api.RegisterMessage((*IpfixClassifyTableAddDelReply)(nil), "ipfix_export.IpfixClassifyTableAddDelReply") - api.RegisterMessage((*IpfixClassifyTableDetails)(nil), "ipfix_export.IpfixClassifyTableDetails") - api.RegisterMessage((*IpfixClassifyTableDump)(nil), "ipfix_export.IpfixClassifyTableDump") - api.RegisterMessage((*IpfixExporterDetails)(nil), "ipfix_export.IpfixExporterDetails") - api.RegisterMessage((*IpfixExporterDump)(nil), "ipfix_export.IpfixExporterDump") - api.RegisterMessage((*IpfixFlush)(nil), "ipfix_export.IpfixFlush") - api.RegisterMessage((*IpfixFlushReply)(nil), "ipfix_export.IpfixFlushReply") - api.RegisterMessage((*SetIpfixClassifyStream)(nil), "ipfix_export.SetIpfixClassifyStream") - api.RegisterMessage((*SetIpfixClassifyStreamReply)(nil), "ipfix_export.SetIpfixClassifyStreamReply") - api.RegisterMessage((*SetIpfixExporter)(nil), "ipfix_export.SetIpfixExporter") - api.RegisterMessage((*SetIpfixExporterReply)(nil), "ipfix_export.SetIpfixExporterReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*IpfixClassifyStreamDetails)(nil), - (*IpfixClassifyStreamDump)(nil), - (*IpfixClassifyTableAddDel)(nil), - (*IpfixClassifyTableAddDelReply)(nil), - (*IpfixClassifyTableDetails)(nil), - (*IpfixClassifyTableDump)(nil), - (*IpfixExporterDetails)(nil), - (*IpfixExporterDump)(nil), - (*IpfixFlush)(nil), - (*IpfixFlushReply)(nil), - (*SetIpfixClassifyStream)(nil), - (*SetIpfixClassifyStreamReply)(nil), - (*SetIpfixExporter)(nil), - (*SetIpfixExporterReply)(nil), - } -} - -// RPCService represents RPC service API for ipfix_export module. -type RPCService interface { - DumpIpfixClassifyStream(ctx context.Context, in *IpfixClassifyStreamDump) (RPCService_DumpIpfixClassifyStreamClient, error) - DumpIpfixClassifyTable(ctx context.Context, in *IpfixClassifyTableDump) (RPCService_DumpIpfixClassifyTableClient, error) - DumpIpfixExporter(ctx context.Context, in *IpfixExporterDump) (RPCService_DumpIpfixExporterClient, error) - IpfixClassifyTableAddDel(ctx context.Context, in *IpfixClassifyTableAddDel) (*IpfixClassifyTableAddDelReply, error) - IpfixFlush(ctx context.Context, in *IpfixFlush) (*IpfixFlushReply, error) - SetIpfixClassifyStream(ctx context.Context, in *SetIpfixClassifyStream) (*SetIpfixClassifyStreamReply, error) - SetIpfixExporter(ctx context.Context, in *SetIpfixExporter) (*SetIpfixExporterReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpIpfixClassifyStream(ctx context.Context, in *IpfixClassifyStreamDump) (RPCService_DumpIpfixClassifyStreamClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpfixClassifyStreamClient{stream} - return x, nil -} - -type RPCService_DumpIpfixClassifyStreamClient interface { - Recv() (*IpfixClassifyStreamDetails, error) -} - -type serviceClient_DumpIpfixClassifyStreamClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpfixClassifyStreamClient) Recv() (*IpfixClassifyStreamDetails, error) { - m := new(IpfixClassifyStreamDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIpfixClassifyTable(ctx context.Context, in *IpfixClassifyTableDump) (RPCService_DumpIpfixClassifyTableClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpfixClassifyTableClient{stream} - return x, nil -} - -type RPCService_DumpIpfixClassifyTableClient interface { - Recv() (*IpfixClassifyTableDetails, error) -} - -type serviceClient_DumpIpfixClassifyTableClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpfixClassifyTableClient) Recv() (*IpfixClassifyTableDetails, error) { - m := new(IpfixClassifyTableDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIpfixExporter(ctx context.Context, in *IpfixExporterDump) (RPCService_DumpIpfixExporterClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpfixExporterClient{stream} - return x, nil -} - -type RPCService_DumpIpfixExporterClient interface { - Recv() (*IpfixExporterDetails, error) -} - -type serviceClient_DumpIpfixExporterClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpfixExporterClient) Recv() (*IpfixExporterDetails, error) { - m := new(IpfixExporterDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) IpfixClassifyTableAddDel(ctx context.Context, in *IpfixClassifyTableAddDel) (*IpfixClassifyTableAddDelReply, error) { - out := new(IpfixClassifyTableAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpfixFlush(ctx context.Context, in *IpfixFlush) (*IpfixFlushReply, error) { - out := new(IpfixFlushReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SetIpfixClassifyStream(ctx context.Context, in *SetIpfixClassifyStream) (*SetIpfixClassifyStreamReply, error) { - out := new(SetIpfixClassifyStreamReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SetIpfixExporter(ctx context.Context, in *SetIpfixExporter) (*SetIpfixExporterReply, error) { - out := new(SetIpfixExporterReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ipip/ipip.ba.go b/plugins/vpp/binapi/vpp2001/ipip/ipip.ba.go deleted file mode 100644 index 7e6236f044..0000000000 --- a/plugins/vpp/binapi/vpp2001/ipip/ipip.ba.go +++ /dev/null @@ -1,364 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ipip.api.json - -/* -Package ipip is a generated VPP binary API for 'ipip' module. - -It consists of: - 11 enums - 6 aliases - 7 types - 1 union - 10 messages - 5 services -*/ -package ipip - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ipip" - // APIVersion is the API version of this module. - APIVersion = "2.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xf108649c -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -// IpipTunnelFlags represents VPP binary API enum 'ipip_tunnel_flags'. -type IpipTunnelFlags uint8 - -const ( - IPIP_TUNNEL_API_FLAG_NONE IpipTunnelFlags = 0 - IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF IpipTunnelFlags = 1 - IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF IpipTunnelFlags = 2 - IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP IpipTunnelFlags = 4 - IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN IpipTunnelFlags = 8 - IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN IpipTunnelFlags = 16 -) - -var IpipTunnelFlags_name = map[uint8]string{ - 0: "IPIP_TUNNEL_API_FLAG_NONE", - 1: "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF", - 2: "IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF", - 4: "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP", - 8: "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN", - 16: "IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN", -} - -var IpipTunnelFlags_value = map[string]uint8{ - "IPIP_TUNNEL_API_FLAG_NONE": 0, - "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DF": 1, - "IPIP_TUNNEL_API_FLAG_ENCAP_SET_DF": 2, - "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_DSCP": 4, - "IPIP_TUNNEL_API_FLAG_ENCAP_COPY_ECN": 8, - "IPIP_TUNNEL_API_FLAG_DECAP_COPY_ECN": 16, -} - -func (x IpipTunnelFlags) String() string { - s, ok := IpipTunnelFlags_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -// IpipTunnel represents VPP binary API type 'ipip_tunnel'. -type IpipTunnel struct { - Instance uint32 - Src Address - Dst Address - SwIfIndex InterfaceIndex - TableID uint32 - Flags IpipTunnelFlags - Dscp IPDscp -} - -func (*IpipTunnel) GetTypeName() string { return "ipip_tunnel" } - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// Ipip6rdAddTunnel represents VPP binary API message 'ipip_6rd_add_tunnel'. -type Ipip6rdAddTunnel struct { - IP6TableID uint32 - IP4TableID uint32 - IP6Prefix IP6Prefix - IP4Prefix IP4Prefix - IP4Src IP4Address - SecurityCheck bool - TcTos uint8 -} - -func (m *Ipip6rdAddTunnel) Reset() { *m = Ipip6rdAddTunnel{} } -func (*Ipip6rdAddTunnel) GetMessageName() string { return "ipip_6rd_add_tunnel" } -func (*Ipip6rdAddTunnel) GetCrcString() string { return "56e93cc0" } -func (*Ipip6rdAddTunnel) GetMessageType() api.MessageType { return api.RequestMessage } - -// Ipip6rdAddTunnelReply represents VPP binary API message 'ipip_6rd_add_tunnel_reply'. -type Ipip6rdAddTunnelReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *Ipip6rdAddTunnelReply) Reset() { *m = Ipip6rdAddTunnelReply{} } -func (*Ipip6rdAddTunnelReply) GetMessageName() string { return "ipip_6rd_add_tunnel_reply" } -func (*Ipip6rdAddTunnelReply) GetCrcString() string { return "5383d31f" } -func (*Ipip6rdAddTunnelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Ipip6rdDelTunnel represents VPP binary API message 'ipip_6rd_del_tunnel'. -type Ipip6rdDelTunnel struct { - SwIfIndex InterfaceIndex -} - -func (m *Ipip6rdDelTunnel) Reset() { *m = Ipip6rdDelTunnel{} } -func (*Ipip6rdDelTunnel) GetMessageName() string { return "ipip_6rd_del_tunnel" } -func (*Ipip6rdDelTunnel) GetCrcString() string { return "f9e6675e" } -func (*Ipip6rdDelTunnel) GetMessageType() api.MessageType { return api.RequestMessage } - -// Ipip6rdDelTunnelReply represents VPP binary API message 'ipip_6rd_del_tunnel_reply'. -type Ipip6rdDelTunnelReply struct { - Retval int32 -} - -func (m *Ipip6rdDelTunnelReply) Reset() { *m = Ipip6rdDelTunnelReply{} } -func (*Ipip6rdDelTunnelReply) GetMessageName() string { return "ipip_6rd_del_tunnel_reply" } -func (*Ipip6rdDelTunnelReply) GetCrcString() string { return "e8d4e804" } -func (*Ipip6rdDelTunnelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpipAddTunnel represents VPP binary API message 'ipip_add_tunnel'. -type IpipAddTunnel struct { - Tunnel IpipTunnel -} - -func (m *IpipAddTunnel) Reset() { *m = IpipAddTunnel{} } -func (*IpipAddTunnel) GetMessageName() string { return "ipip_add_tunnel" } -func (*IpipAddTunnel) GetCrcString() string { return "ef93caab" } -func (*IpipAddTunnel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpipAddTunnelReply represents VPP binary API message 'ipip_add_tunnel_reply'. -type IpipAddTunnelReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *IpipAddTunnelReply) Reset() { *m = IpipAddTunnelReply{} } -func (*IpipAddTunnelReply) GetMessageName() string { return "ipip_add_tunnel_reply" } -func (*IpipAddTunnelReply) GetCrcString() string { return "5383d31f" } -func (*IpipAddTunnelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpipDelTunnel represents VPP binary API message 'ipip_del_tunnel'. -type IpipDelTunnel struct { - SwIfIndex InterfaceIndex -} - -func (m *IpipDelTunnel) Reset() { *m = IpipDelTunnel{} } -func (*IpipDelTunnel) GetMessageName() string { return "ipip_del_tunnel" } -func (*IpipDelTunnel) GetCrcString() string { return "f9e6675e" } -func (*IpipDelTunnel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpipDelTunnelReply represents VPP binary API message 'ipip_del_tunnel_reply'. -type IpipDelTunnelReply struct { - Retval int32 -} - -func (m *IpipDelTunnelReply) Reset() { *m = IpipDelTunnelReply{} } -func (*IpipDelTunnelReply) GetMessageName() string { return "ipip_del_tunnel_reply" } -func (*IpipDelTunnelReply) GetCrcString() string { return "e8d4e804" } -func (*IpipDelTunnelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpipTunnelDetails represents VPP binary API message 'ipip_tunnel_details'. -type IpipTunnelDetails struct { - Tunnel IpipTunnel -} - -func (m *IpipTunnelDetails) Reset() { *m = IpipTunnelDetails{} } -func (*IpipTunnelDetails) GetMessageName() string { return "ipip_tunnel_details" } -func (*IpipTunnelDetails) GetCrcString() string { return "7f7b5b85" } -func (*IpipTunnelDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpipTunnelDump represents VPP binary API message 'ipip_tunnel_dump'. -type IpipTunnelDump struct { - SwIfIndex InterfaceIndex -} - -func (m *IpipTunnelDump) Reset() { *m = IpipTunnelDump{} } -func (*IpipTunnelDump) GetMessageName() string { return "ipip_tunnel_dump" } -func (*IpipTunnelDump) GetCrcString() string { return "f9e6675e" } -func (*IpipTunnelDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*Ipip6rdAddTunnel)(nil), "ipip.Ipip6rdAddTunnel") - api.RegisterMessage((*Ipip6rdAddTunnelReply)(nil), "ipip.Ipip6rdAddTunnelReply") - api.RegisterMessage((*Ipip6rdDelTunnel)(nil), "ipip.Ipip6rdDelTunnel") - api.RegisterMessage((*Ipip6rdDelTunnelReply)(nil), "ipip.Ipip6rdDelTunnelReply") - api.RegisterMessage((*IpipAddTunnel)(nil), "ipip.IpipAddTunnel") - api.RegisterMessage((*IpipAddTunnelReply)(nil), "ipip.IpipAddTunnelReply") - api.RegisterMessage((*IpipDelTunnel)(nil), "ipip.IpipDelTunnel") - api.RegisterMessage((*IpipDelTunnelReply)(nil), "ipip.IpipDelTunnelReply") - api.RegisterMessage((*IpipTunnelDetails)(nil), "ipip.IpipTunnelDetails") - api.RegisterMessage((*IpipTunnelDump)(nil), "ipip.IpipTunnelDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*Ipip6rdAddTunnel)(nil), - (*Ipip6rdAddTunnelReply)(nil), - (*Ipip6rdDelTunnel)(nil), - (*Ipip6rdDelTunnelReply)(nil), - (*IpipAddTunnel)(nil), - (*IpipAddTunnelReply)(nil), - (*IpipDelTunnel)(nil), - (*IpipDelTunnelReply)(nil), - (*IpipTunnelDetails)(nil), - (*IpipTunnelDump)(nil), - } -} - -// RPCService represents RPC service API for ipip module. -type RPCService interface { - DumpIpipTunnel(ctx context.Context, in *IpipTunnelDump) (RPCService_DumpIpipTunnelClient, error) - Ipip6rdAddTunnel(ctx context.Context, in *Ipip6rdAddTunnel) (*Ipip6rdAddTunnelReply, error) - Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunnel) (*Ipip6rdDelTunnelReply, error) - IpipAddTunnel(ctx context.Context, in *IpipAddTunnel) (*IpipAddTunnelReply, error) - IpipDelTunnel(ctx context.Context, in *IpipDelTunnel) (*IpipDelTunnelReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpIpipTunnel(ctx context.Context, in *IpipTunnelDump) (RPCService_DumpIpipTunnelClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpipTunnelClient{stream} - return x, nil -} - -type RPCService_DumpIpipTunnelClient interface { - Recv() (*IpipTunnelDetails, error) -} - -type serviceClient_DumpIpipTunnelClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpipTunnelClient) Recv() (*IpipTunnelDetails, error) { - m := new(IpipTunnelDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) Ipip6rdAddTunnel(ctx context.Context, in *Ipip6rdAddTunnel) (*Ipip6rdAddTunnelReply, error) { - out := new(Ipip6rdAddTunnelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Ipip6rdDelTunnel(ctx context.Context, in *Ipip6rdDelTunnel) (*Ipip6rdDelTunnelReply, error) { - out := new(Ipip6rdDelTunnelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpipAddTunnel(ctx context.Context, in *IpipAddTunnel) (*IpipAddTunnelReply, error) { - out := new(IpipAddTunnelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpipDelTunnel(ctx context.Context, in *IpipDelTunnel) (*IpipDelTunnelReply, error) { - out := new(IpipDelTunnelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ipsec/ipsec.ba.go b/plugins/vpp/binapi/vpp2001/ipsec/ipsec.ba.go deleted file mode 100644 index 980c29a724..0000000000 --- a/plugins/vpp/binapi/vpp2001/ipsec/ipsec.ba.go +++ /dev/null @@ -1,850 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ipsec.api.json - -/* -Package ipsec is a generated VPP binary API for 'ipsec' module. - -It consists of: - 15 enums - 6 aliases - 10 types - 1 union - 30 messages - 15 services -*/ -package ipsec - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - ipsec_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ipsec" - // APIVersion is the API version of this module. - APIVersion = "3.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x5a59fef9 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type IpsecCryptoAlg = ipsec_types.IpsecCryptoAlg - -type IpsecIntegAlg = ipsec_types.IpsecIntegAlg - -type IpsecProto = ipsec_types.IpsecProto - -type IpsecSadFlags = ipsec_types.IpsecSadFlags - -// IpsecSpdAction represents VPP binary API enum 'ipsec_spd_action'. -type IpsecSpdAction uint32 - -const ( - IPSEC_API_SPD_ACTION_BYPASS IpsecSpdAction = 0 - IPSEC_API_SPD_ACTION_DISCARD IpsecSpdAction = 1 - IPSEC_API_SPD_ACTION_RESOLVE IpsecSpdAction = 2 - IPSEC_API_SPD_ACTION_PROTECT IpsecSpdAction = 3 -) - -var IpsecSpdAction_name = map[uint32]string{ - 0: "IPSEC_API_SPD_ACTION_BYPASS", - 1: "IPSEC_API_SPD_ACTION_DISCARD", - 2: "IPSEC_API_SPD_ACTION_RESOLVE", - 3: "IPSEC_API_SPD_ACTION_PROTECT", -} - -var IpsecSpdAction_value = map[string]uint32{ - "IPSEC_API_SPD_ACTION_BYPASS": 0, - "IPSEC_API_SPD_ACTION_DISCARD": 1, - "IPSEC_API_SPD_ACTION_RESOLVE": 2, - "IPSEC_API_SPD_ACTION_PROTECT": 3, -} - -func (x IpsecSpdAction) String() string { - s, ok := IpsecSpdAction_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type IpsecSadEntry = ipsec_types.IpsecSadEntry - -// IpsecSpdEntry represents VPP binary API type 'ipsec_spd_entry'. -type IpsecSpdEntry struct { - SpdID uint32 - Priority int32 - IsOutbound uint8 - SaID uint32 - Policy IpsecSpdAction - Protocol uint8 - RemoteAddressStart Address - RemoteAddressStop Address - LocalAddressStart Address - LocalAddressStop Address - RemotePortStart uint16 - RemotePortStop uint16 - LocalPortStart uint16 - LocalPortStop uint16 -} - -func (*IpsecSpdEntry) GetTypeName() string { return "ipsec_spd_entry" } - -// IpsecTunnelProtect represents VPP binary API type 'ipsec_tunnel_protect'. -type IpsecTunnelProtect struct { - SwIfIndex InterfaceIndex - SaOut uint32 - NSaIn uint8 `struc:"sizeof=SaIn"` - SaIn []uint32 -} - -func (*IpsecTunnelProtect) GetTypeName() string { return "ipsec_tunnel_protect" } - -type Key = ipsec_types.Key - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// IpsecBackendDetails represents VPP binary API message 'ipsec_backend_details'. -type IpsecBackendDetails struct { - Name []byte `struc:"[128]byte"` - Protocol IpsecProto - Index uint8 - Active uint8 -} - -func (m *IpsecBackendDetails) Reset() { *m = IpsecBackendDetails{} } -func (*IpsecBackendDetails) GetMessageName() string { return "ipsec_backend_details" } -func (*IpsecBackendDetails) GetCrcString() string { return "7700751c" } -func (*IpsecBackendDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecBackendDump represents VPP binary API message 'ipsec_backend_dump'. -type IpsecBackendDump struct{} - -func (m *IpsecBackendDump) Reset() { *m = IpsecBackendDump{} } -func (*IpsecBackendDump) GetMessageName() string { return "ipsec_backend_dump" } -func (*IpsecBackendDump) GetCrcString() string { return "51077d14" } -func (*IpsecBackendDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecInterfaceAddDelSpd represents VPP binary API message 'ipsec_interface_add_del_spd'. -type IpsecInterfaceAddDelSpd struct { - IsAdd uint8 - SwIfIndex uint32 - SpdID uint32 -} - -func (m *IpsecInterfaceAddDelSpd) Reset() { *m = IpsecInterfaceAddDelSpd{} } -func (*IpsecInterfaceAddDelSpd) GetMessageName() string { return "ipsec_interface_add_del_spd" } -func (*IpsecInterfaceAddDelSpd) GetCrcString() string { return "1e3b8286" } -func (*IpsecInterfaceAddDelSpd) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecInterfaceAddDelSpdReply represents VPP binary API message 'ipsec_interface_add_del_spd_reply'. -type IpsecInterfaceAddDelSpdReply struct { - Retval int32 -} - -func (m *IpsecInterfaceAddDelSpdReply) Reset() { *m = IpsecInterfaceAddDelSpdReply{} } -func (*IpsecInterfaceAddDelSpdReply) GetMessageName() string { - return "ipsec_interface_add_del_spd_reply" -} -func (*IpsecInterfaceAddDelSpdReply) GetCrcString() string { return "e8d4e804" } -func (*IpsecInterfaceAddDelSpdReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSaDetails represents VPP binary API message 'ipsec_sa_details'. -type IpsecSaDetails struct { - Entry IpsecSadEntry - SwIfIndex uint32 - Salt uint32 - SeqOutbound uint64 - LastSeqInbound uint64 - ReplayWindow uint64 - TotalDataSize uint64 -} - -func (m *IpsecSaDetails) Reset() { *m = IpsecSaDetails{} } -func (*IpsecSaDetails) GetMessageName() string { return "ipsec_sa_details" } -func (*IpsecSaDetails) GetCrcString() string { return "9c8d829a" } -func (*IpsecSaDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSaDump represents VPP binary API message 'ipsec_sa_dump'. -type IpsecSaDump struct { - SaID uint32 -} - -func (m *IpsecSaDump) Reset() { *m = IpsecSaDump{} } -func (*IpsecSaDump) GetMessageName() string { return "ipsec_sa_dump" } -func (*IpsecSaDump) GetCrcString() string { return "2076c2f4" } -func (*IpsecSaDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecSadEntryAddDel represents VPP binary API message 'ipsec_sad_entry_add_del'. -type IpsecSadEntryAddDel struct { - IsAdd uint8 - Entry IpsecSadEntry -} - -func (m *IpsecSadEntryAddDel) Reset() { *m = IpsecSadEntryAddDel{} } -func (*IpsecSadEntryAddDel) GetMessageName() string { return "ipsec_sad_entry_add_del" } -func (*IpsecSadEntryAddDel) GetCrcString() string { return "a25ab61e" } -func (*IpsecSadEntryAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecSadEntryAddDelReply represents VPP binary API message 'ipsec_sad_entry_add_del_reply'. -type IpsecSadEntryAddDelReply struct { - Retval int32 - StatIndex uint32 -} - -func (m *IpsecSadEntryAddDelReply) Reset() { *m = IpsecSadEntryAddDelReply{} } -func (*IpsecSadEntryAddDelReply) GetMessageName() string { return "ipsec_sad_entry_add_del_reply" } -func (*IpsecSadEntryAddDelReply) GetCrcString() string { return "9ffac24b" } -func (*IpsecSadEntryAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSelectBackend represents VPP binary API message 'ipsec_select_backend'. -type IpsecSelectBackend struct { - Protocol IpsecProto - Index uint8 -} - -func (m *IpsecSelectBackend) Reset() { *m = IpsecSelectBackend{} } -func (*IpsecSelectBackend) GetMessageName() string { return "ipsec_select_backend" } -func (*IpsecSelectBackend) GetCrcString() string { return "4fd24836" } -func (*IpsecSelectBackend) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecSelectBackendReply represents VPP binary API message 'ipsec_select_backend_reply'. -type IpsecSelectBackendReply struct { - Retval int32 -} - -func (m *IpsecSelectBackendReply) Reset() { *m = IpsecSelectBackendReply{} } -func (*IpsecSelectBackendReply) GetMessageName() string { return "ipsec_select_backend_reply" } -func (*IpsecSelectBackendReply) GetCrcString() string { return "e8d4e804" } -func (*IpsecSelectBackendReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSpdAddDel represents VPP binary API message 'ipsec_spd_add_del'. -type IpsecSpdAddDel struct { - IsAdd uint8 - SpdID uint32 -} - -func (m *IpsecSpdAddDel) Reset() { *m = IpsecSpdAddDel{} } -func (*IpsecSpdAddDel) GetMessageName() string { return "ipsec_spd_add_del" } -func (*IpsecSpdAddDel) GetCrcString() string { return "9ffdf5da" } -func (*IpsecSpdAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecSpdAddDelReply represents VPP binary API message 'ipsec_spd_add_del_reply'. -type IpsecSpdAddDelReply struct { - Retval int32 -} - -func (m *IpsecSpdAddDelReply) Reset() { *m = IpsecSpdAddDelReply{} } -func (*IpsecSpdAddDelReply) GetMessageName() string { return "ipsec_spd_add_del_reply" } -func (*IpsecSpdAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IpsecSpdAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSpdDetails represents VPP binary API message 'ipsec_spd_details'. -type IpsecSpdDetails struct { - Entry IpsecSpdEntry -} - -func (m *IpsecSpdDetails) Reset() { *m = IpsecSpdDetails{} } -func (*IpsecSpdDetails) GetMessageName() string { return "ipsec_spd_details" } -func (*IpsecSpdDetails) GetCrcString() string { return "021e2c20" } -func (*IpsecSpdDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSpdDump represents VPP binary API message 'ipsec_spd_dump'. -type IpsecSpdDump struct { - SpdID uint32 - SaID uint32 -} - -func (m *IpsecSpdDump) Reset() { *m = IpsecSpdDump{} } -func (*IpsecSpdDump) GetMessageName() string { return "ipsec_spd_dump" } -func (*IpsecSpdDump) GetCrcString() string { return "afefbf7d" } -func (*IpsecSpdDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecSpdEntryAddDel represents VPP binary API message 'ipsec_spd_entry_add_del'. -type IpsecSpdEntryAddDel struct { - IsAdd uint8 - Entry IpsecSpdEntry -} - -func (m *IpsecSpdEntryAddDel) Reset() { *m = IpsecSpdEntryAddDel{} } -func (*IpsecSpdEntryAddDel) GetMessageName() string { return "ipsec_spd_entry_add_del" } -func (*IpsecSpdEntryAddDel) GetCrcString() string { return "db217840" } -func (*IpsecSpdEntryAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecSpdEntryAddDelReply represents VPP binary API message 'ipsec_spd_entry_add_del_reply'. -type IpsecSpdEntryAddDelReply struct { - Retval int32 - StatIndex uint32 -} - -func (m *IpsecSpdEntryAddDelReply) Reset() { *m = IpsecSpdEntryAddDelReply{} } -func (*IpsecSpdEntryAddDelReply) GetMessageName() string { return "ipsec_spd_entry_add_del_reply" } -func (*IpsecSpdEntryAddDelReply) GetCrcString() string { return "9ffac24b" } -func (*IpsecSpdEntryAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSpdInterfaceDetails represents VPP binary API message 'ipsec_spd_interface_details'. -type IpsecSpdInterfaceDetails struct { - SpdIndex uint32 - SwIfIndex uint32 -} - -func (m *IpsecSpdInterfaceDetails) Reset() { *m = IpsecSpdInterfaceDetails{} } -func (*IpsecSpdInterfaceDetails) GetMessageName() string { return "ipsec_spd_interface_details" } -func (*IpsecSpdInterfaceDetails) GetCrcString() string { return "2c54296d" } -func (*IpsecSpdInterfaceDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSpdInterfaceDump represents VPP binary API message 'ipsec_spd_interface_dump'. -type IpsecSpdInterfaceDump struct { - SpdIndex uint32 - SpdIndexValid uint8 -} - -func (m *IpsecSpdInterfaceDump) Reset() { *m = IpsecSpdInterfaceDump{} } -func (*IpsecSpdInterfaceDump) GetMessageName() string { return "ipsec_spd_interface_dump" } -func (*IpsecSpdInterfaceDump) GetCrcString() string { return "8971de19" } -func (*IpsecSpdInterfaceDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecSpdsDetails represents VPP binary API message 'ipsec_spds_details'. -type IpsecSpdsDetails struct { - SpdID uint32 - Npolicies uint32 -} - -func (m *IpsecSpdsDetails) Reset() { *m = IpsecSpdsDetails{} } -func (*IpsecSpdsDetails) GetMessageName() string { return "ipsec_spds_details" } -func (*IpsecSpdsDetails) GetCrcString() string { return "a04bb254" } -func (*IpsecSpdsDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecSpdsDump represents VPP binary API message 'ipsec_spds_dump'. -type IpsecSpdsDump struct{} - -func (m *IpsecSpdsDump) Reset() { *m = IpsecSpdsDump{} } -func (*IpsecSpdsDump) GetMessageName() string { return "ipsec_spds_dump" } -func (*IpsecSpdsDump) GetCrcString() string { return "51077d14" } -func (*IpsecSpdsDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecTunnelIfAddDel represents VPP binary API message 'ipsec_tunnel_if_add_del'. -type IpsecTunnelIfAddDel struct { - IsAdd uint8 - Esn uint8 - AntiReplay uint8 - LocalIP Address - RemoteIP Address - LocalSpi uint32 - RemoteSpi uint32 - CryptoAlg uint8 - LocalCryptoKeyLen uint8 - LocalCryptoKey []byte `struc:"[128]byte"` - RemoteCryptoKeyLen uint8 - RemoteCryptoKey []byte `struc:"[128]byte"` - IntegAlg uint8 - LocalIntegKeyLen uint8 - LocalIntegKey []byte `struc:"[128]byte"` - RemoteIntegKeyLen uint8 - RemoteIntegKey []byte `struc:"[128]byte"` - Renumber uint8 - ShowInstance uint32 - UDPEncap uint8 - TxTableID uint32 - Salt uint32 -} - -func (m *IpsecTunnelIfAddDel) Reset() { *m = IpsecTunnelIfAddDel{} } -func (*IpsecTunnelIfAddDel) GetMessageName() string { return "ipsec_tunnel_if_add_del" } -func (*IpsecTunnelIfAddDel) GetCrcString() string { return "d5a98274" } -func (*IpsecTunnelIfAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecTunnelIfAddDelReply represents VPP binary API message 'ipsec_tunnel_if_add_del_reply'. -type IpsecTunnelIfAddDelReply struct { - Retval int32 - SwIfIndex uint32 -} - -func (m *IpsecTunnelIfAddDelReply) Reset() { *m = IpsecTunnelIfAddDelReply{} } -func (*IpsecTunnelIfAddDelReply) GetMessageName() string { return "ipsec_tunnel_if_add_del_reply" } -func (*IpsecTunnelIfAddDelReply) GetCrcString() string { return "fda5941f" } -func (*IpsecTunnelIfAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecTunnelIfSetSa represents VPP binary API message 'ipsec_tunnel_if_set_sa'. -type IpsecTunnelIfSetSa struct { - SwIfIndex uint32 - SaID uint32 - IsOutbound uint8 -} - -func (m *IpsecTunnelIfSetSa) Reset() { *m = IpsecTunnelIfSetSa{} } -func (*IpsecTunnelIfSetSa) GetMessageName() string { return "ipsec_tunnel_if_set_sa" } -func (*IpsecTunnelIfSetSa) GetCrcString() string { return "6ab567f2" } -func (*IpsecTunnelIfSetSa) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecTunnelIfSetSaReply represents VPP binary API message 'ipsec_tunnel_if_set_sa_reply'. -type IpsecTunnelIfSetSaReply struct { - Retval int32 -} - -func (m *IpsecTunnelIfSetSaReply) Reset() { *m = IpsecTunnelIfSetSaReply{} } -func (*IpsecTunnelIfSetSaReply) GetMessageName() string { return "ipsec_tunnel_if_set_sa_reply" } -func (*IpsecTunnelIfSetSaReply) GetCrcString() string { return "e8d4e804" } -func (*IpsecTunnelIfSetSaReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecTunnelProtectDel represents VPP binary API message 'ipsec_tunnel_protect_del'. -type IpsecTunnelProtectDel struct { - SwIfIndex InterfaceIndex -} - -func (m *IpsecTunnelProtectDel) Reset() { *m = IpsecTunnelProtectDel{} } -func (*IpsecTunnelProtectDel) GetMessageName() string { return "ipsec_tunnel_protect_del" } -func (*IpsecTunnelProtectDel) GetCrcString() string { return "f9e6675e" } -func (*IpsecTunnelProtectDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecTunnelProtectDelReply represents VPP binary API message 'ipsec_tunnel_protect_del_reply'. -type IpsecTunnelProtectDelReply struct { - Retval int32 -} - -func (m *IpsecTunnelProtectDelReply) Reset() { *m = IpsecTunnelProtectDelReply{} } -func (*IpsecTunnelProtectDelReply) GetMessageName() string { return "ipsec_tunnel_protect_del_reply" } -func (*IpsecTunnelProtectDelReply) GetCrcString() string { return "e8d4e804" } -func (*IpsecTunnelProtectDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecTunnelProtectDetails represents VPP binary API message 'ipsec_tunnel_protect_details'. -type IpsecTunnelProtectDetails struct { - Tun IpsecTunnelProtect -} - -func (m *IpsecTunnelProtectDetails) Reset() { *m = IpsecTunnelProtectDetails{} } -func (*IpsecTunnelProtectDetails) GetMessageName() string { return "ipsec_tunnel_protect_details" } -func (*IpsecTunnelProtectDetails) GetCrcString() string { return "7520eefe" } -func (*IpsecTunnelProtectDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// IpsecTunnelProtectDump represents VPP binary API message 'ipsec_tunnel_protect_dump'. -type IpsecTunnelProtectDump struct { - SwIfIndex InterfaceIndex -} - -func (m *IpsecTunnelProtectDump) Reset() { *m = IpsecTunnelProtectDump{} } -func (*IpsecTunnelProtectDump) GetMessageName() string { return "ipsec_tunnel_protect_dump" } -func (*IpsecTunnelProtectDump) GetCrcString() string { return "f9e6675e" } -func (*IpsecTunnelProtectDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecTunnelProtectUpdate represents VPP binary API message 'ipsec_tunnel_protect_update'. -type IpsecTunnelProtectUpdate struct { - Tunnel IpsecTunnelProtect -} - -func (m *IpsecTunnelProtectUpdate) Reset() { *m = IpsecTunnelProtectUpdate{} } -func (*IpsecTunnelProtectUpdate) GetMessageName() string { return "ipsec_tunnel_protect_update" } -func (*IpsecTunnelProtectUpdate) GetCrcString() string { return "eccbc177" } -func (*IpsecTunnelProtectUpdate) GetMessageType() api.MessageType { return api.RequestMessage } - -// IpsecTunnelProtectUpdateReply represents VPP binary API message 'ipsec_tunnel_protect_update_reply'. -type IpsecTunnelProtectUpdateReply struct { - Retval int32 -} - -func (m *IpsecTunnelProtectUpdateReply) Reset() { *m = IpsecTunnelProtectUpdateReply{} } -func (*IpsecTunnelProtectUpdateReply) GetMessageName() string { - return "ipsec_tunnel_protect_update_reply" -} -func (*IpsecTunnelProtectUpdateReply) GetCrcString() string { return "e8d4e804" } -func (*IpsecTunnelProtectUpdateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*IpsecBackendDetails)(nil), "ipsec.IpsecBackendDetails") - api.RegisterMessage((*IpsecBackendDump)(nil), "ipsec.IpsecBackendDump") - api.RegisterMessage((*IpsecInterfaceAddDelSpd)(nil), "ipsec.IpsecInterfaceAddDelSpd") - api.RegisterMessage((*IpsecInterfaceAddDelSpdReply)(nil), "ipsec.IpsecInterfaceAddDelSpdReply") - api.RegisterMessage((*IpsecSaDetails)(nil), "ipsec.IpsecSaDetails") - api.RegisterMessage((*IpsecSaDump)(nil), "ipsec.IpsecSaDump") - api.RegisterMessage((*IpsecSadEntryAddDel)(nil), "ipsec.IpsecSadEntryAddDel") - api.RegisterMessage((*IpsecSadEntryAddDelReply)(nil), "ipsec.IpsecSadEntryAddDelReply") - api.RegisterMessage((*IpsecSelectBackend)(nil), "ipsec.IpsecSelectBackend") - api.RegisterMessage((*IpsecSelectBackendReply)(nil), "ipsec.IpsecSelectBackendReply") - api.RegisterMessage((*IpsecSpdAddDel)(nil), "ipsec.IpsecSpdAddDel") - api.RegisterMessage((*IpsecSpdAddDelReply)(nil), "ipsec.IpsecSpdAddDelReply") - api.RegisterMessage((*IpsecSpdDetails)(nil), "ipsec.IpsecSpdDetails") - api.RegisterMessage((*IpsecSpdDump)(nil), "ipsec.IpsecSpdDump") - api.RegisterMessage((*IpsecSpdEntryAddDel)(nil), "ipsec.IpsecSpdEntryAddDel") - api.RegisterMessage((*IpsecSpdEntryAddDelReply)(nil), "ipsec.IpsecSpdEntryAddDelReply") - api.RegisterMessage((*IpsecSpdInterfaceDetails)(nil), "ipsec.IpsecSpdInterfaceDetails") - api.RegisterMessage((*IpsecSpdInterfaceDump)(nil), "ipsec.IpsecSpdInterfaceDump") - api.RegisterMessage((*IpsecSpdsDetails)(nil), "ipsec.IpsecSpdsDetails") - api.RegisterMessage((*IpsecSpdsDump)(nil), "ipsec.IpsecSpdsDump") - api.RegisterMessage((*IpsecTunnelIfAddDel)(nil), "ipsec.IpsecTunnelIfAddDel") - api.RegisterMessage((*IpsecTunnelIfAddDelReply)(nil), "ipsec.IpsecTunnelIfAddDelReply") - api.RegisterMessage((*IpsecTunnelIfSetSa)(nil), "ipsec.IpsecTunnelIfSetSa") - api.RegisterMessage((*IpsecTunnelIfSetSaReply)(nil), "ipsec.IpsecTunnelIfSetSaReply") - api.RegisterMessage((*IpsecTunnelProtectDel)(nil), "ipsec.IpsecTunnelProtectDel") - api.RegisterMessage((*IpsecTunnelProtectDelReply)(nil), "ipsec.IpsecTunnelProtectDelReply") - api.RegisterMessage((*IpsecTunnelProtectDetails)(nil), "ipsec.IpsecTunnelProtectDetails") - api.RegisterMessage((*IpsecTunnelProtectDump)(nil), "ipsec.IpsecTunnelProtectDump") - api.RegisterMessage((*IpsecTunnelProtectUpdate)(nil), "ipsec.IpsecTunnelProtectUpdate") - api.RegisterMessage((*IpsecTunnelProtectUpdateReply)(nil), "ipsec.IpsecTunnelProtectUpdateReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*IpsecBackendDetails)(nil), - (*IpsecBackendDump)(nil), - (*IpsecInterfaceAddDelSpd)(nil), - (*IpsecInterfaceAddDelSpdReply)(nil), - (*IpsecSaDetails)(nil), - (*IpsecSaDump)(nil), - (*IpsecSadEntryAddDel)(nil), - (*IpsecSadEntryAddDelReply)(nil), - (*IpsecSelectBackend)(nil), - (*IpsecSelectBackendReply)(nil), - (*IpsecSpdAddDel)(nil), - (*IpsecSpdAddDelReply)(nil), - (*IpsecSpdDetails)(nil), - (*IpsecSpdDump)(nil), - (*IpsecSpdEntryAddDel)(nil), - (*IpsecSpdEntryAddDelReply)(nil), - (*IpsecSpdInterfaceDetails)(nil), - (*IpsecSpdInterfaceDump)(nil), - (*IpsecSpdsDetails)(nil), - (*IpsecSpdsDump)(nil), - (*IpsecTunnelIfAddDel)(nil), - (*IpsecTunnelIfAddDelReply)(nil), - (*IpsecTunnelIfSetSa)(nil), - (*IpsecTunnelIfSetSaReply)(nil), - (*IpsecTunnelProtectDel)(nil), - (*IpsecTunnelProtectDelReply)(nil), - (*IpsecTunnelProtectDetails)(nil), - (*IpsecTunnelProtectDump)(nil), - (*IpsecTunnelProtectUpdate)(nil), - (*IpsecTunnelProtectUpdateReply)(nil), - } -} - -// RPCService represents RPC service API for ipsec module. -type RPCService interface { - DumpIpsecBackend(ctx context.Context, in *IpsecBackendDump) (RPCService_DumpIpsecBackendClient, error) - DumpIpsecSa(ctx context.Context, in *IpsecSaDump) (RPCService_DumpIpsecSaClient, error) - DumpIpsecSpd(ctx context.Context, in *IpsecSpdDump) (RPCService_DumpIpsecSpdClient, error) - DumpIpsecSpdInterface(ctx context.Context, in *IpsecSpdInterfaceDump) (RPCService_DumpIpsecSpdInterfaceClient, error) - DumpIpsecSpds(ctx context.Context, in *IpsecSpdsDump) (RPCService_DumpIpsecSpdsClient, error) - DumpIpsecTunnelProtect(ctx context.Context, in *IpsecTunnelProtectDump) (RPCService_DumpIpsecTunnelProtectClient, error) - IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecInterfaceAddDelSpd) (*IpsecInterfaceAddDelSpdReply, error) - IpsecSadEntryAddDel(ctx context.Context, in *IpsecSadEntryAddDel) (*IpsecSadEntryAddDelReply, error) - IpsecSelectBackend(ctx context.Context, in *IpsecSelectBackend) (*IpsecSelectBackendReply, error) - IpsecSpdAddDel(ctx context.Context, in *IpsecSpdAddDel) (*IpsecSpdAddDelReply, error) - IpsecSpdEntryAddDel(ctx context.Context, in *IpsecSpdEntryAddDel) (*IpsecSpdEntryAddDelReply, error) - IpsecTunnelIfAddDel(ctx context.Context, in *IpsecTunnelIfAddDel) (*IpsecTunnelIfAddDelReply, error) - IpsecTunnelIfSetSa(ctx context.Context, in *IpsecTunnelIfSetSa) (*IpsecTunnelIfSetSaReply, error) - IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunnelProtectDel) (*IpsecTunnelProtectDelReply, error) - IpsecTunnelProtectUpdate(ctx context.Context, in *IpsecTunnelProtectUpdate) (*IpsecTunnelProtectUpdateReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpIpsecBackend(ctx context.Context, in *IpsecBackendDump) (RPCService_DumpIpsecBackendClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpsecBackendClient{stream} - return x, nil -} - -type RPCService_DumpIpsecBackendClient interface { - Recv() (*IpsecBackendDetails, error) -} - -type serviceClient_DumpIpsecBackendClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpsecBackendClient) Recv() (*IpsecBackendDetails, error) { - m := new(IpsecBackendDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIpsecSa(ctx context.Context, in *IpsecSaDump) (RPCService_DumpIpsecSaClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpsecSaClient{stream} - return x, nil -} - -type RPCService_DumpIpsecSaClient interface { - Recv() (*IpsecSaDetails, error) -} - -type serviceClient_DumpIpsecSaClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpsecSaClient) Recv() (*IpsecSaDetails, error) { - m := new(IpsecSaDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIpsecSpd(ctx context.Context, in *IpsecSpdDump) (RPCService_DumpIpsecSpdClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpsecSpdClient{stream} - return x, nil -} - -type RPCService_DumpIpsecSpdClient interface { - Recv() (*IpsecSpdDetails, error) -} - -type serviceClient_DumpIpsecSpdClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpsecSpdClient) Recv() (*IpsecSpdDetails, error) { - m := new(IpsecSpdDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIpsecSpdInterface(ctx context.Context, in *IpsecSpdInterfaceDump) (RPCService_DumpIpsecSpdInterfaceClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpsecSpdInterfaceClient{stream} - return x, nil -} - -type RPCService_DumpIpsecSpdInterfaceClient interface { - Recv() (*IpsecSpdInterfaceDetails, error) -} - -type serviceClient_DumpIpsecSpdInterfaceClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpsecSpdInterfaceClient) Recv() (*IpsecSpdInterfaceDetails, error) { - m := new(IpsecSpdInterfaceDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIpsecSpds(ctx context.Context, in *IpsecSpdsDump) (RPCService_DumpIpsecSpdsClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpsecSpdsClient{stream} - return x, nil -} - -type RPCService_DumpIpsecSpdsClient interface { - Recv() (*IpsecSpdsDetails, error) -} - -type serviceClient_DumpIpsecSpdsClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpsecSpdsClient) Recv() (*IpsecSpdsDetails, error) { - m := new(IpsecSpdsDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpIpsecTunnelProtect(ctx context.Context, in *IpsecTunnelProtectDump) (RPCService_DumpIpsecTunnelProtectClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpIpsecTunnelProtectClient{stream} - return x, nil -} - -type RPCService_DumpIpsecTunnelProtectClient interface { - Recv() (*IpsecTunnelProtectDetails, error) -} - -type serviceClient_DumpIpsecTunnelProtectClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpIpsecTunnelProtectClient) Recv() (*IpsecTunnelProtectDetails, error) { - m := new(IpsecTunnelProtectDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) IpsecInterfaceAddDelSpd(ctx context.Context, in *IpsecInterfaceAddDelSpd) (*IpsecInterfaceAddDelSpdReply, error) { - out := new(IpsecInterfaceAddDelSpdReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecSadEntryAddDel(ctx context.Context, in *IpsecSadEntryAddDel) (*IpsecSadEntryAddDelReply, error) { - out := new(IpsecSadEntryAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecSelectBackend(ctx context.Context, in *IpsecSelectBackend) (*IpsecSelectBackendReply, error) { - out := new(IpsecSelectBackendReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecSpdAddDel(ctx context.Context, in *IpsecSpdAddDel) (*IpsecSpdAddDelReply, error) { - out := new(IpsecSpdAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecSpdEntryAddDel(ctx context.Context, in *IpsecSpdEntryAddDel) (*IpsecSpdEntryAddDelReply, error) { - out := new(IpsecSpdEntryAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecTunnelIfAddDel(ctx context.Context, in *IpsecTunnelIfAddDel) (*IpsecTunnelIfAddDelReply, error) { - out := new(IpsecTunnelIfAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecTunnelIfSetSa(ctx context.Context, in *IpsecTunnelIfSetSa) (*IpsecTunnelIfSetSaReply, error) { - out := new(IpsecTunnelIfSetSaReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecTunnelProtectDel(ctx context.Context, in *IpsecTunnelProtectDel) (*IpsecTunnelProtectDelReply, error) { - out := new(IpsecTunnelProtectDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) IpsecTunnelProtectUpdate(ctx context.Context, in *IpsecTunnelProtectUpdate) (*IpsecTunnelProtectUpdateReply, error) { - out := new(IpsecTunnelProtectUpdateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/ipsec_types/ipsec_types.ba.go b/plugins/vpp/binapi/vpp2001/ipsec_types/ipsec_types.ba.go deleted file mode 100644 index 51e7824174..0000000000 --- a/plugins/vpp/binapi/vpp2001/ipsec_types/ipsec_types.ba.go +++ /dev/null @@ -1,267 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/ipsec_types.api.json - -/* -Package ipsec_types is a generated VPP binary API for 'ipsec_types' module. - -It consists of: - 8 enums - 5 aliases - 8 types - 1 union -*/ -package ipsec_types - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "ipsec_types" - // APIVersion is the API version of this module. - APIVersion = "3.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x6e9f4c73 -) - -type AddressFamily = ip_types.AddressFamily - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -// IpsecCryptoAlg represents VPP binary API enum 'ipsec_crypto_alg'. -type IpsecCryptoAlg uint32 - -const ( - IPSEC_API_CRYPTO_ALG_NONE IpsecCryptoAlg = 0 - IPSEC_API_CRYPTO_ALG_AES_CBC_128 IpsecCryptoAlg = 1 - IPSEC_API_CRYPTO_ALG_AES_CBC_192 IpsecCryptoAlg = 2 - IPSEC_API_CRYPTO_ALG_AES_CBC_256 IpsecCryptoAlg = 3 - IPSEC_API_CRYPTO_ALG_AES_CTR_128 IpsecCryptoAlg = 4 - IPSEC_API_CRYPTO_ALG_AES_CTR_192 IpsecCryptoAlg = 5 - IPSEC_API_CRYPTO_ALG_AES_CTR_256 IpsecCryptoAlg = 6 - IPSEC_API_CRYPTO_ALG_AES_GCM_128 IpsecCryptoAlg = 7 - IPSEC_API_CRYPTO_ALG_AES_GCM_192 IpsecCryptoAlg = 8 - IPSEC_API_CRYPTO_ALG_AES_GCM_256 IpsecCryptoAlg = 9 - IPSEC_API_CRYPTO_ALG_DES_CBC IpsecCryptoAlg = 10 - IPSEC_API_CRYPTO_ALG_3DES_CBC IpsecCryptoAlg = 11 -) - -var IpsecCryptoAlg_name = map[uint32]string{ - 0: "IPSEC_API_CRYPTO_ALG_NONE", - 1: "IPSEC_API_CRYPTO_ALG_AES_CBC_128", - 2: "IPSEC_API_CRYPTO_ALG_AES_CBC_192", - 3: "IPSEC_API_CRYPTO_ALG_AES_CBC_256", - 4: "IPSEC_API_CRYPTO_ALG_AES_CTR_128", - 5: "IPSEC_API_CRYPTO_ALG_AES_CTR_192", - 6: "IPSEC_API_CRYPTO_ALG_AES_CTR_256", - 7: "IPSEC_API_CRYPTO_ALG_AES_GCM_128", - 8: "IPSEC_API_CRYPTO_ALG_AES_GCM_192", - 9: "IPSEC_API_CRYPTO_ALG_AES_GCM_256", - 10: "IPSEC_API_CRYPTO_ALG_DES_CBC", - 11: "IPSEC_API_CRYPTO_ALG_3DES_CBC", -} - -var IpsecCryptoAlg_value = map[string]uint32{ - "IPSEC_API_CRYPTO_ALG_NONE": 0, - "IPSEC_API_CRYPTO_ALG_AES_CBC_128": 1, - "IPSEC_API_CRYPTO_ALG_AES_CBC_192": 2, - "IPSEC_API_CRYPTO_ALG_AES_CBC_256": 3, - "IPSEC_API_CRYPTO_ALG_AES_CTR_128": 4, - "IPSEC_API_CRYPTO_ALG_AES_CTR_192": 5, - "IPSEC_API_CRYPTO_ALG_AES_CTR_256": 6, - "IPSEC_API_CRYPTO_ALG_AES_GCM_128": 7, - "IPSEC_API_CRYPTO_ALG_AES_GCM_192": 8, - "IPSEC_API_CRYPTO_ALG_AES_GCM_256": 9, - "IPSEC_API_CRYPTO_ALG_DES_CBC": 10, - "IPSEC_API_CRYPTO_ALG_3DES_CBC": 11, -} - -func (x IpsecCryptoAlg) String() string { - s, ok := IpsecCryptoAlg_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IpsecIntegAlg represents VPP binary API enum 'ipsec_integ_alg'. -type IpsecIntegAlg uint32 - -const ( - IPSEC_API_INTEG_ALG_NONE IpsecIntegAlg = 0 - IPSEC_API_INTEG_ALG_MD5_96 IpsecIntegAlg = 1 - IPSEC_API_INTEG_ALG_SHA1_96 IpsecIntegAlg = 2 - IPSEC_API_INTEG_ALG_SHA_256_96 IpsecIntegAlg = 3 - IPSEC_API_INTEG_ALG_SHA_256_128 IpsecIntegAlg = 4 - IPSEC_API_INTEG_ALG_SHA_384_192 IpsecIntegAlg = 5 - IPSEC_API_INTEG_ALG_SHA_512_256 IpsecIntegAlg = 6 -) - -var IpsecIntegAlg_name = map[uint32]string{ - 0: "IPSEC_API_INTEG_ALG_NONE", - 1: "IPSEC_API_INTEG_ALG_MD5_96", - 2: "IPSEC_API_INTEG_ALG_SHA1_96", - 3: "IPSEC_API_INTEG_ALG_SHA_256_96", - 4: "IPSEC_API_INTEG_ALG_SHA_256_128", - 5: "IPSEC_API_INTEG_ALG_SHA_384_192", - 6: "IPSEC_API_INTEG_ALG_SHA_512_256", -} - -var IpsecIntegAlg_value = map[string]uint32{ - "IPSEC_API_INTEG_ALG_NONE": 0, - "IPSEC_API_INTEG_ALG_MD5_96": 1, - "IPSEC_API_INTEG_ALG_SHA1_96": 2, - "IPSEC_API_INTEG_ALG_SHA_256_96": 3, - "IPSEC_API_INTEG_ALG_SHA_256_128": 4, - "IPSEC_API_INTEG_ALG_SHA_384_192": 5, - "IPSEC_API_INTEG_ALG_SHA_512_256": 6, -} - -func (x IpsecIntegAlg) String() string { - s, ok := IpsecIntegAlg_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IpsecProto represents VPP binary API enum 'ipsec_proto'. -type IpsecProto uint32 - -const ( - IPSEC_API_PROTO_ESP IpsecProto = 1 - IPSEC_API_PROTO_AH IpsecProto = 2 -) - -var IpsecProto_name = map[uint32]string{ - 1: "IPSEC_API_PROTO_ESP", - 2: "IPSEC_API_PROTO_AH", -} - -var IpsecProto_value = map[string]uint32{ - "IPSEC_API_PROTO_ESP": 1, - "IPSEC_API_PROTO_AH": 2, -} - -func (x IpsecProto) String() string { - s, ok := IpsecProto_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// IpsecSadFlags represents VPP binary API enum 'ipsec_sad_flags'. -type IpsecSadFlags uint32 - -const ( - IPSEC_API_SAD_FLAG_NONE IpsecSadFlags = 0 - IPSEC_API_SAD_FLAG_USE_ESN IpsecSadFlags = 1 - IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY IpsecSadFlags = 2 - IPSEC_API_SAD_FLAG_IS_TUNNEL IpsecSadFlags = 4 - IPSEC_API_SAD_FLAG_IS_TUNNEL_V6 IpsecSadFlags = 8 - IPSEC_API_SAD_FLAG_UDP_ENCAP IpsecSadFlags = 16 -) - -var IpsecSadFlags_name = map[uint32]string{ - 0: "IPSEC_API_SAD_FLAG_NONE", - 1: "IPSEC_API_SAD_FLAG_USE_ESN", - 2: "IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY", - 4: "IPSEC_API_SAD_FLAG_IS_TUNNEL", - 8: "IPSEC_API_SAD_FLAG_IS_TUNNEL_V6", - 16: "IPSEC_API_SAD_FLAG_UDP_ENCAP", -} - -var IpsecSadFlags_value = map[string]uint32{ - "IPSEC_API_SAD_FLAG_NONE": 0, - "IPSEC_API_SAD_FLAG_USE_ESN": 1, - "IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY": 2, - "IPSEC_API_SAD_FLAG_IS_TUNNEL": 4, - "IPSEC_API_SAD_FLAG_IS_TUNNEL_V6": 8, - "IPSEC_API_SAD_FLAG_UDP_ENCAP": 16, -} - -func (x IpsecSadFlags) String() string { - s, ok := IpsecSadFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -// IpsecSadEntry represents VPP binary API type 'ipsec_sad_entry'. -type IpsecSadEntry struct { - SadID uint32 - Spi uint32 - Protocol IpsecProto - CryptoAlgorithm IpsecCryptoAlg - CryptoKey Key - IntegrityAlgorithm IpsecIntegAlg - IntegrityKey Key - Flags IpsecSadFlags - TunnelSrc Address - TunnelDst Address - TxTableID uint32 - Salt uint32 -} - -func (*IpsecSadEntry) GetTypeName() string { return "ipsec_sad_entry" } - -// Key represents VPP binary API type 'key'. -type Key struct { - Length uint8 - Data []byte `struc:"[128]byte"` -} - -func (*Key) GetTypeName() string { return "key" } - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/l2/l2.ba.go b/plugins/vpp/binapi/vpp2001/l2/l2.ba.go deleted file mode 100644 index eed08828b5..0000000000 --- a/plugins/vpp/binapi/vpp2001/l2/l2.ba.go +++ /dev/null @@ -1,1270 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/l2.api.json - -/* -Package l2 is a generated VPP binary API for 'l2' module. - -It consists of: - 12 enums - 7 aliases - 9 types - 1 union - 54 messages - 26 services -*/ -package l2 - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "l2" - // APIVersion is the API version of this module. - APIVersion = "2.2.2" - // VersionCrc is the CRC of this module. - VersionCrc = 0x2e148df3 -) - -type AddressFamily = ip_types.AddressFamily - -// BdFlags represents VPP binary API enum 'bd_flags'. -type BdFlags uint32 - -const ( - BRIDGE_API_FLAG_NONE BdFlags = 0 - BRIDGE_API_FLAG_LEARN BdFlags = 1 - BRIDGE_API_FLAG_FWD BdFlags = 2 - BRIDGE_API_FLAG_FLOOD BdFlags = 4 - BRIDGE_API_FLAG_UU_FLOOD BdFlags = 8 - BRIDGE_API_FLAG_ARP_TERM BdFlags = 16 - BRIDGE_API_FLAG_ARP_UFWD BdFlags = 32 -) - -var BdFlags_name = map[uint32]string{ - 0: "BRIDGE_API_FLAG_NONE", - 1: "BRIDGE_API_FLAG_LEARN", - 2: "BRIDGE_API_FLAG_FWD", - 4: "BRIDGE_API_FLAG_FLOOD", - 8: "BRIDGE_API_FLAG_UU_FLOOD", - 16: "BRIDGE_API_FLAG_ARP_TERM", - 32: "BRIDGE_API_FLAG_ARP_UFWD", -} - -var BdFlags_value = map[string]uint32{ - "BRIDGE_API_FLAG_NONE": 0, - "BRIDGE_API_FLAG_LEARN": 1, - "BRIDGE_API_FLAG_FWD": 2, - "BRIDGE_API_FLAG_FLOOD": 4, - "BRIDGE_API_FLAG_UU_FLOOD": 8, - "BRIDGE_API_FLAG_ARP_TERM": 16, - "BRIDGE_API_FLAG_ARP_UFWD": 32, -} - -func (x BdFlags) String() string { - s, ok := BdFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -// L2PortType represents VPP binary API enum 'l2_port_type'. -type L2PortType uint32 - -const ( - L2_API_PORT_TYPE_NORMAL L2PortType = 0 - L2_API_PORT_TYPE_BVI L2PortType = 1 - L2_API_PORT_TYPE_UU_FWD L2PortType = 2 -) - -var L2PortType_name = map[uint32]string{ - 0: "L2_API_PORT_TYPE_NORMAL", - 1: "L2_API_PORT_TYPE_BVI", - 2: "L2_API_PORT_TYPE_UU_FWD", -} - -var L2PortType_value = map[string]uint32{ - "L2_API_PORT_TYPE_NORMAL": 0, - "L2_API_PORT_TYPE_BVI": 1, - "L2_API_PORT_TYPE_UU_FWD": 2, -} - -func (x L2PortType) String() string { - s, ok := L2PortType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type MacAddress = ethernet_types.MacAddress - -type Address = ip_types.Address - -// BdIPMac represents VPP binary API type 'bd_ip_mac'. -type BdIPMac struct { - BdID uint32 - IP Address - Mac MacAddress -} - -func (*BdIPMac) GetTypeName() string { return "bd_ip_mac" } - -// BridgeDomainSwIf represents VPP binary API type 'bridge_domain_sw_if'. -type BridgeDomainSwIf struct { - Context uint32 - SwIfIndex uint32 - Shg uint8 -} - -func (*BridgeDomainSwIf) GetTypeName() string { return "bridge_domain_sw_if" } - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -// MacEntry represents VPP binary API type 'mac_entry'. -type MacEntry struct { - SwIfIndex uint32 - MacAddr []byte `struc:"[6]byte"` - Action uint8 - Flags uint8 -} - -func (*MacEntry) GetTypeName() string { return "mac_entry" } - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// BdIPMacAddDel represents VPP binary API message 'bd_ip_mac_add_del'. -type BdIPMacAddDel struct { - IsAdd uint8 - Entry BdIPMac -} - -func (m *BdIPMacAddDel) Reset() { *m = BdIPMacAddDel{} } -func (*BdIPMacAddDel) GetMessageName() string { return "bd_ip_mac_add_del" } -func (*BdIPMacAddDel) GetCrcString() string { return "25bf4063" } -func (*BdIPMacAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// BdIPMacAddDelReply represents VPP binary API message 'bd_ip_mac_add_del_reply'. -type BdIPMacAddDelReply struct { - Retval int32 -} - -func (m *BdIPMacAddDelReply) Reset() { *m = BdIPMacAddDelReply{} } -func (*BdIPMacAddDelReply) GetMessageName() string { return "bd_ip_mac_add_del_reply" } -func (*BdIPMacAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*BdIPMacAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BdIPMacDetails represents VPP binary API message 'bd_ip_mac_details'. -type BdIPMacDetails struct { - Entry BdIPMac -} - -func (m *BdIPMacDetails) Reset() { *m = BdIPMacDetails{} } -func (*BdIPMacDetails) GetMessageName() string { return "bd_ip_mac_details" } -func (*BdIPMacDetails) GetCrcString() string { return "a52f8044" } -func (*BdIPMacDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BdIPMacDump represents VPP binary API message 'bd_ip_mac_dump'. -type BdIPMacDump struct { - BdID uint32 -} - -func (m *BdIPMacDump) Reset() { *m = BdIPMacDump{} } -func (*BdIPMacDump) GetMessageName() string { return "bd_ip_mac_dump" } -func (*BdIPMacDump) GetCrcString() string { return "c25fdce6" } -func (*BdIPMacDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// BdIPMacFlush represents VPP binary API message 'bd_ip_mac_flush'. -type BdIPMacFlush struct { - BdID uint32 -} - -func (m *BdIPMacFlush) Reset() { *m = BdIPMacFlush{} } -func (*BdIPMacFlush) GetMessageName() string { return "bd_ip_mac_flush" } -func (*BdIPMacFlush) GetCrcString() string { return "c25fdce6" } -func (*BdIPMacFlush) GetMessageType() api.MessageType { return api.RequestMessage } - -// BdIPMacFlushReply represents VPP binary API message 'bd_ip_mac_flush_reply'. -type BdIPMacFlushReply struct { - Retval int32 -} - -func (m *BdIPMacFlushReply) Reset() { *m = BdIPMacFlushReply{} } -func (*BdIPMacFlushReply) GetMessageName() string { return "bd_ip_mac_flush_reply" } -func (*BdIPMacFlushReply) GetCrcString() string { return "e8d4e804" } -func (*BdIPMacFlushReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BridgeDomainAddDel represents VPP binary API message 'bridge_domain_add_del'. -type BridgeDomainAddDel struct { - BdID uint32 - Flood uint8 - UuFlood uint8 - Forward uint8 - Learn uint8 - ArpTerm uint8 - ArpUfwd uint8 - MacAge uint8 - BdTag []byte `struc:"[64]byte"` - IsAdd uint8 -} - -func (m *BridgeDomainAddDel) Reset() { *m = BridgeDomainAddDel{} } -func (*BridgeDomainAddDel) GetMessageName() string { return "bridge_domain_add_del" } -func (*BridgeDomainAddDel) GetCrcString() string { return "c6360720" } -func (*BridgeDomainAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// BridgeDomainAddDelReply represents VPP binary API message 'bridge_domain_add_del_reply'. -type BridgeDomainAddDelReply struct { - Retval int32 -} - -func (m *BridgeDomainAddDelReply) Reset() { *m = BridgeDomainAddDelReply{} } -func (*BridgeDomainAddDelReply) GetMessageName() string { return "bridge_domain_add_del_reply" } -func (*BridgeDomainAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*BridgeDomainAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BridgeDomainDetails represents VPP binary API message 'bridge_domain_details'. -type BridgeDomainDetails struct { - BdID uint32 - Flood uint8 - UuFlood uint8 - Forward uint8 - Learn uint8 - ArpTerm uint8 - ArpUfwd uint8 - MacAge uint8 - BdTag []byte `struc:"[64]byte"` - BviSwIfIndex uint32 - UuFwdSwIfIndex uint32 - NSwIfs uint32 `struc:"sizeof=SwIfDetails"` - SwIfDetails []BridgeDomainSwIf -} - -func (m *BridgeDomainDetails) Reset() { *m = BridgeDomainDetails{} } -func (*BridgeDomainDetails) GetMessageName() string { return "bridge_domain_details" } -func (*BridgeDomainDetails) GetCrcString() string { return "748c854a" } -func (*BridgeDomainDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BridgeDomainDump represents VPP binary API message 'bridge_domain_dump'. -type BridgeDomainDump struct { - BdID uint32 -} - -func (m *BridgeDomainDump) Reset() { *m = BridgeDomainDump{} } -func (*BridgeDomainDump) GetMessageName() string { return "bridge_domain_dump" } -func (*BridgeDomainDump) GetCrcString() string { return "c25fdce6" } -func (*BridgeDomainDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// BridgeDomainSetMacAge represents VPP binary API message 'bridge_domain_set_mac_age'. -type BridgeDomainSetMacAge struct { - BdID uint32 - MacAge uint8 -} - -func (m *BridgeDomainSetMacAge) Reset() { *m = BridgeDomainSetMacAge{} } -func (*BridgeDomainSetMacAge) GetMessageName() string { return "bridge_domain_set_mac_age" } -func (*BridgeDomainSetMacAge) GetCrcString() string { return "b537ad7b" } -func (*BridgeDomainSetMacAge) GetMessageType() api.MessageType { return api.RequestMessage } - -// BridgeDomainSetMacAgeReply represents VPP binary API message 'bridge_domain_set_mac_age_reply'. -type BridgeDomainSetMacAgeReply struct { - Retval int32 -} - -func (m *BridgeDomainSetMacAgeReply) Reset() { *m = BridgeDomainSetMacAgeReply{} } -func (*BridgeDomainSetMacAgeReply) GetMessageName() string { return "bridge_domain_set_mac_age_reply" } -func (*BridgeDomainSetMacAgeReply) GetCrcString() string { return "e8d4e804" } -func (*BridgeDomainSetMacAgeReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BridgeFlags represents VPP binary API message 'bridge_flags'. -type BridgeFlags struct { - BdID uint32 - IsSet uint8 - Flags BdFlags -} - -func (m *BridgeFlags) Reset() { *m = BridgeFlags{} } -func (*BridgeFlags) GetMessageName() string { return "bridge_flags" } -func (*BridgeFlags) GetCrcString() string { return "2eb9b76c" } -func (*BridgeFlags) GetMessageType() api.MessageType { return api.RequestMessage } - -// BridgeFlagsReply represents VPP binary API message 'bridge_flags_reply'. -type BridgeFlagsReply struct { - Retval int32 - ResultingFeatureBitmap uint32 -} - -func (m *BridgeFlagsReply) Reset() { *m = BridgeFlagsReply{} } -func (*BridgeFlagsReply) GetMessageName() string { return "bridge_flags_reply" } -func (*BridgeFlagsReply) GetCrcString() string { return "29b2a2b3" } -func (*BridgeFlagsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BviCreate represents VPP binary API message 'bvi_create'. -type BviCreate struct { - Mac MacAddress - UserInstance uint32 -} - -func (m *BviCreate) Reset() { *m = BviCreate{} } -func (*BviCreate) GetMessageName() string { return "bvi_create" } -func (*BviCreate) GetCrcString() string { return "f5398559" } -func (*BviCreate) GetMessageType() api.MessageType { return api.RequestMessage } - -// BviCreateReply represents VPP binary API message 'bvi_create_reply'. -type BviCreateReply struct { - Retval int32 - SwIfIndex uint32 -} - -func (m *BviCreateReply) Reset() { *m = BviCreateReply{} } -func (*BviCreateReply) GetMessageName() string { return "bvi_create_reply" } -func (*BviCreateReply) GetCrcString() string { return "fda5941f" } -func (*BviCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// BviDelete represents VPP binary API message 'bvi_delete'. -type BviDelete struct { - SwIfIndex uint32 -} - -func (m *BviDelete) Reset() { *m = BviDelete{} } -func (*BviDelete) GetMessageName() string { return "bvi_delete" } -func (*BviDelete) GetCrcString() string { return "529cb13f" } -func (*BviDelete) GetMessageType() api.MessageType { return api.RequestMessage } - -// BviDeleteReply represents VPP binary API message 'bvi_delete_reply'. -type BviDeleteReply struct { - Retval int32 -} - -func (m *BviDeleteReply) Reset() { *m = BviDeleteReply{} } -func (*BviDeleteReply) GetMessageName() string { return "bvi_delete_reply" } -func (*BviDeleteReply) GetCrcString() string { return "e8d4e804" } -func (*BviDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2ArpTermEvent represents VPP binary API message 'l2_arp_term_event'. -type L2ArpTermEvent struct { - PID uint32 - IP Address - SwIfIndex InterfaceIndex - Mac MacAddress -} - -func (m *L2ArpTermEvent) Reset() { *m = L2ArpTermEvent{} } -func (*L2ArpTermEvent) GetMessageName() string { return "l2_arp_term_event" } -func (*L2ArpTermEvent) GetCrcString() string { return "85ff71ea" } -func (*L2ArpTermEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// L2FibClearTable represents VPP binary API message 'l2_fib_clear_table'. -type L2FibClearTable struct{} - -func (m *L2FibClearTable) Reset() { *m = L2FibClearTable{} } -func (*L2FibClearTable) GetMessageName() string { return "l2_fib_clear_table" } -func (*L2FibClearTable) GetCrcString() string { return "51077d14" } -func (*L2FibClearTable) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2FibClearTableReply represents VPP binary API message 'l2_fib_clear_table_reply'. -type L2FibClearTableReply struct { - Retval int32 -} - -func (m *L2FibClearTableReply) Reset() { *m = L2FibClearTableReply{} } -func (*L2FibClearTableReply) GetMessageName() string { return "l2_fib_clear_table_reply" } -func (*L2FibClearTableReply) GetCrcString() string { return "e8d4e804" } -func (*L2FibClearTableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2FibTableDetails represents VPP binary API message 'l2_fib_table_details'. -type L2FibTableDetails struct { - BdID uint32 - Mac []byte `struc:"[6]byte"` - SwIfIndex uint32 - StaticMac uint8 - FilterMac uint8 - BviMac uint8 -} - -func (m *L2FibTableDetails) Reset() { *m = L2FibTableDetails{} } -func (*L2FibTableDetails) GetMessageName() string { return "l2_fib_table_details" } -func (*L2FibTableDetails) GetCrcString() string { return "c7392706" } -func (*L2FibTableDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2FibTableDump represents VPP binary API message 'l2_fib_table_dump'. -type L2FibTableDump struct { - BdID uint32 -} - -func (m *L2FibTableDump) Reset() { *m = L2FibTableDump{} } -func (*L2FibTableDump) GetMessageName() string { return "l2_fib_table_dump" } -func (*L2FibTableDump) GetCrcString() string { return "c25fdce6" } -func (*L2FibTableDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2Flags represents VPP binary API message 'l2_flags'. -type L2Flags struct { - SwIfIndex uint32 - IsSet uint8 - FeatureBitmap uint32 -} - -func (m *L2Flags) Reset() { *m = L2Flags{} } -func (*L2Flags) GetMessageName() string { return "l2_flags" } -func (*L2Flags) GetCrcString() string { return "0e889fb9" } -func (*L2Flags) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2FlagsReply represents VPP binary API message 'l2_flags_reply'. -type L2FlagsReply struct { - Retval int32 - ResultingFeatureBitmap uint32 -} - -func (m *L2FlagsReply) Reset() { *m = L2FlagsReply{} } -func (*L2FlagsReply) GetMessageName() string { return "l2_flags_reply" } -func (*L2FlagsReply) GetCrcString() string { return "29b2a2b3" } -func (*L2FlagsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2InterfaceEfpFilter represents VPP binary API message 'l2_interface_efp_filter'. -type L2InterfaceEfpFilter struct { - SwIfIndex uint32 - EnableDisable uint8 -} - -func (m *L2InterfaceEfpFilter) Reset() { *m = L2InterfaceEfpFilter{} } -func (*L2InterfaceEfpFilter) GetMessageName() string { return "l2_interface_efp_filter" } -func (*L2InterfaceEfpFilter) GetCrcString() string { return "69d24598" } -func (*L2InterfaceEfpFilter) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2InterfaceEfpFilterReply represents VPP binary API message 'l2_interface_efp_filter_reply'. -type L2InterfaceEfpFilterReply struct { - Retval int32 -} - -func (m *L2InterfaceEfpFilterReply) Reset() { *m = L2InterfaceEfpFilterReply{} } -func (*L2InterfaceEfpFilterReply) GetMessageName() string { return "l2_interface_efp_filter_reply" } -func (*L2InterfaceEfpFilterReply) GetCrcString() string { return "e8d4e804" } -func (*L2InterfaceEfpFilterReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2InterfacePbbTagRewrite represents VPP binary API message 'l2_interface_pbb_tag_rewrite'. -type L2InterfacePbbTagRewrite struct { - SwIfIndex uint32 - VtrOp uint32 - OuterTag uint16 - BDmac []byte `struc:"[6]byte"` - BSmac []byte `struc:"[6]byte"` - BVlanid uint16 - ISid uint32 -} - -func (m *L2InterfacePbbTagRewrite) Reset() { *m = L2InterfacePbbTagRewrite{} } -func (*L2InterfacePbbTagRewrite) GetMessageName() string { return "l2_interface_pbb_tag_rewrite" } -func (*L2InterfacePbbTagRewrite) GetCrcString() string { return "6cf815f9" } -func (*L2InterfacePbbTagRewrite) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2InterfacePbbTagRewriteReply represents VPP binary API message 'l2_interface_pbb_tag_rewrite_reply'. -type L2InterfacePbbTagRewriteReply struct { - Retval int32 -} - -func (m *L2InterfacePbbTagRewriteReply) Reset() { *m = L2InterfacePbbTagRewriteReply{} } -func (*L2InterfacePbbTagRewriteReply) GetMessageName() string { - return "l2_interface_pbb_tag_rewrite_reply" -} -func (*L2InterfacePbbTagRewriteReply) GetCrcString() string { return "e8d4e804" } -func (*L2InterfacePbbTagRewriteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2InterfaceVlanTagRewrite represents VPP binary API message 'l2_interface_vlan_tag_rewrite'. -type L2InterfaceVlanTagRewrite struct { - SwIfIndex uint32 - VtrOp uint32 - PushDot1q uint32 - Tag1 uint32 - Tag2 uint32 -} - -func (m *L2InterfaceVlanTagRewrite) Reset() { *m = L2InterfaceVlanTagRewrite{} } -func (*L2InterfaceVlanTagRewrite) GetMessageName() string { return "l2_interface_vlan_tag_rewrite" } -func (*L2InterfaceVlanTagRewrite) GetCrcString() string { return "b90be6b4" } -func (*L2InterfaceVlanTagRewrite) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2InterfaceVlanTagRewriteReply represents VPP binary API message 'l2_interface_vlan_tag_rewrite_reply'. -type L2InterfaceVlanTagRewriteReply struct { - Retval int32 -} - -func (m *L2InterfaceVlanTagRewriteReply) Reset() { *m = L2InterfaceVlanTagRewriteReply{} } -func (*L2InterfaceVlanTagRewriteReply) GetMessageName() string { - return "l2_interface_vlan_tag_rewrite_reply" -} -func (*L2InterfaceVlanTagRewriteReply) GetCrcString() string { return "e8d4e804" } -func (*L2InterfaceVlanTagRewriteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2MacsEvent represents VPP binary API message 'l2_macs_event'. -type L2MacsEvent struct { - PID uint32 - NMacs uint32 `struc:"sizeof=Mac"` - Mac []MacEntry -} - -func (m *L2MacsEvent) Reset() { *m = L2MacsEvent{} } -func (*L2MacsEvent) GetMessageName() string { return "l2_macs_event" } -func (*L2MacsEvent) GetCrcString() string { return "afc74a60" } -func (*L2MacsEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// L2PatchAddDel represents VPP binary API message 'l2_patch_add_del'. -type L2PatchAddDel struct { - RxSwIfIndex uint32 - TxSwIfIndex uint32 - IsAdd uint8 -} - -func (m *L2PatchAddDel) Reset() { *m = L2PatchAddDel{} } -func (*L2PatchAddDel) GetMessageName() string { return "l2_patch_add_del" } -func (*L2PatchAddDel) GetCrcString() string { return "62506e63" } -func (*L2PatchAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2PatchAddDelReply represents VPP binary API message 'l2_patch_add_del_reply'. -type L2PatchAddDelReply struct { - Retval int32 -} - -func (m *L2PatchAddDelReply) Reset() { *m = L2PatchAddDelReply{} } -func (*L2PatchAddDelReply) GetMessageName() string { return "l2_patch_add_del_reply" } -func (*L2PatchAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*L2PatchAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2XconnectDetails represents VPP binary API message 'l2_xconnect_details'. -type L2XconnectDetails struct { - RxSwIfIndex uint32 - TxSwIfIndex uint32 -} - -func (m *L2XconnectDetails) Reset() { *m = L2XconnectDetails{} } -func (*L2XconnectDetails) GetMessageName() string { return "l2_xconnect_details" } -func (*L2XconnectDetails) GetCrcString() string { return "722e2378" } -func (*L2XconnectDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2XconnectDump represents VPP binary API message 'l2_xconnect_dump'. -type L2XconnectDump struct{} - -func (m *L2XconnectDump) Reset() { *m = L2XconnectDump{} } -func (*L2XconnectDump) GetMessageName() string { return "l2_xconnect_dump" } -func (*L2XconnectDump) GetCrcString() string { return "51077d14" } -func (*L2XconnectDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2fibAddDel represents VPP binary API message 'l2fib_add_del'. -type L2fibAddDel struct { - Mac []byte `struc:"[6]byte"` - BdID uint32 - SwIfIndex uint32 - IsAdd uint8 - StaticMac uint8 - FilterMac uint8 - BviMac uint8 -} - -func (m *L2fibAddDel) Reset() { *m = L2fibAddDel{} } -func (*L2fibAddDel) GetMessageName() string { return "l2fib_add_del" } -func (*L2fibAddDel) GetCrcString() string { return "34ced3eb" } -func (*L2fibAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2fibAddDelReply represents VPP binary API message 'l2fib_add_del_reply'. -type L2fibAddDelReply struct { - Retval int32 -} - -func (m *L2fibAddDelReply) Reset() { *m = L2fibAddDelReply{} } -func (*L2fibAddDelReply) GetMessageName() string { return "l2fib_add_del_reply" } -func (*L2fibAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*L2fibAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2fibFlushAll represents VPP binary API message 'l2fib_flush_all'. -type L2fibFlushAll struct{} - -func (m *L2fibFlushAll) Reset() { *m = L2fibFlushAll{} } -func (*L2fibFlushAll) GetMessageName() string { return "l2fib_flush_all" } -func (*L2fibFlushAll) GetCrcString() string { return "51077d14" } -func (*L2fibFlushAll) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2fibFlushAllReply represents VPP binary API message 'l2fib_flush_all_reply'. -type L2fibFlushAllReply struct { - Retval int32 -} - -func (m *L2fibFlushAllReply) Reset() { *m = L2fibFlushAllReply{} } -func (*L2fibFlushAllReply) GetMessageName() string { return "l2fib_flush_all_reply" } -func (*L2fibFlushAllReply) GetCrcString() string { return "e8d4e804" } -func (*L2fibFlushAllReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2fibFlushBd represents VPP binary API message 'l2fib_flush_bd'. -type L2fibFlushBd struct { - BdID uint32 -} - -func (m *L2fibFlushBd) Reset() { *m = L2fibFlushBd{} } -func (*L2fibFlushBd) GetMessageName() string { return "l2fib_flush_bd" } -func (*L2fibFlushBd) GetCrcString() string { return "c25fdce6" } -func (*L2fibFlushBd) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2fibFlushBdReply represents VPP binary API message 'l2fib_flush_bd_reply'. -type L2fibFlushBdReply struct { - Retval int32 -} - -func (m *L2fibFlushBdReply) Reset() { *m = L2fibFlushBdReply{} } -func (*L2fibFlushBdReply) GetMessageName() string { return "l2fib_flush_bd_reply" } -func (*L2fibFlushBdReply) GetCrcString() string { return "e8d4e804" } -func (*L2fibFlushBdReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L2fibFlushInt represents VPP binary API message 'l2fib_flush_int'. -type L2fibFlushInt struct { - SwIfIndex uint32 -} - -func (m *L2fibFlushInt) Reset() { *m = L2fibFlushInt{} } -func (*L2fibFlushInt) GetMessageName() string { return "l2fib_flush_int" } -func (*L2fibFlushInt) GetCrcString() string { return "529cb13f" } -func (*L2fibFlushInt) GetMessageType() api.MessageType { return api.RequestMessage } - -// L2fibFlushIntReply represents VPP binary API message 'l2fib_flush_int_reply'. -type L2fibFlushIntReply struct { - Retval int32 -} - -func (m *L2fibFlushIntReply) Reset() { *m = L2fibFlushIntReply{} } -func (*L2fibFlushIntReply) GetMessageName() string { return "l2fib_flush_int_reply" } -func (*L2fibFlushIntReply) GetCrcString() string { return "e8d4e804" } -func (*L2fibFlushIntReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetL2Bridge represents VPP binary API message 'sw_interface_set_l2_bridge'. -type SwInterfaceSetL2Bridge struct { - RxSwIfIndex uint32 - BdID uint32 - PortType L2PortType - Shg uint8 - Enable uint8 -} - -func (m *SwInterfaceSetL2Bridge) Reset() { *m = SwInterfaceSetL2Bridge{} } -func (*SwInterfaceSetL2Bridge) GetMessageName() string { return "sw_interface_set_l2_bridge" } -func (*SwInterfaceSetL2Bridge) GetCrcString() string { return "5579f809" } -func (*SwInterfaceSetL2Bridge) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetL2BridgeReply represents VPP binary API message 'sw_interface_set_l2_bridge_reply'. -type SwInterfaceSetL2BridgeReply struct { - Retval int32 -} - -func (m *SwInterfaceSetL2BridgeReply) Reset() { *m = SwInterfaceSetL2BridgeReply{} } -func (*SwInterfaceSetL2BridgeReply) GetMessageName() string { - return "sw_interface_set_l2_bridge_reply" -} -func (*SwInterfaceSetL2BridgeReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetL2BridgeReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetL2Xconnect represents VPP binary API message 'sw_interface_set_l2_xconnect'. -type SwInterfaceSetL2Xconnect struct { - RxSwIfIndex uint32 - TxSwIfIndex uint32 - Enable uint8 -} - -func (m *SwInterfaceSetL2Xconnect) Reset() { *m = SwInterfaceSetL2Xconnect{} } -func (*SwInterfaceSetL2Xconnect) GetMessageName() string { return "sw_interface_set_l2_xconnect" } -func (*SwInterfaceSetL2Xconnect) GetCrcString() string { return "95de3988" } -func (*SwInterfaceSetL2Xconnect) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetL2XconnectReply represents VPP binary API message 'sw_interface_set_l2_xconnect_reply'. -type SwInterfaceSetL2XconnectReply struct { - Retval int32 -} - -func (m *SwInterfaceSetL2XconnectReply) Reset() { *m = SwInterfaceSetL2XconnectReply{} } -func (*SwInterfaceSetL2XconnectReply) GetMessageName() string { - return "sw_interface_set_l2_xconnect_reply" -} -func (*SwInterfaceSetL2XconnectReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetL2XconnectReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSetVpath represents VPP binary API message 'sw_interface_set_vpath'. -type SwInterfaceSetVpath struct { - SwIfIndex uint32 - Enable uint8 -} - -func (m *SwInterfaceSetVpath) Reset() { *m = SwInterfaceSetVpath{} } -func (*SwInterfaceSetVpath) GetMessageName() string { return "sw_interface_set_vpath" } -func (*SwInterfaceSetVpath) GetCrcString() string { return "a36fadc0" } -func (*SwInterfaceSetVpath) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetVpathReply represents VPP binary API message 'sw_interface_set_vpath_reply'. -type SwInterfaceSetVpathReply struct { - Retval int32 -} - -func (m *SwInterfaceSetVpathReply) Reset() { *m = SwInterfaceSetVpathReply{} } -func (*SwInterfaceSetVpathReply) GetMessageName() string { return "sw_interface_set_vpath_reply" } -func (*SwInterfaceSetVpathReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetVpathReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// WantL2ArpTermEvents represents VPP binary API message 'want_l2_arp_term_events'. -type WantL2ArpTermEvents struct { - Enable bool - PID uint32 -} - -func (m *WantL2ArpTermEvents) Reset() { *m = WantL2ArpTermEvents{} } -func (*WantL2ArpTermEvents) GetMessageName() string { return "want_l2_arp_term_events" } -func (*WantL2ArpTermEvents) GetCrcString() string { return "3ec6d6c2" } -func (*WantL2ArpTermEvents) GetMessageType() api.MessageType { return api.RequestMessage } - -// WantL2ArpTermEventsReply represents VPP binary API message 'want_l2_arp_term_events_reply'. -type WantL2ArpTermEventsReply struct { - Retval int32 -} - -func (m *WantL2ArpTermEventsReply) Reset() { *m = WantL2ArpTermEventsReply{} } -func (*WantL2ArpTermEventsReply) GetMessageName() string { return "want_l2_arp_term_events_reply" } -func (*WantL2ArpTermEventsReply) GetCrcString() string { return "e8d4e804" } -func (*WantL2ArpTermEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// WantL2MacsEvents represents VPP binary API message 'want_l2_macs_events'. -type WantL2MacsEvents struct { - LearnLimit uint32 - ScanDelay uint8 - MaxMacsInEvent uint8 - EnableDisable bool - PID uint32 -} - -func (m *WantL2MacsEvents) Reset() { *m = WantL2MacsEvents{} } -func (*WantL2MacsEvents) GetMessageName() string { return "want_l2_macs_events" } -func (*WantL2MacsEvents) GetCrcString() string { return "9aabdfde" } -func (*WantL2MacsEvents) GetMessageType() api.MessageType { return api.RequestMessage } - -// WantL2MacsEventsReply represents VPP binary API message 'want_l2_macs_events_reply'. -type WantL2MacsEventsReply struct { - Retval int32 -} - -func (m *WantL2MacsEventsReply) Reset() { *m = WantL2MacsEventsReply{} } -func (*WantL2MacsEventsReply) GetMessageName() string { return "want_l2_macs_events_reply" } -func (*WantL2MacsEventsReply) GetCrcString() string { return "e8d4e804" } -func (*WantL2MacsEventsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*BdIPMacAddDel)(nil), "l2.BdIPMacAddDel") - api.RegisterMessage((*BdIPMacAddDelReply)(nil), "l2.BdIPMacAddDelReply") - api.RegisterMessage((*BdIPMacDetails)(nil), "l2.BdIPMacDetails") - api.RegisterMessage((*BdIPMacDump)(nil), "l2.BdIPMacDump") - api.RegisterMessage((*BdIPMacFlush)(nil), "l2.BdIPMacFlush") - api.RegisterMessage((*BdIPMacFlushReply)(nil), "l2.BdIPMacFlushReply") - api.RegisterMessage((*BridgeDomainAddDel)(nil), "l2.BridgeDomainAddDel") - api.RegisterMessage((*BridgeDomainAddDelReply)(nil), "l2.BridgeDomainAddDelReply") - api.RegisterMessage((*BridgeDomainDetails)(nil), "l2.BridgeDomainDetails") - api.RegisterMessage((*BridgeDomainDump)(nil), "l2.BridgeDomainDump") - api.RegisterMessage((*BridgeDomainSetMacAge)(nil), "l2.BridgeDomainSetMacAge") - api.RegisterMessage((*BridgeDomainSetMacAgeReply)(nil), "l2.BridgeDomainSetMacAgeReply") - api.RegisterMessage((*BridgeFlags)(nil), "l2.BridgeFlags") - api.RegisterMessage((*BridgeFlagsReply)(nil), "l2.BridgeFlagsReply") - api.RegisterMessage((*BviCreate)(nil), "l2.BviCreate") - api.RegisterMessage((*BviCreateReply)(nil), "l2.BviCreateReply") - api.RegisterMessage((*BviDelete)(nil), "l2.BviDelete") - api.RegisterMessage((*BviDeleteReply)(nil), "l2.BviDeleteReply") - api.RegisterMessage((*L2ArpTermEvent)(nil), "l2.L2ArpTermEvent") - api.RegisterMessage((*L2FibClearTable)(nil), "l2.L2FibClearTable") - api.RegisterMessage((*L2FibClearTableReply)(nil), "l2.L2FibClearTableReply") - api.RegisterMessage((*L2FibTableDetails)(nil), "l2.L2FibTableDetails") - api.RegisterMessage((*L2FibTableDump)(nil), "l2.L2FibTableDump") - api.RegisterMessage((*L2Flags)(nil), "l2.L2Flags") - api.RegisterMessage((*L2FlagsReply)(nil), "l2.L2FlagsReply") - api.RegisterMessage((*L2InterfaceEfpFilter)(nil), "l2.L2InterfaceEfpFilter") - api.RegisterMessage((*L2InterfaceEfpFilterReply)(nil), "l2.L2InterfaceEfpFilterReply") - api.RegisterMessage((*L2InterfacePbbTagRewrite)(nil), "l2.L2InterfacePbbTagRewrite") - api.RegisterMessage((*L2InterfacePbbTagRewriteReply)(nil), "l2.L2InterfacePbbTagRewriteReply") - api.RegisterMessage((*L2InterfaceVlanTagRewrite)(nil), "l2.L2InterfaceVlanTagRewrite") - api.RegisterMessage((*L2InterfaceVlanTagRewriteReply)(nil), "l2.L2InterfaceVlanTagRewriteReply") - api.RegisterMessage((*L2MacsEvent)(nil), "l2.L2MacsEvent") - api.RegisterMessage((*L2PatchAddDel)(nil), "l2.L2PatchAddDel") - api.RegisterMessage((*L2PatchAddDelReply)(nil), "l2.L2PatchAddDelReply") - api.RegisterMessage((*L2XconnectDetails)(nil), "l2.L2XconnectDetails") - api.RegisterMessage((*L2XconnectDump)(nil), "l2.L2XconnectDump") - api.RegisterMessage((*L2fibAddDel)(nil), "l2.L2fibAddDel") - api.RegisterMessage((*L2fibAddDelReply)(nil), "l2.L2fibAddDelReply") - api.RegisterMessage((*L2fibFlushAll)(nil), "l2.L2fibFlushAll") - api.RegisterMessage((*L2fibFlushAllReply)(nil), "l2.L2fibFlushAllReply") - api.RegisterMessage((*L2fibFlushBd)(nil), "l2.L2fibFlushBd") - api.RegisterMessage((*L2fibFlushBdReply)(nil), "l2.L2fibFlushBdReply") - api.RegisterMessage((*L2fibFlushInt)(nil), "l2.L2fibFlushInt") - api.RegisterMessage((*L2fibFlushIntReply)(nil), "l2.L2fibFlushIntReply") - api.RegisterMessage((*SwInterfaceSetL2Bridge)(nil), "l2.SwInterfaceSetL2Bridge") - api.RegisterMessage((*SwInterfaceSetL2BridgeReply)(nil), "l2.SwInterfaceSetL2BridgeReply") - api.RegisterMessage((*SwInterfaceSetL2Xconnect)(nil), "l2.SwInterfaceSetL2Xconnect") - api.RegisterMessage((*SwInterfaceSetL2XconnectReply)(nil), "l2.SwInterfaceSetL2XconnectReply") - api.RegisterMessage((*SwInterfaceSetVpath)(nil), "l2.SwInterfaceSetVpath") - api.RegisterMessage((*SwInterfaceSetVpathReply)(nil), "l2.SwInterfaceSetVpathReply") - api.RegisterMessage((*WantL2ArpTermEvents)(nil), "l2.WantL2ArpTermEvents") - api.RegisterMessage((*WantL2ArpTermEventsReply)(nil), "l2.WantL2ArpTermEventsReply") - api.RegisterMessage((*WantL2MacsEvents)(nil), "l2.WantL2MacsEvents") - api.RegisterMessage((*WantL2MacsEventsReply)(nil), "l2.WantL2MacsEventsReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*BdIPMacAddDel)(nil), - (*BdIPMacAddDelReply)(nil), - (*BdIPMacDetails)(nil), - (*BdIPMacDump)(nil), - (*BdIPMacFlush)(nil), - (*BdIPMacFlushReply)(nil), - (*BridgeDomainAddDel)(nil), - (*BridgeDomainAddDelReply)(nil), - (*BridgeDomainDetails)(nil), - (*BridgeDomainDump)(nil), - (*BridgeDomainSetMacAge)(nil), - (*BridgeDomainSetMacAgeReply)(nil), - (*BridgeFlags)(nil), - (*BridgeFlagsReply)(nil), - (*BviCreate)(nil), - (*BviCreateReply)(nil), - (*BviDelete)(nil), - (*BviDeleteReply)(nil), - (*L2ArpTermEvent)(nil), - (*L2FibClearTable)(nil), - (*L2FibClearTableReply)(nil), - (*L2FibTableDetails)(nil), - (*L2FibTableDump)(nil), - (*L2Flags)(nil), - (*L2FlagsReply)(nil), - (*L2InterfaceEfpFilter)(nil), - (*L2InterfaceEfpFilterReply)(nil), - (*L2InterfacePbbTagRewrite)(nil), - (*L2InterfacePbbTagRewriteReply)(nil), - (*L2InterfaceVlanTagRewrite)(nil), - (*L2InterfaceVlanTagRewriteReply)(nil), - (*L2MacsEvent)(nil), - (*L2PatchAddDel)(nil), - (*L2PatchAddDelReply)(nil), - (*L2XconnectDetails)(nil), - (*L2XconnectDump)(nil), - (*L2fibAddDel)(nil), - (*L2fibAddDelReply)(nil), - (*L2fibFlushAll)(nil), - (*L2fibFlushAllReply)(nil), - (*L2fibFlushBd)(nil), - (*L2fibFlushBdReply)(nil), - (*L2fibFlushInt)(nil), - (*L2fibFlushIntReply)(nil), - (*SwInterfaceSetL2Bridge)(nil), - (*SwInterfaceSetL2BridgeReply)(nil), - (*SwInterfaceSetL2Xconnect)(nil), - (*SwInterfaceSetL2XconnectReply)(nil), - (*SwInterfaceSetVpath)(nil), - (*SwInterfaceSetVpathReply)(nil), - (*WantL2ArpTermEvents)(nil), - (*WantL2ArpTermEventsReply)(nil), - (*WantL2MacsEvents)(nil), - (*WantL2MacsEventsReply)(nil), - } -} - -// RPCService represents RPC service API for l2 module. -type RPCService interface { - DumpBdIPMac(ctx context.Context, in *BdIPMacDump) (RPCService_DumpBdIPMacClient, error) - DumpBridgeDomain(ctx context.Context, in *BridgeDomainDump) (RPCService_DumpBridgeDomainClient, error) - DumpL2FibTable(ctx context.Context, in *L2FibTableDump) (RPCService_DumpL2FibTableClient, error) - DumpL2Xconnect(ctx context.Context, in *L2XconnectDump) (RPCService_DumpL2XconnectClient, error) - BdIPMacAddDel(ctx context.Context, in *BdIPMacAddDel) (*BdIPMacAddDelReply, error) - BdIPMacFlush(ctx context.Context, in *BdIPMacFlush) (*BdIPMacFlushReply, error) - BridgeDomainAddDel(ctx context.Context, in *BridgeDomainAddDel) (*BridgeDomainAddDelReply, error) - BridgeDomainSetMacAge(ctx context.Context, in *BridgeDomainSetMacAge) (*BridgeDomainSetMacAgeReply, error) - BridgeFlags(ctx context.Context, in *BridgeFlags) (*BridgeFlagsReply, error) - BviCreate(ctx context.Context, in *BviCreate) (*BviCreateReply, error) - BviDelete(ctx context.Context, in *BviDelete) (*BviDeleteReply, error) - L2FibClearTable(ctx context.Context, in *L2FibClearTable) (*L2FibClearTableReply, error) - L2Flags(ctx context.Context, in *L2Flags) (*L2FlagsReply, error) - L2InterfaceEfpFilter(ctx context.Context, in *L2InterfaceEfpFilter) (*L2InterfaceEfpFilterReply, error) - L2InterfacePbbTagRewrite(ctx context.Context, in *L2InterfacePbbTagRewrite) (*L2InterfacePbbTagRewriteReply, error) - L2InterfaceVlanTagRewrite(ctx context.Context, in *L2InterfaceVlanTagRewrite) (*L2InterfaceVlanTagRewriteReply, error) - L2PatchAddDel(ctx context.Context, in *L2PatchAddDel) (*L2PatchAddDelReply, error) - L2fibAddDel(ctx context.Context, in *L2fibAddDel) (*L2fibAddDelReply, error) - L2fibFlushAll(ctx context.Context, in *L2fibFlushAll) (*L2fibFlushAllReply, error) - L2fibFlushBd(ctx context.Context, in *L2fibFlushBd) (*L2fibFlushBdReply, error) - L2fibFlushInt(ctx context.Context, in *L2fibFlushInt) (*L2fibFlushIntReply, error) - SwInterfaceSetL2Bridge(ctx context.Context, in *SwInterfaceSetL2Bridge) (*SwInterfaceSetL2BridgeReply, error) - SwInterfaceSetL2Xconnect(ctx context.Context, in *SwInterfaceSetL2Xconnect) (*SwInterfaceSetL2XconnectReply, error) - SwInterfaceSetVpath(ctx context.Context, in *SwInterfaceSetVpath) (*SwInterfaceSetVpathReply, error) - WantL2ArpTermEvents(ctx context.Context, in *WantL2ArpTermEvents) (*WantL2ArpTermEventsReply, error) - WantL2MacsEvents(ctx context.Context, in *WantL2MacsEvents) (*WantL2MacsEventsReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpBdIPMac(ctx context.Context, in *BdIPMacDump) (RPCService_DumpBdIPMacClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpBdIPMacClient{stream} - return x, nil -} - -type RPCService_DumpBdIPMacClient interface { - Recv() (*BdIPMacDetails, error) -} - -type serviceClient_DumpBdIPMacClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpBdIPMacClient) Recv() (*BdIPMacDetails, error) { - m := new(BdIPMacDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpBridgeDomain(ctx context.Context, in *BridgeDomainDump) (RPCService_DumpBridgeDomainClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpBridgeDomainClient{stream} - return x, nil -} - -type RPCService_DumpBridgeDomainClient interface { - Recv() (*BridgeDomainDetails, error) -} - -type serviceClient_DumpBridgeDomainClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpBridgeDomainClient) Recv() (*BridgeDomainDetails, error) { - m := new(BridgeDomainDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpL2FibTable(ctx context.Context, in *L2FibTableDump) (RPCService_DumpL2FibTableClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpL2FibTableClient{stream} - return x, nil -} - -type RPCService_DumpL2FibTableClient interface { - Recv() (*L2FibTableDetails, error) -} - -type serviceClient_DumpL2FibTableClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpL2FibTableClient) Recv() (*L2FibTableDetails, error) { - m := new(L2FibTableDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpL2Xconnect(ctx context.Context, in *L2XconnectDump) (RPCService_DumpL2XconnectClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpL2XconnectClient{stream} - return x, nil -} - -type RPCService_DumpL2XconnectClient interface { - Recv() (*L2XconnectDetails, error) -} - -type serviceClient_DumpL2XconnectClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpL2XconnectClient) Recv() (*L2XconnectDetails, error) { - m := new(L2XconnectDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) BdIPMacAddDel(ctx context.Context, in *BdIPMacAddDel) (*BdIPMacAddDelReply, error) { - out := new(BdIPMacAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BdIPMacFlush(ctx context.Context, in *BdIPMacFlush) (*BdIPMacFlushReply, error) { - out := new(BdIPMacFlushReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BridgeDomainAddDel(ctx context.Context, in *BridgeDomainAddDel) (*BridgeDomainAddDelReply, error) { - out := new(BridgeDomainAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BridgeDomainSetMacAge(ctx context.Context, in *BridgeDomainSetMacAge) (*BridgeDomainSetMacAgeReply, error) { - out := new(BridgeDomainSetMacAgeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BridgeFlags(ctx context.Context, in *BridgeFlags) (*BridgeFlagsReply, error) { - out := new(BridgeFlagsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BviCreate(ctx context.Context, in *BviCreate) (*BviCreateReply, error) { - out := new(BviCreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) BviDelete(ctx context.Context, in *BviDelete) (*BviDeleteReply, error) { - out := new(BviDeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2FibClearTable(ctx context.Context, in *L2FibClearTable) (*L2FibClearTableReply, error) { - out := new(L2FibClearTableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2Flags(ctx context.Context, in *L2Flags) (*L2FlagsReply, error) { - out := new(L2FlagsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2InterfaceEfpFilter(ctx context.Context, in *L2InterfaceEfpFilter) (*L2InterfaceEfpFilterReply, error) { - out := new(L2InterfaceEfpFilterReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2InterfacePbbTagRewrite(ctx context.Context, in *L2InterfacePbbTagRewrite) (*L2InterfacePbbTagRewriteReply, error) { - out := new(L2InterfacePbbTagRewriteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2InterfaceVlanTagRewrite(ctx context.Context, in *L2InterfaceVlanTagRewrite) (*L2InterfaceVlanTagRewriteReply, error) { - out := new(L2InterfaceVlanTagRewriteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2PatchAddDel(ctx context.Context, in *L2PatchAddDel) (*L2PatchAddDelReply, error) { - out := new(L2PatchAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2fibAddDel(ctx context.Context, in *L2fibAddDel) (*L2fibAddDelReply, error) { - out := new(L2fibAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2fibFlushAll(ctx context.Context, in *L2fibFlushAll) (*L2fibFlushAllReply, error) { - out := new(L2fibFlushAllReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2fibFlushBd(ctx context.Context, in *L2fibFlushBd) (*L2fibFlushBdReply, error) { - out := new(L2fibFlushBdReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L2fibFlushInt(ctx context.Context, in *L2fibFlushInt) (*L2fibFlushIntReply, error) { - out := new(L2fibFlushIntReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetL2Bridge(ctx context.Context, in *SwInterfaceSetL2Bridge) (*SwInterfaceSetL2BridgeReply, error) { - out := new(SwInterfaceSetL2BridgeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetL2Xconnect(ctx context.Context, in *SwInterfaceSetL2Xconnect) (*SwInterfaceSetL2XconnectReply, error) { - out := new(SwInterfaceSetL2XconnectReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SwInterfaceSetVpath(ctx context.Context, in *SwInterfaceSetVpath) (*SwInterfaceSetVpathReply, error) { - out := new(SwInterfaceSetVpathReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) WantL2ArpTermEvents(ctx context.Context, in *WantL2ArpTermEvents) (*WantL2ArpTermEventsReply, error) { - out := new(WantL2ArpTermEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) WantL2MacsEvents(ctx context.Context, in *WantL2MacsEvents) (*WantL2MacsEventsReply, error) { - out := new(WantL2MacsEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/l3xc/l3xc.ba.go b/plugins/vpp/binapi/vpp2001/l3xc/l3xc.ba.go deleted file mode 100644 index 60b8228d60..0000000000 --- a/plugins/vpp/binapi/vpp2001/l3xc/l3xc.ba.go +++ /dev/null @@ -1,295 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/l3xc.api.json - -/* -Package l3xc is a generated VPP binary API for 'l3xc' module. - -It consists of: - 13 enums - 6 aliases - 10 types - 1 union - 8 messages - 4 services -*/ -package l3xc - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - fib_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "l3xc" - // APIVersion is the API version of this module. - APIVersion = "1.0.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0x80b00c99 -) - -type AddressFamily = ip_types.AddressFamily - -type FibPathFlags = fib_types.FibPathFlags - -type FibPathNhProto = fib_types.FibPathNhProto - -type FibPathType = fib_types.FibPathType - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type FibMplsLabel = fib_types.FibMplsLabel - -type FibPath = fib_types.FibPath - -type FibPathNh = fib_types.FibPathNh - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -// L3xc represents VPP binary API type 'l3xc'. -type L3xc struct { - SwIfIndex InterfaceIndex - IsIP6 bool - NPaths uint8 `struc:"sizeof=Paths"` - Paths []FibPath -} - -func (*L3xc) GetTypeName() string { return "l3xc" } - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// L3xcDel represents VPP binary API message 'l3xc_del'. -type L3xcDel struct { - SwIfIndex InterfaceIndex - IsIP6 bool -} - -func (m *L3xcDel) Reset() { *m = L3xcDel{} } -func (*L3xcDel) GetMessageName() string { return "l3xc_del" } -func (*L3xcDel) GetCrcString() string { return "e7dbef91" } -func (*L3xcDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// L3xcDelReply represents VPP binary API message 'l3xc_del_reply'. -type L3xcDelReply struct { - Retval int32 -} - -func (m *L3xcDelReply) Reset() { *m = L3xcDelReply{} } -func (*L3xcDelReply) GetMessageName() string { return "l3xc_del_reply" } -func (*L3xcDelReply) GetCrcString() string { return "e8d4e804" } -func (*L3xcDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L3xcDetails represents VPP binary API message 'l3xc_details'. -type L3xcDetails struct { - L3xc L3xc -} - -func (m *L3xcDetails) Reset() { *m = L3xcDetails{} } -func (*L3xcDetails) GetMessageName() string { return "l3xc_details" } -func (*L3xcDetails) GetCrcString() string { return "d4f69627" } -func (*L3xcDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L3xcDump represents VPP binary API message 'l3xc_dump'. -type L3xcDump struct { - SwIfIndex InterfaceIndex -} - -func (m *L3xcDump) Reset() { *m = L3xcDump{} } -func (*L3xcDump) GetMessageName() string { return "l3xc_dump" } -func (*L3xcDump) GetCrcString() string { return "f9e6675e" } -func (*L3xcDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// L3xcPluginGetVersion represents VPP binary API message 'l3xc_plugin_get_version'. -type L3xcPluginGetVersion struct{} - -func (m *L3xcPluginGetVersion) Reset() { *m = L3xcPluginGetVersion{} } -func (*L3xcPluginGetVersion) GetMessageName() string { return "l3xc_plugin_get_version" } -func (*L3xcPluginGetVersion) GetCrcString() string { return "51077d14" } -func (*L3xcPluginGetVersion) GetMessageType() api.MessageType { return api.RequestMessage } - -// L3xcPluginGetVersionReply represents VPP binary API message 'l3xc_plugin_get_version_reply'. -type L3xcPluginGetVersionReply struct { - Major uint32 - Minor uint32 -} - -func (m *L3xcPluginGetVersionReply) Reset() { *m = L3xcPluginGetVersionReply{} } -func (*L3xcPluginGetVersionReply) GetMessageName() string { return "l3xc_plugin_get_version_reply" } -func (*L3xcPluginGetVersionReply) GetCrcString() string { return "9b32cf86" } -func (*L3xcPluginGetVersionReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// L3xcUpdate represents VPP binary API message 'l3xc_update'. -type L3xcUpdate struct { - L3xc L3xc -} - -func (m *L3xcUpdate) Reset() { *m = L3xcUpdate{} } -func (*L3xcUpdate) GetMessageName() string { return "l3xc_update" } -func (*L3xcUpdate) GetCrcString() string { return "0787b1d3" } -func (*L3xcUpdate) GetMessageType() api.MessageType { return api.RequestMessage } - -// L3xcUpdateReply represents VPP binary API message 'l3xc_update_reply'. -type L3xcUpdateReply struct { - Retval int32 - StatsIndex uint32 -} - -func (m *L3xcUpdateReply) Reset() { *m = L3xcUpdateReply{} } -func (*L3xcUpdateReply) GetMessageName() string { return "l3xc_update_reply" } -func (*L3xcUpdateReply) GetCrcString() string { return "1992deab" } -func (*L3xcUpdateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*L3xcDel)(nil), "l3xc.L3xcDel") - api.RegisterMessage((*L3xcDelReply)(nil), "l3xc.L3xcDelReply") - api.RegisterMessage((*L3xcDetails)(nil), "l3xc.L3xcDetails") - api.RegisterMessage((*L3xcDump)(nil), "l3xc.L3xcDump") - api.RegisterMessage((*L3xcPluginGetVersion)(nil), "l3xc.L3xcPluginGetVersion") - api.RegisterMessage((*L3xcPluginGetVersionReply)(nil), "l3xc.L3xcPluginGetVersionReply") - api.RegisterMessage((*L3xcUpdate)(nil), "l3xc.L3xcUpdate") - api.RegisterMessage((*L3xcUpdateReply)(nil), "l3xc.L3xcUpdateReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*L3xcDel)(nil), - (*L3xcDelReply)(nil), - (*L3xcDetails)(nil), - (*L3xcDump)(nil), - (*L3xcPluginGetVersion)(nil), - (*L3xcPluginGetVersionReply)(nil), - (*L3xcUpdate)(nil), - (*L3xcUpdateReply)(nil), - } -} - -// RPCService represents RPC service API for l3xc module. -type RPCService interface { - DumpL3xc(ctx context.Context, in *L3xcDump) (RPCService_DumpL3xcClient, error) - L3xcDel(ctx context.Context, in *L3xcDel) (*L3xcDelReply, error) - L3xcPluginGetVersion(ctx context.Context, in *L3xcPluginGetVersion) (*L3xcPluginGetVersionReply, error) - L3xcUpdate(ctx context.Context, in *L3xcUpdate) (*L3xcUpdateReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpL3xc(ctx context.Context, in *L3xcDump) (RPCService_DumpL3xcClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpL3xcClient{stream} - return x, nil -} - -type RPCService_DumpL3xcClient interface { - Recv() (*L3xcDetails, error) -} - -type serviceClient_DumpL3xcClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpL3xcClient) Recv() (*L3xcDetails, error) { - m := new(L3xcDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) L3xcDel(ctx context.Context, in *L3xcDel) (*L3xcDelReply, error) { - out := new(L3xcDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L3xcPluginGetVersion(ctx context.Context, in *L3xcPluginGetVersion) (*L3xcPluginGetVersionReply, error) { - out := new(L3xcPluginGetVersionReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) L3xcUpdate(ctx context.Context, in *L3xcUpdate) (*L3xcUpdateReply, error) { - out := new(L3xcUpdateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/memclnt/memclnt.ba.go b/plugins/vpp/binapi/vpp2001/memclnt/memclnt.ba.go deleted file mode 100644 index a3ca389e14..0000000000 --- a/plugins/vpp/binapi/vpp2001/memclnt/memclnt.ba.go +++ /dev/null @@ -1,482 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/memclnt.api.json - -/* -Package memclnt is a generated VPP binary API for 'memclnt' module. - -It consists of: - 2 types - 22 messages - 13 services -*/ -package memclnt - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "memclnt" - // APIVersion is the API version of this module. - APIVersion = "2.1.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x8d3dd881 -) - -// MessageTableEntry represents VPP binary API type 'message_table_entry'. -type MessageTableEntry struct { - Index uint16 - Name string `struc:"[64]byte"` -} - -func (*MessageTableEntry) GetTypeName() string { return "message_table_entry" } - -// ModuleVersion represents VPP binary API type 'module_version'. -type ModuleVersion struct { - Major uint32 - Minor uint32 - Patch uint32 - Name string `struc:"[64]byte"` -} - -func (*ModuleVersion) GetTypeName() string { return "module_version" } - -// APIVersions represents VPP binary API message 'api_versions'. -type APIVersions struct{} - -func (m *APIVersions) Reset() { *m = APIVersions{} } -func (*APIVersions) GetMessageName() string { return "api_versions" } -func (*APIVersions) GetCrcString() string { return "51077d14" } -func (*APIVersions) GetMessageType() api.MessageType { return api.RequestMessage } - -// APIVersionsReply represents VPP binary API message 'api_versions_reply'. -type APIVersionsReply struct { - Retval int32 - Count uint32 `struc:"sizeof=APIVersions"` - APIVersions []ModuleVersion -} - -func (m *APIVersionsReply) Reset() { *m = APIVersionsReply{} } -func (*APIVersionsReply) GetMessageName() string { return "api_versions_reply" } -func (*APIVersionsReply) GetCrcString() string { return "5f0d99d6" } -func (*APIVersionsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GetFirstMsgID represents VPP binary API message 'get_first_msg_id'. -type GetFirstMsgID struct { - Name string `struc:"[64]byte"` -} - -func (m *GetFirstMsgID) Reset() { *m = GetFirstMsgID{} } -func (*GetFirstMsgID) GetMessageName() string { return "get_first_msg_id" } -func (*GetFirstMsgID) GetCrcString() string { return "ebf79a66" } -func (*GetFirstMsgID) GetMessageType() api.MessageType { return api.RequestMessage } - -// GetFirstMsgIDReply represents VPP binary API message 'get_first_msg_id_reply'. -type GetFirstMsgIDReply struct { - Retval int32 - FirstMsgID uint16 -} - -func (m *GetFirstMsgIDReply) Reset() { *m = GetFirstMsgIDReply{} } -func (*GetFirstMsgIDReply) GetMessageName() string { return "get_first_msg_id_reply" } -func (*GetFirstMsgIDReply) GetCrcString() string { return "7d337472" } -func (*GetFirstMsgIDReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemclntCreate represents VPP binary API message 'memclnt_create'. -type MemclntCreate struct { - CtxQuota int32 - InputQueue uint64 - Name string `struc:"[64]byte"` - APIVersions []uint32 `struc:"[8]uint32"` -} - -func (m *MemclntCreate) Reset() { *m = MemclntCreate{} } -func (*MemclntCreate) GetMessageName() string { return "memclnt_create" } -func (*MemclntCreate) GetCrcString() string { return "9c5e1c2f" } -func (*MemclntCreate) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemclntCreateReply represents VPP binary API message 'memclnt_create_reply'. -type MemclntCreateReply struct { - Response int32 - Handle uint64 - Index uint32 - MessageTable uint64 -} - -func (m *MemclntCreateReply) Reset() { *m = MemclntCreateReply{} } -func (*MemclntCreateReply) GetMessageName() string { return "memclnt_create_reply" } -func (*MemclntCreateReply) GetCrcString() string { return "42ec4560" } -func (*MemclntCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemclntDelete represents VPP binary API message 'memclnt_delete'. -type MemclntDelete struct { - Index uint32 - Handle uint64 - DoCleanup bool -} - -func (m *MemclntDelete) Reset() { *m = MemclntDelete{} } -func (*MemclntDelete) GetMessageName() string { return "memclnt_delete" } -func (*MemclntDelete) GetCrcString() string { return "7e1c04e3" } -func (*MemclntDelete) GetMessageType() api.MessageType { return api.OtherMessage } - -// MemclntDeleteReply represents VPP binary API message 'memclnt_delete_reply'. -type MemclntDeleteReply struct { - Response int32 - Handle uint64 -} - -func (m *MemclntDeleteReply) Reset() { *m = MemclntDeleteReply{} } -func (*MemclntDeleteReply) GetMessageName() string { return "memclnt_delete_reply" } -func (*MemclntDeleteReply) GetCrcString() string { return "3d3b6312" } -func (*MemclntDeleteReply) GetMessageType() api.MessageType { return api.OtherMessage } - -// MemclntKeepalive represents VPP binary API message 'memclnt_keepalive'. -type MemclntKeepalive struct{} - -func (m *MemclntKeepalive) Reset() { *m = MemclntKeepalive{} } -func (*MemclntKeepalive) GetMessageName() string { return "memclnt_keepalive" } -func (*MemclntKeepalive) GetCrcString() string { return "51077d14" } -func (*MemclntKeepalive) GetMessageType() api.MessageType { return api.RequestMessage } - -// MemclntKeepaliveReply represents VPP binary API message 'memclnt_keepalive_reply'. -type MemclntKeepaliveReply struct { - Retval int32 -} - -func (m *MemclntKeepaliveReply) Reset() { *m = MemclntKeepaliveReply{} } -func (*MemclntKeepaliveReply) GetMessageName() string { return "memclnt_keepalive_reply" } -func (*MemclntKeepaliveReply) GetCrcString() string { return "e8d4e804" } -func (*MemclntKeepaliveReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemclntReadTimeout represents VPP binary API message 'memclnt_read_timeout'. -type MemclntReadTimeout struct { - Dummy uint8 -} - -func (m *MemclntReadTimeout) Reset() { *m = MemclntReadTimeout{} } -func (*MemclntReadTimeout) GetMessageName() string { return "memclnt_read_timeout" } -func (*MemclntReadTimeout) GetCrcString() string { return "c3a3a452" } -func (*MemclntReadTimeout) GetMessageType() api.MessageType { return api.OtherMessage } - -// MemclntRxThreadSuspend represents VPP binary API message 'memclnt_rx_thread_suspend'. -type MemclntRxThreadSuspend struct { - Dummy uint8 -} - -func (m *MemclntRxThreadSuspend) Reset() { *m = MemclntRxThreadSuspend{} } -func (*MemclntRxThreadSuspend) GetMessageName() string { return "memclnt_rx_thread_suspend" } -func (*MemclntRxThreadSuspend) GetCrcString() string { return "c3a3a452" } -func (*MemclntRxThreadSuspend) GetMessageType() api.MessageType { return api.OtherMessage } - -// RPCCall represents VPP binary API message 'rpc_call'. -type RPCCall struct { - Function uint64 - Multicast uint8 - NeedBarrierSync uint8 - SendReply uint8 - DataLen uint32 `struc:"sizeof=Data"` - Data []byte -} - -func (m *RPCCall) Reset() { *m = RPCCall{} } -func (*RPCCall) GetMessageName() string { return "rpc_call" } -func (*RPCCall) GetCrcString() string { return "7e8a2c95" } -func (*RPCCall) GetMessageType() api.MessageType { return api.RequestMessage } - -// RPCCallReply represents VPP binary API message 'rpc_call_reply'. -type RPCCallReply struct { - Retval int32 -} - -func (m *RPCCallReply) Reset() { *m = RPCCallReply{} } -func (*RPCCallReply) GetMessageName() string { return "rpc_call_reply" } -func (*RPCCallReply) GetCrcString() string { return "e8d4e804" } -func (*RPCCallReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// RxThreadExit represents VPP binary API message 'rx_thread_exit'. -type RxThreadExit struct { - Dummy uint8 -} - -func (m *RxThreadExit) Reset() { *m = RxThreadExit{} } -func (*RxThreadExit) GetMessageName() string { return "rx_thread_exit" } -func (*RxThreadExit) GetCrcString() string { return "c3a3a452" } -func (*RxThreadExit) GetMessageType() api.MessageType { return api.OtherMessage } - -// SockInitShm represents VPP binary API message 'sock_init_shm'. -type SockInitShm struct { - RequestedSize uint32 - Nitems uint8 `struc:"sizeof=Configs"` - Configs []uint64 -} - -func (m *SockInitShm) Reset() { *m = SockInitShm{} } -func (*SockInitShm) GetMessageName() string { return "sock_init_shm" } -func (*SockInitShm) GetCrcString() string { return "51646d92" } -func (*SockInitShm) GetMessageType() api.MessageType { return api.RequestMessage } - -// SockInitShmReply represents VPP binary API message 'sock_init_shm_reply'. -type SockInitShmReply struct { - Retval int32 -} - -func (m *SockInitShmReply) Reset() { *m = SockInitShmReply{} } -func (*SockInitShmReply) GetMessageName() string { return "sock_init_shm_reply" } -func (*SockInitShmReply) GetCrcString() string { return "e8d4e804" } -func (*SockInitShmReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SockclntCreate represents VPP binary API message 'sockclnt_create'. -type SockclntCreate struct { - Name string `struc:"[64]byte"` -} - -func (m *SockclntCreate) Reset() { *m = SockclntCreate{} } -func (*SockclntCreate) GetMessageName() string { return "sockclnt_create" } -func (*SockclntCreate) GetCrcString() string { return "455fb9c4" } -func (*SockclntCreate) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SockclntCreateReply represents VPP binary API message 'sockclnt_create_reply'. -type SockclntCreateReply struct { - Response int32 - Index uint32 - Count uint16 `struc:"sizeof=MessageTable"` - MessageTable []MessageTableEntry -} - -func (m *SockclntCreateReply) Reset() { *m = SockclntCreateReply{} } -func (*SockclntCreateReply) GetMessageName() string { return "sockclnt_create_reply" } -func (*SockclntCreateReply) GetCrcString() string { return "35166268" } -func (*SockclntCreateReply) GetMessageType() api.MessageType { return api.RequestMessage } - -// SockclntDelete represents VPP binary API message 'sockclnt_delete'. -type SockclntDelete struct { - Index uint32 -} - -func (m *SockclntDelete) Reset() { *m = SockclntDelete{} } -func (*SockclntDelete) GetMessageName() string { return "sockclnt_delete" } -func (*SockclntDelete) GetCrcString() string { return "8ac76db6" } -func (*SockclntDelete) GetMessageType() api.MessageType { return api.RequestMessage } - -// SockclntDeleteReply represents VPP binary API message 'sockclnt_delete_reply'. -type SockclntDeleteReply struct { - Response int32 -} - -func (m *SockclntDeleteReply) Reset() { *m = SockclntDeleteReply{} } -func (*SockclntDeleteReply) GetMessageName() string { return "sockclnt_delete_reply" } -func (*SockclntDeleteReply) GetCrcString() string { return "8f38b1ee" } -func (*SockclntDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// TracePluginMsgIds represents VPP binary API message 'trace_plugin_msg_ids'. -type TracePluginMsgIds struct { - PluginName string `struc:"[128]byte"` - FirstMsgID uint16 - LastMsgID uint16 -} - -func (m *TracePluginMsgIds) Reset() { *m = TracePluginMsgIds{} } -func (*TracePluginMsgIds) GetMessageName() string { return "trace_plugin_msg_ids" } -func (*TracePluginMsgIds) GetCrcString() string { return "f476d3ce" } -func (*TracePluginMsgIds) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*APIVersions)(nil), "memclnt.APIVersions") - api.RegisterMessage((*APIVersionsReply)(nil), "memclnt.APIVersionsReply") - api.RegisterMessage((*GetFirstMsgID)(nil), "memclnt.GetFirstMsgID") - api.RegisterMessage((*GetFirstMsgIDReply)(nil), "memclnt.GetFirstMsgIDReply") - api.RegisterMessage((*MemclntCreate)(nil), "memclnt.MemclntCreate") - api.RegisterMessage((*MemclntCreateReply)(nil), "memclnt.MemclntCreateReply") - api.RegisterMessage((*MemclntDelete)(nil), "memclnt.MemclntDelete") - api.RegisterMessage((*MemclntDeleteReply)(nil), "memclnt.MemclntDeleteReply") - api.RegisterMessage((*MemclntKeepalive)(nil), "memclnt.MemclntKeepalive") - api.RegisterMessage((*MemclntKeepaliveReply)(nil), "memclnt.MemclntKeepaliveReply") - api.RegisterMessage((*MemclntReadTimeout)(nil), "memclnt.MemclntReadTimeout") - api.RegisterMessage((*MemclntRxThreadSuspend)(nil), "memclnt.MemclntRxThreadSuspend") - api.RegisterMessage((*RPCCall)(nil), "memclnt.RPCCall") - api.RegisterMessage((*RPCCallReply)(nil), "memclnt.RPCCallReply") - api.RegisterMessage((*RxThreadExit)(nil), "memclnt.RxThreadExit") - api.RegisterMessage((*SockInitShm)(nil), "memclnt.SockInitShm") - api.RegisterMessage((*SockInitShmReply)(nil), "memclnt.SockInitShmReply") - api.RegisterMessage((*SockclntCreate)(nil), "memclnt.SockclntCreate") - api.RegisterMessage((*SockclntCreateReply)(nil), "memclnt.SockclntCreateReply") - api.RegisterMessage((*SockclntDelete)(nil), "memclnt.SockclntDelete") - api.RegisterMessage((*SockclntDeleteReply)(nil), "memclnt.SockclntDeleteReply") - api.RegisterMessage((*TracePluginMsgIds)(nil), "memclnt.TracePluginMsgIds") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*APIVersions)(nil), - (*APIVersionsReply)(nil), - (*GetFirstMsgID)(nil), - (*GetFirstMsgIDReply)(nil), - (*MemclntCreate)(nil), - (*MemclntCreateReply)(nil), - (*MemclntDelete)(nil), - (*MemclntDeleteReply)(nil), - (*MemclntKeepalive)(nil), - (*MemclntKeepaliveReply)(nil), - (*MemclntReadTimeout)(nil), - (*MemclntRxThreadSuspend)(nil), - (*RPCCall)(nil), - (*RPCCallReply)(nil), - (*RxThreadExit)(nil), - (*SockInitShm)(nil), - (*SockInitShmReply)(nil), - (*SockclntCreate)(nil), - (*SockclntCreateReply)(nil), - (*SockclntDelete)(nil), - (*SockclntDeleteReply)(nil), - (*TracePluginMsgIds)(nil), - } -} - -// RPCService represents RPC service API for memclnt module. -type RPCService interface { - APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) - GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) - MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) - MemclntDelete(ctx context.Context, in *MemclntDelete) (*MemclntDeleteReply, error) - MemclntKeepalive(ctx context.Context, in *MemclntKeepalive) (*MemclntKeepaliveReply, error) - MemclntReadTimeout(ctx context.Context, in *MemclntReadTimeout) error - MemclntRxThreadSuspend(ctx context.Context, in *MemclntRxThreadSuspend) error - RPCCall(ctx context.Context, in *RPCCall) (*RPCCallReply, error) - RxThreadExit(ctx context.Context, in *RxThreadExit) error - SockInitShm(ctx context.Context, in *SockInitShm) (*SockInitShmReply, error) - SockclntCreate(ctx context.Context, in *SockclntCreate) (*SockclntCreateReply, error) - SockclntDelete(ctx context.Context, in *SockclntDelete) (*SockclntDeleteReply, error) - TracePluginMsgIds(ctx context.Context, in *TracePluginMsgIds) error -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) APIVersions(ctx context.Context, in *APIVersions) (*APIVersionsReply, error) { - out := new(APIVersionsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetFirstMsgID(ctx context.Context, in *GetFirstMsgID) (*GetFirstMsgIDReply, error) { - out := new(GetFirstMsgIDReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MemclntCreate(ctx context.Context, in *MemclntCreate) (*MemclntCreateReply, error) { - out := new(MemclntCreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MemclntDelete(ctx context.Context, in *MemclntDelete) (*MemclntDeleteReply, error) { - out := new(MemclntDeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MemclntKeepalive(ctx context.Context, in *MemclntKeepalive) (*MemclntKeepaliveReply, error) { - out := new(MemclntKeepaliveReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MemclntReadTimeout(ctx context.Context, in *MemclntReadTimeout) error { - c.ch.SendRequest(in) - return nil -} - -func (c *serviceClient) MemclntRxThreadSuspend(ctx context.Context, in *MemclntRxThreadSuspend) error { - c.ch.SendRequest(in) - return nil -} - -func (c *serviceClient) RPCCall(ctx context.Context, in *RPCCall) (*RPCCallReply, error) { - out := new(RPCCallReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) RxThreadExit(ctx context.Context, in *RxThreadExit) error { - c.ch.SendRequest(in) - return nil -} - -func (c *serviceClient) SockInitShm(ctx context.Context, in *SockInitShm) (*SockInitShmReply, error) { - out := new(SockInitShmReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SockclntCreate(ctx context.Context, in *SockclntCreate) (*SockclntCreateReply, error) { - out := new(SockclntCreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SockclntDelete(ctx context.Context, in *SockclntDelete) (*SockclntDeleteReply, error) { - out := new(SockclntDeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) TracePluginMsgIds(ctx context.Context, in *TracePluginMsgIds) error { - c.ch.SendRequest(in) - return nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/memif/memif.ba.go b/plugins/vpp/binapi/vpp2001/memif/memif.ba.go deleted file mode 100644 index 092bdab7d7..0000000000 --- a/plugins/vpp/binapi/vpp2001/memif/memif.ba.go +++ /dev/null @@ -1,367 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/memif.api.json - -/* -Package memif is a generated VPP binary API for 'memif' module. - -It consists of: - 8 enums - 2 aliases - 10 messages - 5 services -*/ -package memif - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "memif" - // APIVersion is the API version of this module. - APIVersion = "3.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x88dc56c9 -) - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type LinkDuplex = interface_types.LinkDuplex - -// MemifMode represents VPP binary API enum 'memif_mode'. -type MemifMode uint32 - -const ( - MEMIF_MODE_API_ETHERNET MemifMode = 0 - MEMIF_MODE_API_IP MemifMode = 1 - MEMIF_MODE_API_PUNT_INJECT MemifMode = 2 -) - -var MemifMode_name = map[uint32]string{ - 0: "MEMIF_MODE_API_ETHERNET", - 1: "MEMIF_MODE_API_IP", - 2: "MEMIF_MODE_API_PUNT_INJECT", -} - -var MemifMode_value = map[string]uint32{ - "MEMIF_MODE_API_ETHERNET": 0, - "MEMIF_MODE_API_IP": 1, - "MEMIF_MODE_API_PUNT_INJECT": 2, -} - -func (x MemifMode) String() string { - s, ok := MemifMode_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// MemifRole represents VPP binary API enum 'memif_role'. -type MemifRole uint32 - -const ( - MEMIF_ROLE_API_MASTER MemifRole = 0 - MEMIF_ROLE_API_SLAVE MemifRole = 1 -) - -var MemifRole_name = map[uint32]string{ - 0: "MEMIF_ROLE_API_MASTER", - 1: "MEMIF_ROLE_API_SLAVE", -} - -var MemifRole_value = map[string]uint32{ - "MEMIF_ROLE_API_MASTER": 0, - "MEMIF_ROLE_API_SLAVE": 1, -} - -func (x MemifRole) String() string { - s, ok := MemifRole_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type InterfaceIndex = interface_types.InterfaceIndex - -type MacAddress = ethernet_types.MacAddress - -// MemifCreate represents VPP binary API message 'memif_create'. -type MemifCreate struct { - Role MemifRole - Mode MemifMode - RxQueues uint8 - TxQueues uint8 - ID uint32 - SocketID uint32 - RingSize uint32 - BufferSize uint16 - NoZeroCopy bool - HwAddr MacAddress - Secret string `struc:"[24]byte"` -} - -func (m *MemifCreate) Reset() { *m = MemifCreate{} } -func (*MemifCreate) GetMessageName() string { return "memif_create" } -func (*MemifCreate) GetCrcString() string { return "b1b25061" } -func (*MemifCreate) GetMessageType() api.MessageType { return api.RequestMessage } - -// MemifCreateReply represents VPP binary API message 'memif_create_reply'. -type MemifCreateReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *MemifCreateReply) Reset() { *m = MemifCreateReply{} } -func (*MemifCreateReply) GetMessageName() string { return "memif_create_reply" } -func (*MemifCreateReply) GetCrcString() string { return "5383d31f" } -func (*MemifCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemifDelete represents VPP binary API message 'memif_delete'. -type MemifDelete struct { - SwIfIndex InterfaceIndex -} - -func (m *MemifDelete) Reset() { *m = MemifDelete{} } -func (*MemifDelete) GetMessageName() string { return "memif_delete" } -func (*MemifDelete) GetCrcString() string { return "f9e6675e" } -func (*MemifDelete) GetMessageType() api.MessageType { return api.RequestMessage } - -// MemifDeleteReply represents VPP binary API message 'memif_delete_reply'. -type MemifDeleteReply struct { - Retval int32 -} - -func (m *MemifDeleteReply) Reset() { *m = MemifDeleteReply{} } -func (*MemifDeleteReply) GetMessageName() string { return "memif_delete_reply" } -func (*MemifDeleteReply) GetCrcString() string { return "e8d4e804" } -func (*MemifDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemifDetails represents VPP binary API message 'memif_details'. -type MemifDetails struct { - SwIfIndex InterfaceIndex - HwAddr MacAddress - ID uint32 - Role MemifRole - Mode MemifMode - ZeroCopy bool - SocketID uint32 - RingSize uint32 - BufferSize uint16 - Flags IfStatusFlags - IfName string `struc:"[64]byte"` -} - -func (m *MemifDetails) Reset() { *m = MemifDetails{} } -func (*MemifDetails) GetMessageName() string { return "memif_details" } -func (*MemifDetails) GetCrcString() string { return "d0382c4c" } -func (*MemifDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemifDump represents VPP binary API message 'memif_dump'. -type MemifDump struct{} - -func (m *MemifDump) Reset() { *m = MemifDump{} } -func (*MemifDump) GetMessageName() string { return "memif_dump" } -func (*MemifDump) GetCrcString() string { return "51077d14" } -func (*MemifDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// MemifSocketFilenameAddDel represents VPP binary API message 'memif_socket_filename_add_del'. -type MemifSocketFilenameAddDel struct { - IsAdd bool - SocketID uint32 - SocketFilename string `struc:"[108]byte"` -} - -func (m *MemifSocketFilenameAddDel) Reset() { *m = MemifSocketFilenameAddDel{} } -func (*MemifSocketFilenameAddDel) GetMessageName() string { return "memif_socket_filename_add_del" } -func (*MemifSocketFilenameAddDel) GetCrcString() string { return "a2ce1a10" } -func (*MemifSocketFilenameAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// MemifSocketFilenameAddDelReply represents VPP binary API message 'memif_socket_filename_add_del_reply'. -type MemifSocketFilenameAddDelReply struct { - Retval int32 -} - -func (m *MemifSocketFilenameAddDelReply) Reset() { *m = MemifSocketFilenameAddDelReply{} } -func (*MemifSocketFilenameAddDelReply) GetMessageName() string { - return "memif_socket_filename_add_del_reply" -} -func (*MemifSocketFilenameAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*MemifSocketFilenameAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemifSocketFilenameDetails represents VPP binary API message 'memif_socket_filename_details'. -type MemifSocketFilenameDetails struct { - SocketID uint32 - SocketFilename string `struc:"[108]byte"` -} - -func (m *MemifSocketFilenameDetails) Reset() { *m = MemifSocketFilenameDetails{} } -func (*MemifSocketFilenameDetails) GetMessageName() string { return "memif_socket_filename_details" } -func (*MemifSocketFilenameDetails) GetCrcString() string { return "7ff326f7" } -func (*MemifSocketFilenameDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// MemifSocketFilenameDump represents VPP binary API message 'memif_socket_filename_dump'. -type MemifSocketFilenameDump struct{} - -func (m *MemifSocketFilenameDump) Reset() { *m = MemifSocketFilenameDump{} } -func (*MemifSocketFilenameDump) GetMessageName() string { return "memif_socket_filename_dump" } -func (*MemifSocketFilenameDump) GetCrcString() string { return "51077d14" } -func (*MemifSocketFilenameDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*MemifCreate)(nil), "memif.MemifCreate") - api.RegisterMessage((*MemifCreateReply)(nil), "memif.MemifCreateReply") - api.RegisterMessage((*MemifDelete)(nil), "memif.MemifDelete") - api.RegisterMessage((*MemifDeleteReply)(nil), "memif.MemifDeleteReply") - api.RegisterMessage((*MemifDetails)(nil), "memif.MemifDetails") - api.RegisterMessage((*MemifDump)(nil), "memif.MemifDump") - api.RegisterMessage((*MemifSocketFilenameAddDel)(nil), "memif.MemifSocketFilenameAddDel") - api.RegisterMessage((*MemifSocketFilenameAddDelReply)(nil), "memif.MemifSocketFilenameAddDelReply") - api.RegisterMessage((*MemifSocketFilenameDetails)(nil), "memif.MemifSocketFilenameDetails") - api.RegisterMessage((*MemifSocketFilenameDump)(nil), "memif.MemifSocketFilenameDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*MemifCreate)(nil), - (*MemifCreateReply)(nil), - (*MemifDelete)(nil), - (*MemifDeleteReply)(nil), - (*MemifDetails)(nil), - (*MemifDump)(nil), - (*MemifSocketFilenameAddDel)(nil), - (*MemifSocketFilenameAddDelReply)(nil), - (*MemifSocketFilenameDetails)(nil), - (*MemifSocketFilenameDump)(nil), - } -} - -// RPCService represents RPC service API for memif module. -type RPCService interface { - DumpMemif(ctx context.Context, in *MemifDump) (RPCService_DumpMemifClient, error) - DumpMemifSocketFilename(ctx context.Context, in *MemifSocketFilenameDump) (RPCService_DumpMemifSocketFilenameClient, error) - MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) - MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) - MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocketFilenameAddDel) (*MemifSocketFilenameAddDelReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpMemif(ctx context.Context, in *MemifDump) (RPCService_DumpMemifClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpMemifClient{stream} - return x, nil -} - -type RPCService_DumpMemifClient interface { - Recv() (*MemifDetails, error) -} - -type serviceClient_DumpMemifClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpMemifClient) Recv() (*MemifDetails, error) { - m := new(MemifDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpMemifSocketFilename(ctx context.Context, in *MemifSocketFilenameDump) (RPCService_DumpMemifSocketFilenameClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpMemifSocketFilenameClient{stream} - return x, nil -} - -type RPCService_DumpMemifSocketFilenameClient interface { - Recv() (*MemifSocketFilenameDetails, error) -} - -type serviceClient_DumpMemifSocketFilenameClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpMemifSocketFilenameClient) Recv() (*MemifSocketFilenameDetails, error) { - m := new(MemifSocketFilenameDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) MemifCreate(ctx context.Context, in *MemifCreate) (*MemifCreateReply, error) { - out := new(MemifCreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MemifDelete(ctx context.Context, in *MemifDelete) (*MemifDeleteReply, error) { - out := new(MemifDeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) MemifSocketFilenameAddDel(ctx context.Context, in *MemifSocketFilenameAddDel) (*MemifSocketFilenameAddDelReply, error) { - out := new(MemifSocketFilenameAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/nat/nat.ba.go b/plugins/vpp/binapi/vpp2001/nat/nat.ba.go deleted file mode 100644 index 37a838dd22..0000000000 --- a/plugins/vpp/binapi/vpp2001/nat/nat.ba.go +++ /dev/null @@ -1,2987 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/nat.api.json - -/* -Package nat is a generated VPP binary API for 'nat' module. - -It consists of: - 12 enums - 6 aliases - 7 types - 1 union - 131 messages - 65 services -*/ -package nat - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "nat" - // APIVersion is the API version of this module. - APIVersion = "5.2.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xef1a1c94 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -// NatConfigFlags represents VPP binary API enum 'nat_config_flags'. -type NatConfigFlags uint8 - -const ( - NAT_IS_NONE NatConfigFlags = 0 - NAT_IS_TWICE_NAT NatConfigFlags = 1 - NAT_IS_SELF_TWICE_NAT NatConfigFlags = 2 - NAT_IS_OUT2IN_ONLY NatConfigFlags = 4 - NAT_IS_ADDR_ONLY NatConfigFlags = 8 - NAT_IS_OUTSIDE NatConfigFlags = 16 - NAT_IS_INSIDE NatConfigFlags = 32 - NAT_IS_STATIC NatConfigFlags = 64 - NAT_IS_EXT_HOST_VALID NatConfigFlags = 128 -) - -var NatConfigFlags_name = map[uint8]string{ - 0: "NAT_IS_NONE", - 1: "NAT_IS_TWICE_NAT", - 2: "NAT_IS_SELF_TWICE_NAT", - 4: "NAT_IS_OUT2IN_ONLY", - 8: "NAT_IS_ADDR_ONLY", - 16: "NAT_IS_OUTSIDE", - 32: "NAT_IS_INSIDE", - 64: "NAT_IS_STATIC", - 128: "NAT_IS_EXT_HOST_VALID", -} - -var NatConfigFlags_value = map[string]uint8{ - "NAT_IS_NONE": 0, - "NAT_IS_TWICE_NAT": 1, - "NAT_IS_SELF_TWICE_NAT": 2, - "NAT_IS_OUT2IN_ONLY": 4, - "NAT_IS_ADDR_ONLY": 8, - "NAT_IS_OUTSIDE": 16, - "NAT_IS_INSIDE": 32, - "NAT_IS_STATIC": 64, - "NAT_IS_EXT_HOST_VALID": 128, -} - -func (x NatConfigFlags) String() string { - s, ok := NatConfigFlags_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// NatLogLevel represents VPP binary API enum 'nat_log_level'. -type NatLogLevel uint8 - -const ( - NAT_LOG_NONE NatLogLevel = 0 - NAT_LOG_ERROR NatLogLevel = 1 - NAT_LOG_WARNING NatLogLevel = 2 - NAT_LOG_NOTICE NatLogLevel = 3 - NAT_LOG_INFO NatLogLevel = 4 - NAT_LOG_DEBUG NatLogLevel = 5 -) - -var NatLogLevel_name = map[uint8]string{ - 0: "NAT_LOG_NONE", - 1: "NAT_LOG_ERROR", - 2: "NAT_LOG_WARNING", - 3: "NAT_LOG_NOTICE", - 4: "NAT_LOG_INFO", - 5: "NAT_LOG_DEBUG", -} - -var NatLogLevel_value = map[string]uint8{ - "NAT_LOG_NONE": 0, - "NAT_LOG_ERROR": 1, - "NAT_LOG_WARNING": 2, - "NAT_LOG_NOTICE": 3, - "NAT_LOG_INFO": 4, - "NAT_LOG_DEBUG": 5, -} - -func (x NatLogLevel) String() string { - s, ok := NatLogLevel_name[uint8(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -// Nat44LbAddrPort represents VPP binary API type 'nat44_lb_addr_port'. -type Nat44LbAddrPort struct { - Addr IP4Address - Port uint16 - Probability uint8 - VrfID uint32 -} - -func (*Nat44LbAddrPort) GetTypeName() string { return "nat44_lb_addr_port" } - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// DsliteAddDelPoolAddrRange represents VPP binary API message 'dslite_add_del_pool_addr_range'. -type DsliteAddDelPoolAddrRange struct { - StartAddr IP4Address - EndAddr IP4Address - IsAdd bool -} - -func (m *DsliteAddDelPoolAddrRange) Reset() { *m = DsliteAddDelPoolAddrRange{} } -func (*DsliteAddDelPoolAddrRange) GetMessageName() string { return "dslite_add_del_pool_addr_range" } -func (*DsliteAddDelPoolAddrRange) GetCrcString() string { return "c448457a" } -func (*DsliteAddDelPoolAddrRange) GetMessageType() api.MessageType { return api.RequestMessage } - -// DsliteAddDelPoolAddrRangeReply represents VPP binary API message 'dslite_add_del_pool_addr_range_reply'. -type DsliteAddDelPoolAddrRangeReply struct { - Retval int32 -} - -func (m *DsliteAddDelPoolAddrRangeReply) Reset() { *m = DsliteAddDelPoolAddrRangeReply{} } -func (*DsliteAddDelPoolAddrRangeReply) GetMessageName() string { - return "dslite_add_del_pool_addr_range_reply" -} -func (*DsliteAddDelPoolAddrRangeReply) GetCrcString() string { return "e8d4e804" } -func (*DsliteAddDelPoolAddrRangeReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DsliteAddressDetails represents VPP binary API message 'dslite_address_details'. -type DsliteAddressDetails struct { - IPAddress IP4Address -} - -func (m *DsliteAddressDetails) Reset() { *m = DsliteAddressDetails{} } -func (*DsliteAddressDetails) GetMessageName() string { return "dslite_address_details" } -func (*DsliteAddressDetails) GetCrcString() string { return "ec26d648" } -func (*DsliteAddressDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DsliteAddressDump represents VPP binary API message 'dslite_address_dump'. -type DsliteAddressDump struct{} - -func (m *DsliteAddressDump) Reset() { *m = DsliteAddressDump{} } -func (*DsliteAddressDump) GetMessageName() string { return "dslite_address_dump" } -func (*DsliteAddressDump) GetCrcString() string { return "51077d14" } -func (*DsliteAddressDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// DsliteGetAftrAddr represents VPP binary API message 'dslite_get_aftr_addr'. -type DsliteGetAftrAddr struct{} - -func (m *DsliteGetAftrAddr) Reset() { *m = DsliteGetAftrAddr{} } -func (*DsliteGetAftrAddr) GetMessageName() string { return "dslite_get_aftr_addr" } -func (*DsliteGetAftrAddr) GetCrcString() string { return "51077d14" } -func (*DsliteGetAftrAddr) GetMessageType() api.MessageType { return api.RequestMessage } - -// DsliteGetAftrAddrReply represents VPP binary API message 'dslite_get_aftr_addr_reply'. -type DsliteGetAftrAddrReply struct { - Retval int32 - IP4Addr IP4Address - IP6Addr IP6Address -} - -func (m *DsliteGetAftrAddrReply) Reset() { *m = DsliteGetAftrAddrReply{} } -func (*DsliteGetAftrAddrReply) GetMessageName() string { return "dslite_get_aftr_addr_reply" } -func (*DsliteGetAftrAddrReply) GetCrcString() string { return "38e30db1" } -func (*DsliteGetAftrAddrReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DsliteGetB4Addr represents VPP binary API message 'dslite_get_b4_addr'. -type DsliteGetB4Addr struct{} - -func (m *DsliteGetB4Addr) Reset() { *m = DsliteGetB4Addr{} } -func (*DsliteGetB4Addr) GetMessageName() string { return "dslite_get_b4_addr" } -func (*DsliteGetB4Addr) GetCrcString() string { return "51077d14" } -func (*DsliteGetB4Addr) GetMessageType() api.MessageType { return api.RequestMessage } - -// DsliteGetB4AddrReply represents VPP binary API message 'dslite_get_b4_addr_reply'. -type DsliteGetB4AddrReply struct { - Retval int32 - IP4Addr IP4Address - IP6Addr IP6Address -} - -func (m *DsliteGetB4AddrReply) Reset() { *m = DsliteGetB4AddrReply{} } -func (*DsliteGetB4AddrReply) GetMessageName() string { return "dslite_get_b4_addr_reply" } -func (*DsliteGetB4AddrReply) GetCrcString() string { return "38e30db1" } -func (*DsliteGetB4AddrReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DsliteSetAftrAddr represents VPP binary API message 'dslite_set_aftr_addr'. -type DsliteSetAftrAddr struct { - IP4Addr IP4Address - IP6Addr IP6Address -} - -func (m *DsliteSetAftrAddr) Reset() { *m = DsliteSetAftrAddr{} } -func (*DsliteSetAftrAddr) GetMessageName() string { return "dslite_set_aftr_addr" } -func (*DsliteSetAftrAddr) GetCrcString() string { return "1e955f8d" } -func (*DsliteSetAftrAddr) GetMessageType() api.MessageType { return api.RequestMessage } - -// DsliteSetAftrAddrReply represents VPP binary API message 'dslite_set_aftr_addr_reply'. -type DsliteSetAftrAddrReply struct { - Retval int32 -} - -func (m *DsliteSetAftrAddrReply) Reset() { *m = DsliteSetAftrAddrReply{} } -func (*DsliteSetAftrAddrReply) GetMessageName() string { return "dslite_set_aftr_addr_reply" } -func (*DsliteSetAftrAddrReply) GetCrcString() string { return "e8d4e804" } -func (*DsliteSetAftrAddrReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// DsliteSetB4Addr represents VPP binary API message 'dslite_set_b4_addr'. -type DsliteSetB4Addr struct { - IP4Addr IP4Address - IP6Addr IP6Address -} - -func (m *DsliteSetB4Addr) Reset() { *m = DsliteSetB4Addr{} } -func (*DsliteSetB4Addr) GetMessageName() string { return "dslite_set_b4_addr" } -func (*DsliteSetB4Addr) GetCrcString() string { return "1e955f8d" } -func (*DsliteSetB4Addr) GetMessageType() api.MessageType { return api.RequestMessage } - -// DsliteSetB4AddrReply represents VPP binary API message 'dslite_set_b4_addr_reply'. -type DsliteSetB4AddrReply struct { - Retval int32 -} - -func (m *DsliteSetB4AddrReply) Reset() { *m = DsliteSetB4AddrReply{} } -func (*DsliteSetB4AddrReply) GetMessageName() string { return "dslite_set_b4_addr_reply" } -func (*DsliteSetB4AddrReply) GetCrcString() string { return "e8d4e804" } -func (*DsliteSetB4AddrReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44AddDelAddressRange represents VPP binary API message 'nat44_add_del_address_range'. -type Nat44AddDelAddressRange struct { - FirstIPAddress IP4Address - LastIPAddress IP4Address - VrfID uint32 - IsAdd bool - Flags NatConfigFlags -} - -func (m *Nat44AddDelAddressRange) Reset() { *m = Nat44AddDelAddressRange{} } -func (*Nat44AddDelAddressRange) GetMessageName() string { return "nat44_add_del_address_range" } -func (*Nat44AddDelAddressRange) GetCrcString() string { return "d4c7568c" } -func (*Nat44AddDelAddressRange) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44AddDelAddressRangeReply represents VPP binary API message 'nat44_add_del_address_range_reply'. -type Nat44AddDelAddressRangeReply struct { - Retval int32 -} - -func (m *Nat44AddDelAddressRangeReply) Reset() { *m = Nat44AddDelAddressRangeReply{} } -func (*Nat44AddDelAddressRangeReply) GetMessageName() string { - return "nat44_add_del_address_range_reply" -} -func (*Nat44AddDelAddressRangeReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44AddDelAddressRangeReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44AddDelIdentityMapping represents VPP binary API message 'nat44_add_del_identity_mapping'. -type Nat44AddDelIdentityMapping struct { - IsAdd bool - Flags NatConfigFlags - IPAddress IP4Address - Protocol uint8 - Port uint16 - SwIfIndex InterfaceIndex - VrfID uint32 - Tag string `struc:"[64]byte"` -} - -func (m *Nat44AddDelIdentityMapping) Reset() { *m = Nat44AddDelIdentityMapping{} } -func (*Nat44AddDelIdentityMapping) GetMessageName() string { return "nat44_add_del_identity_mapping" } -func (*Nat44AddDelIdentityMapping) GetCrcString() string { return "8e12743f" } -func (*Nat44AddDelIdentityMapping) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44AddDelIdentityMappingReply represents VPP binary API message 'nat44_add_del_identity_mapping_reply'. -type Nat44AddDelIdentityMappingReply struct { - Retval int32 -} - -func (m *Nat44AddDelIdentityMappingReply) Reset() { *m = Nat44AddDelIdentityMappingReply{} } -func (*Nat44AddDelIdentityMappingReply) GetMessageName() string { - return "nat44_add_del_identity_mapping_reply" -} -func (*Nat44AddDelIdentityMappingReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44AddDelIdentityMappingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44AddDelInterfaceAddr represents VPP binary API message 'nat44_add_del_interface_addr'. -type Nat44AddDelInterfaceAddr struct { - IsAdd bool - SwIfIndex InterfaceIndex - Flags NatConfigFlags -} - -func (m *Nat44AddDelInterfaceAddr) Reset() { *m = Nat44AddDelInterfaceAddr{} } -func (*Nat44AddDelInterfaceAddr) GetMessageName() string { return "nat44_add_del_interface_addr" } -func (*Nat44AddDelInterfaceAddr) GetCrcString() string { return "fc835325" } -func (*Nat44AddDelInterfaceAddr) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44AddDelInterfaceAddrReply represents VPP binary API message 'nat44_add_del_interface_addr_reply'. -type Nat44AddDelInterfaceAddrReply struct { - Retval int32 -} - -func (m *Nat44AddDelInterfaceAddrReply) Reset() { *m = Nat44AddDelInterfaceAddrReply{} } -func (*Nat44AddDelInterfaceAddrReply) GetMessageName() string { - return "nat44_add_del_interface_addr_reply" -} -func (*Nat44AddDelInterfaceAddrReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44AddDelInterfaceAddrReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44AddDelLbStaticMapping represents VPP binary API message 'nat44_add_del_lb_static_mapping'. -type Nat44AddDelLbStaticMapping struct { - IsAdd bool - Flags NatConfigFlags - ExternalAddr IP4Address - ExternalPort uint16 - Protocol uint8 - Affinity uint32 - Tag string `struc:"[64]byte"` - LocalNum uint32 `struc:"sizeof=Locals"` - Locals []Nat44LbAddrPort -} - -func (m *Nat44AddDelLbStaticMapping) Reset() { *m = Nat44AddDelLbStaticMapping{} } -func (*Nat44AddDelLbStaticMapping) GetMessageName() string { return "nat44_add_del_lb_static_mapping" } -func (*Nat44AddDelLbStaticMapping) GetCrcString() string { return "53b24611" } -func (*Nat44AddDelLbStaticMapping) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44AddDelLbStaticMappingReply represents VPP binary API message 'nat44_add_del_lb_static_mapping_reply'. -type Nat44AddDelLbStaticMappingReply struct { - Retval int32 -} - -func (m *Nat44AddDelLbStaticMappingReply) Reset() { *m = Nat44AddDelLbStaticMappingReply{} } -func (*Nat44AddDelLbStaticMappingReply) GetMessageName() string { - return "nat44_add_del_lb_static_mapping_reply" -} -func (*Nat44AddDelLbStaticMappingReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44AddDelLbStaticMappingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44AddDelStaticMapping represents VPP binary API message 'nat44_add_del_static_mapping'. -type Nat44AddDelStaticMapping struct { - IsAdd bool - Flags NatConfigFlags - LocalIPAddress IP4Address - ExternalIPAddress IP4Address - Protocol uint8 - LocalPort uint16 - ExternalPort uint16 - ExternalSwIfIndex InterfaceIndex - VrfID uint32 - Tag string `struc:"[64]byte"` -} - -func (m *Nat44AddDelStaticMapping) Reset() { *m = Nat44AddDelStaticMapping{} } -func (*Nat44AddDelStaticMapping) GetMessageName() string { return "nat44_add_del_static_mapping" } -func (*Nat44AddDelStaticMapping) GetCrcString() string { return "e165e83b" } -func (*Nat44AddDelStaticMapping) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44AddDelStaticMappingReply represents VPP binary API message 'nat44_add_del_static_mapping_reply'. -type Nat44AddDelStaticMappingReply struct { - Retval int32 -} - -func (m *Nat44AddDelStaticMappingReply) Reset() { *m = Nat44AddDelStaticMappingReply{} } -func (*Nat44AddDelStaticMappingReply) GetMessageName() string { - return "nat44_add_del_static_mapping_reply" -} -func (*Nat44AddDelStaticMappingReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44AddDelStaticMappingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44AddressDetails represents VPP binary API message 'nat44_address_details'. -type Nat44AddressDetails struct { - IPAddress IP4Address - Flags NatConfigFlags - VrfID uint32 -} - -func (m *Nat44AddressDetails) Reset() { *m = Nat44AddressDetails{} } -func (*Nat44AddressDetails) GetMessageName() string { return "nat44_address_details" } -func (*Nat44AddressDetails) GetCrcString() string { return "45410ac4" } -func (*Nat44AddressDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44AddressDump represents VPP binary API message 'nat44_address_dump'. -type Nat44AddressDump struct{} - -func (m *Nat44AddressDump) Reset() { *m = Nat44AddressDump{} } -func (*Nat44AddressDump) GetMessageName() string { return "nat44_address_dump" } -func (*Nat44AddressDump) GetCrcString() string { return "51077d14" } -func (*Nat44AddressDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44DelSession represents VPP binary API message 'nat44_del_session'. -type Nat44DelSession struct { - Address IP4Address - Protocol uint8 - Port uint16 - VrfID uint32 - Flags NatConfigFlags - ExtHostAddress IP4Address - ExtHostPort uint16 -} - -func (m *Nat44DelSession) Reset() { *m = Nat44DelSession{} } -func (*Nat44DelSession) GetMessageName() string { return "nat44_del_session" } -func (*Nat44DelSession) GetCrcString() string { return "4c49c387" } -func (*Nat44DelSession) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44DelSessionReply represents VPP binary API message 'nat44_del_session_reply'. -type Nat44DelSessionReply struct { - Retval int32 -} - -func (m *Nat44DelSessionReply) Reset() { *m = Nat44DelSessionReply{} } -func (*Nat44DelSessionReply) GetMessageName() string { return "nat44_del_session_reply" } -func (*Nat44DelSessionReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44DelSessionReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44ForwardingEnableDisable represents VPP binary API message 'nat44_forwarding_enable_disable'. -type Nat44ForwardingEnableDisable struct { - Enable bool -} - -func (m *Nat44ForwardingEnableDisable) Reset() { *m = Nat44ForwardingEnableDisable{} } -func (*Nat44ForwardingEnableDisable) GetMessageName() string { - return "nat44_forwarding_enable_disable" -} -func (*Nat44ForwardingEnableDisable) GetCrcString() string { return "b3e225d2" } -func (*Nat44ForwardingEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44ForwardingEnableDisableReply represents VPP binary API message 'nat44_forwarding_enable_disable_reply'. -type Nat44ForwardingEnableDisableReply struct { - Retval int32 -} - -func (m *Nat44ForwardingEnableDisableReply) Reset() { *m = Nat44ForwardingEnableDisableReply{} } -func (*Nat44ForwardingEnableDisableReply) GetMessageName() string { - return "nat44_forwarding_enable_disable_reply" -} -func (*Nat44ForwardingEnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44ForwardingEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44ForwardingIsEnabled represents VPP binary API message 'nat44_forwarding_is_enabled'. -type Nat44ForwardingIsEnabled struct{} - -func (m *Nat44ForwardingIsEnabled) Reset() { *m = Nat44ForwardingIsEnabled{} } -func (*Nat44ForwardingIsEnabled) GetMessageName() string { return "nat44_forwarding_is_enabled" } -func (*Nat44ForwardingIsEnabled) GetCrcString() string { return "51077d14" } -func (*Nat44ForwardingIsEnabled) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44ForwardingIsEnabledReply represents VPP binary API message 'nat44_forwarding_is_enabled_reply'. -type Nat44ForwardingIsEnabledReply struct { - Enabled bool -} - -func (m *Nat44ForwardingIsEnabledReply) Reset() { *m = Nat44ForwardingIsEnabledReply{} } -func (*Nat44ForwardingIsEnabledReply) GetMessageName() string { - return "nat44_forwarding_is_enabled_reply" -} -func (*Nat44ForwardingIsEnabledReply) GetCrcString() string { return "46924a06" } -func (*Nat44ForwardingIsEnabledReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44IdentityMappingDetails represents VPP binary API message 'nat44_identity_mapping_details'. -type Nat44IdentityMappingDetails struct { - Flags NatConfigFlags - IPAddress IP4Address - Protocol uint8 - Port uint16 - SwIfIndex InterfaceIndex - VrfID uint32 - Tag string `struc:"[64]byte"` -} - -func (m *Nat44IdentityMappingDetails) Reset() { *m = Nat44IdentityMappingDetails{} } -func (*Nat44IdentityMappingDetails) GetMessageName() string { return "nat44_identity_mapping_details" } -func (*Nat44IdentityMappingDetails) GetCrcString() string { return "36d21351" } -func (*Nat44IdentityMappingDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44IdentityMappingDump represents VPP binary API message 'nat44_identity_mapping_dump'. -type Nat44IdentityMappingDump struct{} - -func (m *Nat44IdentityMappingDump) Reset() { *m = Nat44IdentityMappingDump{} } -func (*Nat44IdentityMappingDump) GetMessageName() string { return "nat44_identity_mapping_dump" } -func (*Nat44IdentityMappingDump) GetCrcString() string { return "51077d14" } -func (*Nat44IdentityMappingDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44InterfaceAddDelFeature represents VPP binary API message 'nat44_interface_add_del_feature'. -type Nat44InterfaceAddDelFeature struct { - IsAdd bool - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat44InterfaceAddDelFeature) Reset() { *m = Nat44InterfaceAddDelFeature{} } -func (*Nat44InterfaceAddDelFeature) GetMessageName() string { return "nat44_interface_add_del_feature" } -func (*Nat44InterfaceAddDelFeature) GetCrcString() string { return "f3699b83" } -func (*Nat44InterfaceAddDelFeature) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44InterfaceAddDelFeatureReply represents VPP binary API message 'nat44_interface_add_del_feature_reply'. -type Nat44InterfaceAddDelFeatureReply struct { - Retval int32 -} - -func (m *Nat44InterfaceAddDelFeatureReply) Reset() { *m = Nat44InterfaceAddDelFeatureReply{} } -func (*Nat44InterfaceAddDelFeatureReply) GetMessageName() string { - return "nat44_interface_add_del_feature_reply" -} -func (*Nat44InterfaceAddDelFeatureReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44InterfaceAddDelFeatureReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44InterfaceAddDelOutputFeature represents VPP binary API message 'nat44_interface_add_del_output_feature'. -type Nat44InterfaceAddDelOutputFeature struct { - IsAdd bool - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat44InterfaceAddDelOutputFeature) Reset() { *m = Nat44InterfaceAddDelOutputFeature{} } -func (*Nat44InterfaceAddDelOutputFeature) GetMessageName() string { - return "nat44_interface_add_del_output_feature" -} -func (*Nat44InterfaceAddDelOutputFeature) GetCrcString() string { return "f3699b83" } -func (*Nat44InterfaceAddDelOutputFeature) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44InterfaceAddDelOutputFeatureReply represents VPP binary API message 'nat44_interface_add_del_output_feature_reply'. -type Nat44InterfaceAddDelOutputFeatureReply struct { - Retval int32 -} - -func (m *Nat44InterfaceAddDelOutputFeatureReply) Reset() { - *m = Nat44InterfaceAddDelOutputFeatureReply{} -} -func (*Nat44InterfaceAddDelOutputFeatureReply) GetMessageName() string { - return "nat44_interface_add_del_output_feature_reply" -} -func (*Nat44InterfaceAddDelOutputFeatureReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44InterfaceAddDelOutputFeatureReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// Nat44InterfaceAddrDetails represents VPP binary API message 'nat44_interface_addr_details'. -type Nat44InterfaceAddrDetails struct { - SwIfIndex InterfaceIndex - Flags NatConfigFlags -} - -func (m *Nat44InterfaceAddrDetails) Reset() { *m = Nat44InterfaceAddrDetails{} } -func (*Nat44InterfaceAddrDetails) GetMessageName() string { return "nat44_interface_addr_details" } -func (*Nat44InterfaceAddrDetails) GetCrcString() string { return "3e687514" } -func (*Nat44InterfaceAddrDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44InterfaceAddrDump represents VPP binary API message 'nat44_interface_addr_dump'. -type Nat44InterfaceAddrDump struct{} - -func (m *Nat44InterfaceAddrDump) Reset() { *m = Nat44InterfaceAddrDump{} } -func (*Nat44InterfaceAddrDump) GetMessageName() string { return "nat44_interface_addr_dump" } -func (*Nat44InterfaceAddrDump) GetCrcString() string { return "51077d14" } -func (*Nat44InterfaceAddrDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44InterfaceDetails represents VPP binary API message 'nat44_interface_details'. -type Nat44InterfaceDetails struct { - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat44InterfaceDetails) Reset() { *m = Nat44InterfaceDetails{} } -func (*Nat44InterfaceDetails) GetMessageName() string { return "nat44_interface_details" } -func (*Nat44InterfaceDetails) GetCrcString() string { return "5d286289" } -func (*Nat44InterfaceDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44InterfaceDump represents VPP binary API message 'nat44_interface_dump'. -type Nat44InterfaceDump struct{} - -func (m *Nat44InterfaceDump) Reset() { *m = Nat44InterfaceDump{} } -func (*Nat44InterfaceDump) GetMessageName() string { return "nat44_interface_dump" } -func (*Nat44InterfaceDump) GetCrcString() string { return "51077d14" } -func (*Nat44InterfaceDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44InterfaceOutputFeatureDetails represents VPP binary API message 'nat44_interface_output_feature_details'. -type Nat44InterfaceOutputFeatureDetails struct { - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat44InterfaceOutputFeatureDetails) Reset() { *m = Nat44InterfaceOutputFeatureDetails{} } -func (*Nat44InterfaceOutputFeatureDetails) GetMessageName() string { - return "nat44_interface_output_feature_details" -} -func (*Nat44InterfaceOutputFeatureDetails) GetCrcString() string { return "5d286289" } -func (*Nat44InterfaceOutputFeatureDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44InterfaceOutputFeatureDump represents VPP binary API message 'nat44_interface_output_feature_dump'. -type Nat44InterfaceOutputFeatureDump struct{} - -func (m *Nat44InterfaceOutputFeatureDump) Reset() { *m = Nat44InterfaceOutputFeatureDump{} } -func (*Nat44InterfaceOutputFeatureDump) GetMessageName() string { - return "nat44_interface_output_feature_dump" -} -func (*Nat44InterfaceOutputFeatureDump) GetCrcString() string { return "51077d14" } -func (*Nat44InterfaceOutputFeatureDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44LbStaticMappingAddDelLocal represents VPP binary API message 'nat44_lb_static_mapping_add_del_local'. -type Nat44LbStaticMappingAddDelLocal struct { - IsAdd bool - ExternalAddr IP4Address - ExternalPort uint16 - Protocol uint8 - Local Nat44LbAddrPort -} - -func (m *Nat44LbStaticMappingAddDelLocal) Reset() { *m = Nat44LbStaticMappingAddDelLocal{} } -func (*Nat44LbStaticMappingAddDelLocal) GetMessageName() string { - return "nat44_lb_static_mapping_add_del_local" -} -func (*Nat44LbStaticMappingAddDelLocal) GetCrcString() string { return "2910a151" } -func (*Nat44LbStaticMappingAddDelLocal) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44LbStaticMappingAddDelLocalReply represents VPP binary API message 'nat44_lb_static_mapping_add_del_local_reply'. -type Nat44LbStaticMappingAddDelLocalReply struct { - Retval int32 -} - -func (m *Nat44LbStaticMappingAddDelLocalReply) Reset() { *m = Nat44LbStaticMappingAddDelLocalReply{} } -func (*Nat44LbStaticMappingAddDelLocalReply) GetMessageName() string { - return "nat44_lb_static_mapping_add_del_local_reply" -} -func (*Nat44LbStaticMappingAddDelLocalReply) GetCrcString() string { return "e8d4e804" } -func (*Nat44LbStaticMappingAddDelLocalReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} - -// Nat44LbStaticMappingDetails represents VPP binary API message 'nat44_lb_static_mapping_details'. -type Nat44LbStaticMappingDetails struct { - ExternalAddr IP4Address - ExternalPort uint16 - Protocol uint8 - Flags NatConfigFlags - Affinity uint32 - Tag string `struc:"[64]byte"` - LocalNum uint32 `struc:"sizeof=Locals"` - Locals []Nat44LbAddrPort -} - -func (m *Nat44LbStaticMappingDetails) Reset() { *m = Nat44LbStaticMappingDetails{} } -func (*Nat44LbStaticMappingDetails) GetMessageName() string { return "nat44_lb_static_mapping_details" } -func (*Nat44LbStaticMappingDetails) GetCrcString() string { return "2267b9e8" } -func (*Nat44LbStaticMappingDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44LbStaticMappingDump represents VPP binary API message 'nat44_lb_static_mapping_dump'. -type Nat44LbStaticMappingDump struct{} - -func (m *Nat44LbStaticMappingDump) Reset() { *m = Nat44LbStaticMappingDump{} } -func (*Nat44LbStaticMappingDump) GetMessageName() string { return "nat44_lb_static_mapping_dump" } -func (*Nat44LbStaticMappingDump) GetCrcString() string { return "51077d14" } -func (*Nat44LbStaticMappingDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44StaticMappingDetails represents VPP binary API message 'nat44_static_mapping_details'. -type Nat44StaticMappingDetails struct { - Flags NatConfigFlags - LocalIPAddress IP4Address - ExternalIPAddress IP4Address - Protocol uint8 - LocalPort uint16 - ExternalPort uint16 - ExternalSwIfIndex InterfaceIndex - VrfID uint32 - Tag string `struc:"[64]byte"` -} - -func (m *Nat44StaticMappingDetails) Reset() { *m = Nat44StaticMappingDetails{} } -func (*Nat44StaticMappingDetails) GetMessageName() string { return "nat44_static_mapping_details" } -func (*Nat44StaticMappingDetails) GetCrcString() string { return "1a433ef7" } -func (*Nat44StaticMappingDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44StaticMappingDump represents VPP binary API message 'nat44_static_mapping_dump'. -type Nat44StaticMappingDump struct{} - -func (m *Nat44StaticMappingDump) Reset() { *m = Nat44StaticMappingDump{} } -func (*Nat44StaticMappingDump) GetMessageName() string { return "nat44_static_mapping_dump" } -func (*Nat44StaticMappingDump) GetCrcString() string { return "51077d14" } -func (*Nat44StaticMappingDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44UserDetails represents VPP binary API message 'nat44_user_details'. -type Nat44UserDetails struct { - VrfID uint32 - IPAddress IP4Address - Nsessions uint32 - Nstaticsessions uint32 -} - -func (m *Nat44UserDetails) Reset() { *m = Nat44UserDetails{} } -func (*Nat44UserDetails) GetMessageName() string { return "nat44_user_details" } -func (*Nat44UserDetails) GetCrcString() string { return "355896c2" } -func (*Nat44UserDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44UserDump represents VPP binary API message 'nat44_user_dump'. -type Nat44UserDump struct{} - -func (m *Nat44UserDump) Reset() { *m = Nat44UserDump{} } -func (*Nat44UserDump) GetMessageName() string { return "nat44_user_dump" } -func (*Nat44UserDump) GetCrcString() string { return "51077d14" } -func (*Nat44UserDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat44UserSessionDetails represents VPP binary API message 'nat44_user_session_details'. -type Nat44UserSessionDetails struct { - OutsideIPAddress IP4Address - OutsidePort uint16 - InsideIPAddress IP4Address - InsidePort uint16 - Protocol uint16 - Flags NatConfigFlags - LastHeard uint64 - TotalBytes uint64 - TotalPkts uint32 - ExtHostAddress IP4Address - ExtHostPort uint16 - ExtHostNatAddress IP4Address - ExtHostNatPort uint16 -} - -func (m *Nat44UserSessionDetails) Reset() { *m = Nat44UserSessionDetails{} } -func (*Nat44UserSessionDetails) GetMessageName() string { return "nat44_user_session_details" } -func (*Nat44UserSessionDetails) GetCrcString() string { return "1965fd69" } -func (*Nat44UserSessionDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat44UserSessionDump represents VPP binary API message 'nat44_user_session_dump'. -type Nat44UserSessionDump struct { - IPAddress IP4Address - VrfID uint32 -} - -func (m *Nat44UserSessionDump) Reset() { *m = Nat44UserSessionDump{} } -func (*Nat44UserSessionDump) GetMessageName() string { return "nat44_user_session_dump" } -func (*Nat44UserSessionDump) GetCrcString() string { return "e1899c98" } -func (*Nat44UserSessionDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64AddDelInterface represents VPP binary API message 'nat64_add_del_interface'. -type Nat64AddDelInterface struct { - IsAdd bool - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat64AddDelInterface) Reset() { *m = Nat64AddDelInterface{} } -func (*Nat64AddDelInterface) GetMessageName() string { return "nat64_add_del_interface" } -func (*Nat64AddDelInterface) GetCrcString() string { return "f3699b83" } -func (*Nat64AddDelInterface) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64AddDelInterfaceAddr represents VPP binary API message 'nat64_add_del_interface_addr'. -type Nat64AddDelInterfaceAddr struct { - IsAdd bool - SwIfIndex InterfaceIndex -} - -func (m *Nat64AddDelInterfaceAddr) Reset() { *m = Nat64AddDelInterfaceAddr{} } -func (*Nat64AddDelInterfaceAddr) GetMessageName() string { return "nat64_add_del_interface_addr" } -func (*Nat64AddDelInterfaceAddr) GetCrcString() string { return "47d6e753" } -func (*Nat64AddDelInterfaceAddr) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64AddDelInterfaceAddrReply represents VPP binary API message 'nat64_add_del_interface_addr_reply'. -type Nat64AddDelInterfaceAddrReply struct { - Retval int32 -} - -func (m *Nat64AddDelInterfaceAddrReply) Reset() { *m = Nat64AddDelInterfaceAddrReply{} } -func (*Nat64AddDelInterfaceAddrReply) GetMessageName() string { - return "nat64_add_del_interface_addr_reply" -} -func (*Nat64AddDelInterfaceAddrReply) GetCrcString() string { return "e8d4e804" } -func (*Nat64AddDelInterfaceAddrReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64AddDelInterfaceReply represents VPP binary API message 'nat64_add_del_interface_reply'. -type Nat64AddDelInterfaceReply struct { - Retval int32 -} - -func (m *Nat64AddDelInterfaceReply) Reset() { *m = Nat64AddDelInterfaceReply{} } -func (*Nat64AddDelInterfaceReply) GetMessageName() string { return "nat64_add_del_interface_reply" } -func (*Nat64AddDelInterfaceReply) GetCrcString() string { return "e8d4e804" } -func (*Nat64AddDelInterfaceReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64AddDelPoolAddrRange represents VPP binary API message 'nat64_add_del_pool_addr_range'. -type Nat64AddDelPoolAddrRange struct { - StartAddr IP4Address - EndAddr IP4Address - VrfID uint32 - IsAdd bool -} - -func (m *Nat64AddDelPoolAddrRange) Reset() { *m = Nat64AddDelPoolAddrRange{} } -func (*Nat64AddDelPoolAddrRange) GetMessageName() string { return "nat64_add_del_pool_addr_range" } -func (*Nat64AddDelPoolAddrRange) GetCrcString() string { return "21234ef3" } -func (*Nat64AddDelPoolAddrRange) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64AddDelPoolAddrRangeReply represents VPP binary API message 'nat64_add_del_pool_addr_range_reply'. -type Nat64AddDelPoolAddrRangeReply struct { - Retval int32 -} - -func (m *Nat64AddDelPoolAddrRangeReply) Reset() { *m = Nat64AddDelPoolAddrRangeReply{} } -func (*Nat64AddDelPoolAddrRangeReply) GetMessageName() string { - return "nat64_add_del_pool_addr_range_reply" -} -func (*Nat64AddDelPoolAddrRangeReply) GetCrcString() string { return "e8d4e804" } -func (*Nat64AddDelPoolAddrRangeReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64AddDelPrefix represents VPP binary API message 'nat64_add_del_prefix'. -type Nat64AddDelPrefix struct { - Prefix IP6Prefix - VrfID uint32 - IsAdd bool -} - -func (m *Nat64AddDelPrefix) Reset() { *m = Nat64AddDelPrefix{} } -func (*Nat64AddDelPrefix) GetMessageName() string { return "nat64_add_del_prefix" } -func (*Nat64AddDelPrefix) GetCrcString() string { return "727b2f4c" } -func (*Nat64AddDelPrefix) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64AddDelPrefixReply represents VPP binary API message 'nat64_add_del_prefix_reply'. -type Nat64AddDelPrefixReply struct { - Retval int32 -} - -func (m *Nat64AddDelPrefixReply) Reset() { *m = Nat64AddDelPrefixReply{} } -func (*Nat64AddDelPrefixReply) GetMessageName() string { return "nat64_add_del_prefix_reply" } -func (*Nat64AddDelPrefixReply) GetCrcString() string { return "e8d4e804" } -func (*Nat64AddDelPrefixReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64AddDelStaticBib represents VPP binary API message 'nat64_add_del_static_bib'. -type Nat64AddDelStaticBib struct { - IAddr IP6Address - OAddr IP4Address - IPort uint16 - OPort uint16 - VrfID uint32 - Proto uint8 - IsAdd bool -} - -func (m *Nat64AddDelStaticBib) Reset() { *m = Nat64AddDelStaticBib{} } -func (*Nat64AddDelStaticBib) GetMessageName() string { return "nat64_add_del_static_bib" } -func (*Nat64AddDelStaticBib) GetCrcString() string { return "90fae58a" } -func (*Nat64AddDelStaticBib) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64AddDelStaticBibReply represents VPP binary API message 'nat64_add_del_static_bib_reply'. -type Nat64AddDelStaticBibReply struct { - Retval int32 -} - -func (m *Nat64AddDelStaticBibReply) Reset() { *m = Nat64AddDelStaticBibReply{} } -func (*Nat64AddDelStaticBibReply) GetMessageName() string { return "nat64_add_del_static_bib_reply" } -func (*Nat64AddDelStaticBibReply) GetCrcString() string { return "e8d4e804" } -func (*Nat64AddDelStaticBibReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64BibDetails represents VPP binary API message 'nat64_bib_details'. -type Nat64BibDetails struct { - IAddr IP6Address - OAddr IP4Address - IPort uint16 - OPort uint16 - VrfID uint32 - Proto uint8 - Flags NatConfigFlags - SesNum uint32 -} - -func (m *Nat64BibDetails) Reset() { *m = Nat64BibDetails{} } -func (*Nat64BibDetails) GetMessageName() string { return "nat64_bib_details" } -func (*Nat64BibDetails) GetCrcString() string { return "62c8541d" } -func (*Nat64BibDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64BibDump represents VPP binary API message 'nat64_bib_dump'. -type Nat64BibDump struct { - Proto uint8 -} - -func (m *Nat64BibDump) Reset() { *m = Nat64BibDump{} } -func (*Nat64BibDump) GetMessageName() string { return "nat64_bib_dump" } -func (*Nat64BibDump) GetCrcString() string { return "cfcb6b75" } -func (*Nat64BibDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64InterfaceDetails represents VPP binary API message 'nat64_interface_details'. -type Nat64InterfaceDetails struct { - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat64InterfaceDetails) Reset() { *m = Nat64InterfaceDetails{} } -func (*Nat64InterfaceDetails) GetMessageName() string { return "nat64_interface_details" } -func (*Nat64InterfaceDetails) GetCrcString() string { return "5d286289" } -func (*Nat64InterfaceDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64InterfaceDump represents VPP binary API message 'nat64_interface_dump'. -type Nat64InterfaceDump struct{} - -func (m *Nat64InterfaceDump) Reset() { *m = Nat64InterfaceDump{} } -func (*Nat64InterfaceDump) GetMessageName() string { return "nat64_interface_dump" } -func (*Nat64InterfaceDump) GetCrcString() string { return "51077d14" } -func (*Nat64InterfaceDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64PoolAddrDetails represents VPP binary API message 'nat64_pool_addr_details'. -type Nat64PoolAddrDetails struct { - Address IP4Address - VrfID uint32 -} - -func (m *Nat64PoolAddrDetails) Reset() { *m = Nat64PoolAddrDetails{} } -func (*Nat64PoolAddrDetails) GetMessageName() string { return "nat64_pool_addr_details" } -func (*Nat64PoolAddrDetails) GetCrcString() string { return "9bb99cdb" } -func (*Nat64PoolAddrDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64PoolAddrDump represents VPP binary API message 'nat64_pool_addr_dump'. -type Nat64PoolAddrDump struct{} - -func (m *Nat64PoolAddrDump) Reset() { *m = Nat64PoolAddrDump{} } -func (*Nat64PoolAddrDump) GetMessageName() string { return "nat64_pool_addr_dump" } -func (*Nat64PoolAddrDump) GetCrcString() string { return "51077d14" } -func (*Nat64PoolAddrDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64PrefixDetails represents VPP binary API message 'nat64_prefix_details'. -type Nat64PrefixDetails struct { - Prefix IP6Prefix - VrfID uint32 -} - -func (m *Nat64PrefixDetails) Reset() { *m = Nat64PrefixDetails{} } -func (*Nat64PrefixDetails) GetMessageName() string { return "nat64_prefix_details" } -func (*Nat64PrefixDetails) GetCrcString() string { return "20568de3" } -func (*Nat64PrefixDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64PrefixDump represents VPP binary API message 'nat64_prefix_dump'. -type Nat64PrefixDump struct{} - -func (m *Nat64PrefixDump) Reset() { *m = Nat64PrefixDump{} } -func (*Nat64PrefixDump) GetMessageName() string { return "nat64_prefix_dump" } -func (*Nat64PrefixDump) GetCrcString() string { return "51077d14" } -func (*Nat64PrefixDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat64StDetails represents VPP binary API message 'nat64_st_details'. -type Nat64StDetails struct { - IlAddr IP6Address - OlAddr IP4Address - IlPort uint16 - OlPort uint16 - IrAddr IP6Address - OrAddr IP4Address - RPort uint16 - VrfID uint32 - Proto uint8 -} - -func (m *Nat64StDetails) Reset() { *m = Nat64StDetails{} } -func (*Nat64StDetails) GetMessageName() string { return "nat64_st_details" } -func (*Nat64StDetails) GetCrcString() string { return "c770d620" } -func (*Nat64StDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat64StDump represents VPP binary API message 'nat64_st_dump'. -type Nat64StDump struct { - Proto uint8 -} - -func (m *Nat64StDump) Reset() { *m = Nat64StDump{} } -func (*Nat64StDump) GetMessageName() string { return "nat64_st_dump" } -func (*Nat64StDump) GetCrcString() string { return "cfcb6b75" } -func (*Nat64StDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat66AddDelInterface represents VPP binary API message 'nat66_add_del_interface'. -type Nat66AddDelInterface struct { - IsAdd bool - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat66AddDelInterface) Reset() { *m = Nat66AddDelInterface{} } -func (*Nat66AddDelInterface) GetMessageName() string { return "nat66_add_del_interface" } -func (*Nat66AddDelInterface) GetCrcString() string { return "f3699b83" } -func (*Nat66AddDelInterface) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat66AddDelInterfaceReply represents VPP binary API message 'nat66_add_del_interface_reply'. -type Nat66AddDelInterfaceReply struct { - Retval int32 -} - -func (m *Nat66AddDelInterfaceReply) Reset() { *m = Nat66AddDelInterfaceReply{} } -func (*Nat66AddDelInterfaceReply) GetMessageName() string { return "nat66_add_del_interface_reply" } -func (*Nat66AddDelInterfaceReply) GetCrcString() string { return "e8d4e804" } -func (*Nat66AddDelInterfaceReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat66AddDelStaticMapping represents VPP binary API message 'nat66_add_del_static_mapping'. -type Nat66AddDelStaticMapping struct { - IsAdd bool - LocalIPAddress IP6Address - ExternalIPAddress IP6Address - VrfID uint32 -} - -func (m *Nat66AddDelStaticMapping) Reset() { *m = Nat66AddDelStaticMapping{} } -func (*Nat66AddDelStaticMapping) GetMessageName() string { return "nat66_add_del_static_mapping" } -func (*Nat66AddDelStaticMapping) GetCrcString() string { return "fb64e50b" } -func (*Nat66AddDelStaticMapping) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat66AddDelStaticMappingReply represents VPP binary API message 'nat66_add_del_static_mapping_reply'. -type Nat66AddDelStaticMappingReply struct { - Retval int32 -} - -func (m *Nat66AddDelStaticMappingReply) Reset() { *m = Nat66AddDelStaticMappingReply{} } -func (*Nat66AddDelStaticMappingReply) GetMessageName() string { - return "nat66_add_del_static_mapping_reply" -} -func (*Nat66AddDelStaticMappingReply) GetCrcString() string { return "e8d4e804" } -func (*Nat66AddDelStaticMappingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat66InterfaceDetails represents VPP binary API message 'nat66_interface_details'. -type Nat66InterfaceDetails struct { - Flags NatConfigFlags - SwIfIndex InterfaceIndex -} - -func (m *Nat66InterfaceDetails) Reset() { *m = Nat66InterfaceDetails{} } -func (*Nat66InterfaceDetails) GetMessageName() string { return "nat66_interface_details" } -func (*Nat66InterfaceDetails) GetCrcString() string { return "5d286289" } -func (*Nat66InterfaceDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat66InterfaceDump represents VPP binary API message 'nat66_interface_dump'. -type Nat66InterfaceDump struct{} - -func (m *Nat66InterfaceDump) Reset() { *m = Nat66InterfaceDump{} } -func (*Nat66InterfaceDump) GetMessageName() string { return "nat66_interface_dump" } -func (*Nat66InterfaceDump) GetCrcString() string { return "51077d14" } -func (*Nat66InterfaceDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// Nat66StaticMappingDetails represents VPP binary API message 'nat66_static_mapping_details'. -type Nat66StaticMappingDetails struct { - LocalIPAddress IP6Address - ExternalIPAddress IP6Address - VrfID uint32 - TotalBytes uint64 - TotalPkts uint64 -} - -func (m *Nat66StaticMappingDetails) Reset() { *m = Nat66StaticMappingDetails{} } -func (*Nat66StaticMappingDetails) GetMessageName() string { return "nat66_static_mapping_details" } -func (*Nat66StaticMappingDetails) GetCrcString() string { return "5c568448" } -func (*Nat66StaticMappingDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Nat66StaticMappingDump represents VPP binary API message 'nat66_static_mapping_dump'. -type Nat66StaticMappingDump struct{} - -func (m *Nat66StaticMappingDump) Reset() { *m = Nat66StaticMappingDump{} } -func (*Nat66StaticMappingDump) GetMessageName() string { return "nat66_static_mapping_dump" } -func (*Nat66StaticMappingDump) GetCrcString() string { return "51077d14" } -func (*Nat66StaticMappingDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatControlPing represents VPP binary API message 'nat_control_ping'. -type NatControlPing struct{} - -func (m *NatControlPing) Reset() { *m = NatControlPing{} } -func (*NatControlPing) GetMessageName() string { return "nat_control_ping" } -func (*NatControlPing) GetCrcString() string { return "51077d14" } -func (*NatControlPing) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatControlPingReply represents VPP binary API message 'nat_control_ping_reply'. -type NatControlPingReply struct { - Retval int32 - ClientIndex uint32 - VpePID uint32 -} - -func (m *NatControlPingReply) Reset() { *m = NatControlPingReply{} } -func (*NatControlPingReply) GetMessageName() string { return "nat_control_ping_reply" } -func (*NatControlPingReply) GetCrcString() string { return "f6b0b8ca" } -func (*NatControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetAddDelMap represents VPP binary API message 'nat_det_add_del_map'. -type NatDetAddDelMap struct { - IsAdd bool - InAddr IP4Address - InPlen uint8 - OutAddr IP4Address - OutPlen uint8 -} - -func (m *NatDetAddDelMap) Reset() { *m = NatDetAddDelMap{} } -func (*NatDetAddDelMap) GetMessageName() string { return "nat_det_add_del_map" } -func (*NatDetAddDelMap) GetCrcString() string { return "112fde05" } -func (*NatDetAddDelMap) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatDetAddDelMapReply represents VPP binary API message 'nat_det_add_del_map_reply'. -type NatDetAddDelMapReply struct { - Retval int32 -} - -func (m *NatDetAddDelMapReply) Reset() { *m = NatDetAddDelMapReply{} } -func (*NatDetAddDelMapReply) GetMessageName() string { return "nat_det_add_del_map_reply" } -func (*NatDetAddDelMapReply) GetCrcString() string { return "e8d4e804" } -func (*NatDetAddDelMapReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetCloseSessionIn represents VPP binary API message 'nat_det_close_session_in'. -type NatDetCloseSessionIn struct { - InAddr IP4Address - InPort uint16 - ExtAddr IP4Address - ExtPort uint16 -} - -func (m *NatDetCloseSessionIn) Reset() { *m = NatDetCloseSessionIn{} } -func (*NatDetCloseSessionIn) GetMessageName() string { return "nat_det_close_session_in" } -func (*NatDetCloseSessionIn) GetCrcString() string { return "0a10ef64" } -func (*NatDetCloseSessionIn) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatDetCloseSessionInReply represents VPP binary API message 'nat_det_close_session_in_reply'. -type NatDetCloseSessionInReply struct { - Retval int32 -} - -func (m *NatDetCloseSessionInReply) Reset() { *m = NatDetCloseSessionInReply{} } -func (*NatDetCloseSessionInReply) GetMessageName() string { return "nat_det_close_session_in_reply" } -func (*NatDetCloseSessionInReply) GetCrcString() string { return "e8d4e804" } -func (*NatDetCloseSessionInReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetCloseSessionOut represents VPP binary API message 'nat_det_close_session_out'. -type NatDetCloseSessionOut struct { - OutAddr IP4Address - OutPort uint16 - ExtAddr IP4Address - ExtPort uint16 -} - -func (m *NatDetCloseSessionOut) Reset() { *m = NatDetCloseSessionOut{} } -func (*NatDetCloseSessionOut) GetMessageName() string { return "nat_det_close_session_out" } -func (*NatDetCloseSessionOut) GetCrcString() string { return "c1b6cbfb" } -func (*NatDetCloseSessionOut) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatDetCloseSessionOutReply represents VPP binary API message 'nat_det_close_session_out_reply'. -type NatDetCloseSessionOutReply struct { - Retval int32 -} - -func (m *NatDetCloseSessionOutReply) Reset() { *m = NatDetCloseSessionOutReply{} } -func (*NatDetCloseSessionOutReply) GetMessageName() string { return "nat_det_close_session_out_reply" } -func (*NatDetCloseSessionOutReply) GetCrcString() string { return "e8d4e804" } -func (*NatDetCloseSessionOutReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetForward represents VPP binary API message 'nat_det_forward'. -type NatDetForward struct { - InAddr IP4Address -} - -func (m *NatDetForward) Reset() { *m = NatDetForward{} } -func (*NatDetForward) GetMessageName() string { return "nat_det_forward" } -func (*NatDetForward) GetCrcString() string { return "7f8a89cd" } -func (*NatDetForward) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatDetForwardReply represents VPP binary API message 'nat_det_forward_reply'. -type NatDetForwardReply struct { - Retval int32 - OutPortLo uint16 - OutPortHi uint16 - OutAddr IP4Address -} - -func (m *NatDetForwardReply) Reset() { *m = NatDetForwardReply{} } -func (*NatDetForwardReply) GetMessageName() string { return "nat_det_forward_reply" } -func (*NatDetForwardReply) GetCrcString() string { return "a8ccbdc0" } -func (*NatDetForwardReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetMapDetails represents VPP binary API message 'nat_det_map_details'. -type NatDetMapDetails struct { - InAddr IP4Address - InPlen uint8 - OutAddr IP4Address - OutPlen uint8 - SharingRatio uint32 - PortsPerHost uint16 - SesNum uint32 -} - -func (m *NatDetMapDetails) Reset() { *m = NatDetMapDetails{} } -func (*NatDetMapDetails) GetMessageName() string { return "nat_det_map_details" } -func (*NatDetMapDetails) GetCrcString() string { return "88000ee1" } -func (*NatDetMapDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetMapDump represents VPP binary API message 'nat_det_map_dump'. -type NatDetMapDump struct{} - -func (m *NatDetMapDump) Reset() { *m = NatDetMapDump{} } -func (*NatDetMapDump) GetMessageName() string { return "nat_det_map_dump" } -func (*NatDetMapDump) GetCrcString() string { return "51077d14" } -func (*NatDetMapDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatDetReverse represents VPP binary API message 'nat_det_reverse'. -type NatDetReverse struct { - OutPort uint16 - OutAddr IP4Address -} - -func (m *NatDetReverse) Reset() { *m = NatDetReverse{} } -func (*NatDetReverse) GetMessageName() string { return "nat_det_reverse" } -func (*NatDetReverse) GetCrcString() string { return "a7573fe1" } -func (*NatDetReverse) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatDetReverseReply represents VPP binary API message 'nat_det_reverse_reply'. -type NatDetReverseReply struct { - Retval int32 - InAddr IP4Address -} - -func (m *NatDetReverseReply) Reset() { *m = NatDetReverseReply{} } -func (*NatDetReverseReply) GetMessageName() string { return "nat_det_reverse_reply" } -func (*NatDetReverseReply) GetCrcString() string { return "34066d48" } -func (*NatDetReverseReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetSessionDetails represents VPP binary API message 'nat_det_session_details'. -type NatDetSessionDetails struct { - InPort uint16 - ExtAddr IP4Address - ExtPort uint16 - OutPort uint16 - State uint8 - Expire uint32 -} - -func (m *NatDetSessionDetails) Reset() { *m = NatDetSessionDetails{} } -func (*NatDetSessionDetails) GetMessageName() string { return "nat_det_session_details" } -func (*NatDetSessionDetails) GetCrcString() string { return "27f3c171" } -func (*NatDetSessionDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatDetSessionDump represents VPP binary API message 'nat_det_session_dump'. -type NatDetSessionDump struct { - UserAddr IP4Address -} - -func (m *NatDetSessionDump) Reset() { *m = NatDetSessionDump{} } -func (*NatDetSessionDump) GetMessageName() string { return "nat_det_session_dump" } -func (*NatDetSessionDump) GetCrcString() string { return "e45a3af7" } -func (*NatDetSessionDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatGetAddrAndPortAllocAlg represents VPP binary API message 'nat_get_addr_and_port_alloc_alg'. -type NatGetAddrAndPortAllocAlg struct{} - -func (m *NatGetAddrAndPortAllocAlg) Reset() { *m = NatGetAddrAndPortAllocAlg{} } -func (*NatGetAddrAndPortAllocAlg) GetMessageName() string { return "nat_get_addr_and_port_alloc_alg" } -func (*NatGetAddrAndPortAllocAlg) GetCrcString() string { return "51077d14" } -func (*NatGetAddrAndPortAllocAlg) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatGetAddrAndPortAllocAlgReply represents VPP binary API message 'nat_get_addr_and_port_alloc_alg_reply'. -type NatGetAddrAndPortAllocAlgReply struct { - Retval int32 - Alg uint8 - PsidOffset uint8 - PsidLength uint8 - Psid uint16 - StartPort uint16 - EndPort uint16 -} - -func (m *NatGetAddrAndPortAllocAlgReply) Reset() { *m = NatGetAddrAndPortAllocAlgReply{} } -func (*NatGetAddrAndPortAllocAlgReply) GetMessageName() string { - return "nat_get_addr_and_port_alloc_alg_reply" -} -func (*NatGetAddrAndPortAllocAlgReply) GetCrcString() string { return "3607a7d0" } -func (*NatGetAddrAndPortAllocAlgReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatGetMssClamping represents VPP binary API message 'nat_get_mss_clamping'. -type NatGetMssClamping struct{} - -func (m *NatGetMssClamping) Reset() { *m = NatGetMssClamping{} } -func (*NatGetMssClamping) GetMessageName() string { return "nat_get_mss_clamping" } -func (*NatGetMssClamping) GetCrcString() string { return "51077d14" } -func (*NatGetMssClamping) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatGetMssClampingReply represents VPP binary API message 'nat_get_mss_clamping_reply'. -type NatGetMssClampingReply struct { - Retval int32 - MssValue uint16 - Enable bool -} - -func (m *NatGetMssClampingReply) Reset() { *m = NatGetMssClampingReply{} } -func (*NatGetMssClampingReply) GetMessageName() string { return "nat_get_mss_clamping_reply" } -func (*NatGetMssClampingReply) GetCrcString() string { return "1c0b2a78" } -func (*NatGetMssClampingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatGetTimeouts represents VPP binary API message 'nat_get_timeouts'. -type NatGetTimeouts struct{} - -func (m *NatGetTimeouts) Reset() { *m = NatGetTimeouts{} } -func (*NatGetTimeouts) GetMessageName() string { return "nat_get_timeouts" } -func (*NatGetTimeouts) GetCrcString() string { return "51077d14" } -func (*NatGetTimeouts) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatGetTimeoutsReply represents VPP binary API message 'nat_get_timeouts_reply'. -type NatGetTimeoutsReply struct { - Retval int32 - UDP uint32 - TCPEstablished uint32 - TCPTransitory uint32 - ICMP uint32 -} - -func (m *NatGetTimeoutsReply) Reset() { *m = NatGetTimeoutsReply{} } -func (*NatGetTimeoutsReply) GetMessageName() string { return "nat_get_timeouts_reply" } -func (*NatGetTimeoutsReply) GetCrcString() string { return "3c4df4e1" } -func (*NatGetTimeoutsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatHaFlush represents VPP binary API message 'nat_ha_flush'. -type NatHaFlush struct{} - -func (m *NatHaFlush) Reset() { *m = NatHaFlush{} } -func (*NatHaFlush) GetMessageName() string { return "nat_ha_flush" } -func (*NatHaFlush) GetCrcString() string { return "51077d14" } -func (*NatHaFlush) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatHaFlushReply represents VPP binary API message 'nat_ha_flush_reply'. -type NatHaFlushReply struct { - Retval int32 -} - -func (m *NatHaFlushReply) Reset() { *m = NatHaFlushReply{} } -func (*NatHaFlushReply) GetMessageName() string { return "nat_ha_flush_reply" } -func (*NatHaFlushReply) GetCrcString() string { return "e8d4e804" } -func (*NatHaFlushReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatHaGetFailover represents VPP binary API message 'nat_ha_get_failover'. -type NatHaGetFailover struct{} - -func (m *NatHaGetFailover) Reset() { *m = NatHaGetFailover{} } -func (*NatHaGetFailover) GetMessageName() string { return "nat_ha_get_failover" } -func (*NatHaGetFailover) GetCrcString() string { return "51077d14" } -func (*NatHaGetFailover) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatHaGetFailoverReply represents VPP binary API message 'nat_ha_get_failover_reply'. -type NatHaGetFailoverReply struct { - Retval int32 - IPAddress IP4Address - Port uint16 - SessionRefreshInterval uint32 -} - -func (m *NatHaGetFailoverReply) Reset() { *m = NatHaGetFailoverReply{} } -func (*NatHaGetFailoverReply) GetMessageName() string { return "nat_ha_get_failover_reply" } -func (*NatHaGetFailoverReply) GetCrcString() string { return "a67d8752" } -func (*NatHaGetFailoverReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatHaGetListener represents VPP binary API message 'nat_ha_get_listener'. -type NatHaGetListener struct{} - -func (m *NatHaGetListener) Reset() { *m = NatHaGetListener{} } -func (*NatHaGetListener) GetMessageName() string { return "nat_ha_get_listener" } -func (*NatHaGetListener) GetCrcString() string { return "51077d14" } -func (*NatHaGetListener) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatHaGetListenerReply represents VPP binary API message 'nat_ha_get_listener_reply'. -type NatHaGetListenerReply struct { - Retval int32 - IPAddress IP4Address - Port uint16 - PathMtu uint32 -} - -func (m *NatHaGetListenerReply) Reset() { *m = NatHaGetListenerReply{} } -func (*NatHaGetListenerReply) GetMessageName() string { return "nat_ha_get_listener_reply" } -func (*NatHaGetListenerReply) GetCrcString() string { return "123ea41f" } -func (*NatHaGetListenerReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatHaResync represents VPP binary API message 'nat_ha_resync'. -type NatHaResync struct { - WantResyncEvent uint8 - PID uint32 -} - -func (m *NatHaResync) Reset() { *m = NatHaResync{} } -func (*NatHaResync) GetMessageName() string { return "nat_ha_resync" } -func (*NatHaResync) GetCrcString() string { return "c8ab9e03" } -func (*NatHaResync) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatHaResyncCompletedEvent represents VPP binary API message 'nat_ha_resync_completed_event'. -type NatHaResyncCompletedEvent struct { - PID uint32 - MissedCount uint32 -} - -func (m *NatHaResyncCompletedEvent) Reset() { *m = NatHaResyncCompletedEvent{} } -func (*NatHaResyncCompletedEvent) GetMessageName() string { return "nat_ha_resync_completed_event" } -func (*NatHaResyncCompletedEvent) GetCrcString() string { return "fdc598fb" } -func (*NatHaResyncCompletedEvent) GetMessageType() api.MessageType { return api.EventMessage } - -// NatHaResyncReply represents VPP binary API message 'nat_ha_resync_reply'. -type NatHaResyncReply struct { - Retval int32 -} - -func (m *NatHaResyncReply) Reset() { *m = NatHaResyncReply{} } -func (*NatHaResyncReply) GetMessageName() string { return "nat_ha_resync_reply" } -func (*NatHaResyncReply) GetCrcString() string { return "e8d4e804" } -func (*NatHaResyncReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatHaSetFailover represents VPP binary API message 'nat_ha_set_failover'. -type NatHaSetFailover struct { - IPAddress IP4Address - Port uint16 - SessionRefreshInterval uint32 -} - -func (m *NatHaSetFailover) Reset() { *m = NatHaSetFailover{} } -func (*NatHaSetFailover) GetMessageName() string { return "nat_ha_set_failover" } -func (*NatHaSetFailover) GetCrcString() string { return "718246af" } -func (*NatHaSetFailover) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatHaSetFailoverReply represents VPP binary API message 'nat_ha_set_failover_reply'. -type NatHaSetFailoverReply struct { - Retval int32 -} - -func (m *NatHaSetFailoverReply) Reset() { *m = NatHaSetFailoverReply{} } -func (*NatHaSetFailoverReply) GetMessageName() string { return "nat_ha_set_failover_reply" } -func (*NatHaSetFailoverReply) GetCrcString() string { return "e8d4e804" } -func (*NatHaSetFailoverReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatHaSetListener represents VPP binary API message 'nat_ha_set_listener'. -type NatHaSetListener struct { - IPAddress IP4Address - Port uint16 - PathMtu uint32 -} - -func (m *NatHaSetListener) Reset() { *m = NatHaSetListener{} } -func (*NatHaSetListener) GetMessageName() string { return "nat_ha_set_listener" } -func (*NatHaSetListener) GetCrcString() string { return "e4a8cb4e" } -func (*NatHaSetListener) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatHaSetListenerReply represents VPP binary API message 'nat_ha_set_listener_reply'. -type NatHaSetListenerReply struct { - Retval int32 -} - -func (m *NatHaSetListenerReply) Reset() { *m = NatHaSetListenerReply{} } -func (*NatHaSetListenerReply) GetMessageName() string { return "nat_ha_set_listener_reply" } -func (*NatHaSetListenerReply) GetCrcString() string { return "e8d4e804" } -func (*NatHaSetListenerReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatIpfixEnableDisable represents VPP binary API message 'nat_ipfix_enable_disable'. -type NatIpfixEnableDisable struct { - DomainID uint32 - SrcPort uint16 - Enable bool -} - -func (m *NatIpfixEnableDisable) Reset() { *m = NatIpfixEnableDisable{} } -func (*NatIpfixEnableDisable) GetMessageName() string { return "nat_ipfix_enable_disable" } -func (*NatIpfixEnableDisable) GetCrcString() string { return "9af4a2d2" } -func (*NatIpfixEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatIpfixEnableDisableReply represents VPP binary API message 'nat_ipfix_enable_disable_reply'. -type NatIpfixEnableDisableReply struct { - Retval int32 -} - -func (m *NatIpfixEnableDisableReply) Reset() { *m = NatIpfixEnableDisableReply{} } -func (*NatIpfixEnableDisableReply) GetMessageName() string { return "nat_ipfix_enable_disable_reply" } -func (*NatIpfixEnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*NatIpfixEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatSetAddrAndPortAllocAlg represents VPP binary API message 'nat_set_addr_and_port_alloc_alg'. -type NatSetAddrAndPortAllocAlg struct { - Alg uint8 - PsidOffset uint8 - PsidLength uint8 - Psid uint16 - StartPort uint16 - EndPort uint16 -} - -func (m *NatSetAddrAndPortAllocAlg) Reset() { *m = NatSetAddrAndPortAllocAlg{} } -func (*NatSetAddrAndPortAllocAlg) GetMessageName() string { return "nat_set_addr_and_port_alloc_alg" } -func (*NatSetAddrAndPortAllocAlg) GetCrcString() string { return "deeb746f" } -func (*NatSetAddrAndPortAllocAlg) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatSetAddrAndPortAllocAlgReply represents VPP binary API message 'nat_set_addr_and_port_alloc_alg_reply'. -type NatSetAddrAndPortAllocAlgReply struct { - Retval int32 -} - -func (m *NatSetAddrAndPortAllocAlgReply) Reset() { *m = NatSetAddrAndPortAllocAlgReply{} } -func (*NatSetAddrAndPortAllocAlgReply) GetMessageName() string { - return "nat_set_addr_and_port_alloc_alg_reply" -} -func (*NatSetAddrAndPortAllocAlgReply) GetCrcString() string { return "e8d4e804" } -func (*NatSetAddrAndPortAllocAlgReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatSetLogLevel represents VPP binary API message 'nat_set_log_level'. -type NatSetLogLevel struct { - LogLevel NatLogLevel -} - -func (m *NatSetLogLevel) Reset() { *m = NatSetLogLevel{} } -func (*NatSetLogLevel) GetMessageName() string { return "nat_set_log_level" } -func (*NatSetLogLevel) GetCrcString() string { return "70076bfe" } -func (*NatSetLogLevel) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatSetLogLevelReply represents VPP binary API message 'nat_set_log_level_reply'. -type NatSetLogLevelReply struct { - Retval int32 -} - -func (m *NatSetLogLevelReply) Reset() { *m = NatSetLogLevelReply{} } -func (*NatSetLogLevelReply) GetMessageName() string { return "nat_set_log_level_reply" } -func (*NatSetLogLevelReply) GetCrcString() string { return "e8d4e804" } -func (*NatSetLogLevelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatSetMssClamping represents VPP binary API message 'nat_set_mss_clamping'. -type NatSetMssClamping struct { - MssValue uint16 - Enable bool -} - -func (m *NatSetMssClamping) Reset() { *m = NatSetMssClamping{} } -func (*NatSetMssClamping) GetMessageName() string { return "nat_set_mss_clamping" } -func (*NatSetMssClamping) GetCrcString() string { return "25e90abb" } -func (*NatSetMssClamping) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatSetMssClampingReply represents VPP binary API message 'nat_set_mss_clamping_reply'. -type NatSetMssClampingReply struct { - Retval int32 -} - -func (m *NatSetMssClampingReply) Reset() { *m = NatSetMssClampingReply{} } -func (*NatSetMssClampingReply) GetMessageName() string { return "nat_set_mss_clamping_reply" } -func (*NatSetMssClampingReply) GetCrcString() string { return "e8d4e804" } -func (*NatSetMssClampingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatSetTimeouts represents VPP binary API message 'nat_set_timeouts'. -type NatSetTimeouts struct { - UDP uint32 - TCPEstablished uint32 - TCPTransitory uint32 - ICMP uint32 -} - -func (m *NatSetTimeouts) Reset() { *m = NatSetTimeouts{} } -func (*NatSetTimeouts) GetMessageName() string { return "nat_set_timeouts" } -func (*NatSetTimeouts) GetCrcString() string { return "d4746b16" } -func (*NatSetTimeouts) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatSetTimeoutsReply represents VPP binary API message 'nat_set_timeouts_reply'. -type NatSetTimeoutsReply struct { - Retval int32 -} - -func (m *NatSetTimeoutsReply) Reset() { *m = NatSetTimeoutsReply{} } -func (*NatSetTimeoutsReply) GetMessageName() string { return "nat_set_timeouts_reply" } -func (*NatSetTimeoutsReply) GetCrcString() string { return "e8d4e804" } -func (*NatSetTimeoutsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatSetWorkers represents VPP binary API message 'nat_set_workers'. -type NatSetWorkers struct { - WorkerMask uint64 -} - -func (m *NatSetWorkers) Reset() { *m = NatSetWorkers{} } -func (*NatSetWorkers) GetMessageName() string { return "nat_set_workers" } -func (*NatSetWorkers) GetCrcString() string { return "da926638" } -func (*NatSetWorkers) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatSetWorkersReply represents VPP binary API message 'nat_set_workers_reply'. -type NatSetWorkersReply struct { - Retval int32 -} - -func (m *NatSetWorkersReply) Reset() { *m = NatSetWorkersReply{} } -func (*NatSetWorkersReply) GetMessageName() string { return "nat_set_workers_reply" } -func (*NatSetWorkersReply) GetCrcString() string { return "e8d4e804" } -func (*NatSetWorkersReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatShowConfig represents VPP binary API message 'nat_show_config'. -type NatShowConfig struct{} - -func (m *NatShowConfig) Reset() { *m = NatShowConfig{} } -func (*NatShowConfig) GetMessageName() string { return "nat_show_config" } -func (*NatShowConfig) GetCrcString() string { return "51077d14" } -func (*NatShowConfig) GetMessageType() api.MessageType { return api.RequestMessage } - -// NatShowConfigReply represents VPP binary API message 'nat_show_config_reply'. -type NatShowConfigReply struct { - Retval int32 - StaticMappingOnly bool - StaticMappingConnectionTracking bool - Deterministic bool - EndpointDependent bool - Out2inDpo bool - DsliteCe bool - TranslationBuckets uint32 - TranslationMemorySize uint32 - UserBuckets uint32 - UserMemorySize uint32 - MaxTranslationsPerUser uint32 - OutsideVrfID uint32 - InsideVrfID uint32 - Nat64BibBuckets uint32 - Nat64BibMemorySize uint32 - Nat64StBuckets uint32 - Nat64StMemorySize uint32 -} - -func (m *NatShowConfigReply) Reset() { *m = NatShowConfigReply{} } -func (*NatShowConfigReply) GetMessageName() string { return "nat_show_config_reply" } -func (*NatShowConfigReply) GetCrcString() string { return "006a0786" } -func (*NatShowConfigReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatWorkerDetails represents VPP binary API message 'nat_worker_details'. -type NatWorkerDetails struct { - WorkerIndex uint32 - LcoreID uint32 - Name string `struc:"[64]byte"` -} - -func (m *NatWorkerDetails) Reset() { *m = NatWorkerDetails{} } -func (*NatWorkerDetails) GetMessageName() string { return "nat_worker_details" } -func (*NatWorkerDetails) GetCrcString() string { return "84bf06fc" } -func (*NatWorkerDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// NatWorkerDump represents VPP binary API message 'nat_worker_dump'. -type NatWorkerDump struct{} - -func (m *NatWorkerDump) Reset() { *m = NatWorkerDump{} } -func (*NatWorkerDump) GetMessageName() string { return "nat_worker_dump" } -func (*NatWorkerDump) GetCrcString() string { return "51077d14" } -func (*NatWorkerDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*DsliteAddDelPoolAddrRange)(nil), "nat.DsliteAddDelPoolAddrRange") - api.RegisterMessage((*DsliteAddDelPoolAddrRangeReply)(nil), "nat.DsliteAddDelPoolAddrRangeReply") - api.RegisterMessage((*DsliteAddressDetails)(nil), "nat.DsliteAddressDetails") - api.RegisterMessage((*DsliteAddressDump)(nil), "nat.DsliteAddressDump") - api.RegisterMessage((*DsliteGetAftrAddr)(nil), "nat.DsliteGetAftrAddr") - api.RegisterMessage((*DsliteGetAftrAddrReply)(nil), "nat.DsliteGetAftrAddrReply") - api.RegisterMessage((*DsliteGetB4Addr)(nil), "nat.DsliteGetB4Addr") - api.RegisterMessage((*DsliteGetB4AddrReply)(nil), "nat.DsliteGetB4AddrReply") - api.RegisterMessage((*DsliteSetAftrAddr)(nil), "nat.DsliteSetAftrAddr") - api.RegisterMessage((*DsliteSetAftrAddrReply)(nil), "nat.DsliteSetAftrAddrReply") - api.RegisterMessage((*DsliteSetB4Addr)(nil), "nat.DsliteSetB4Addr") - api.RegisterMessage((*DsliteSetB4AddrReply)(nil), "nat.DsliteSetB4AddrReply") - api.RegisterMessage((*Nat44AddDelAddressRange)(nil), "nat.Nat44AddDelAddressRange") - api.RegisterMessage((*Nat44AddDelAddressRangeReply)(nil), "nat.Nat44AddDelAddressRangeReply") - api.RegisterMessage((*Nat44AddDelIdentityMapping)(nil), "nat.Nat44AddDelIdentityMapping") - api.RegisterMessage((*Nat44AddDelIdentityMappingReply)(nil), "nat.Nat44AddDelIdentityMappingReply") - api.RegisterMessage((*Nat44AddDelInterfaceAddr)(nil), "nat.Nat44AddDelInterfaceAddr") - api.RegisterMessage((*Nat44AddDelInterfaceAddrReply)(nil), "nat.Nat44AddDelInterfaceAddrReply") - api.RegisterMessage((*Nat44AddDelLbStaticMapping)(nil), "nat.Nat44AddDelLbStaticMapping") - api.RegisterMessage((*Nat44AddDelLbStaticMappingReply)(nil), "nat.Nat44AddDelLbStaticMappingReply") - api.RegisterMessage((*Nat44AddDelStaticMapping)(nil), "nat.Nat44AddDelStaticMapping") - api.RegisterMessage((*Nat44AddDelStaticMappingReply)(nil), "nat.Nat44AddDelStaticMappingReply") - api.RegisterMessage((*Nat44AddressDetails)(nil), "nat.Nat44AddressDetails") - api.RegisterMessage((*Nat44AddressDump)(nil), "nat.Nat44AddressDump") - api.RegisterMessage((*Nat44DelSession)(nil), "nat.Nat44DelSession") - api.RegisterMessage((*Nat44DelSessionReply)(nil), "nat.Nat44DelSessionReply") - api.RegisterMessage((*Nat44ForwardingEnableDisable)(nil), "nat.Nat44ForwardingEnableDisable") - api.RegisterMessage((*Nat44ForwardingEnableDisableReply)(nil), "nat.Nat44ForwardingEnableDisableReply") - api.RegisterMessage((*Nat44ForwardingIsEnabled)(nil), "nat.Nat44ForwardingIsEnabled") - api.RegisterMessage((*Nat44ForwardingIsEnabledReply)(nil), "nat.Nat44ForwardingIsEnabledReply") - api.RegisterMessage((*Nat44IdentityMappingDetails)(nil), "nat.Nat44IdentityMappingDetails") - api.RegisterMessage((*Nat44IdentityMappingDump)(nil), "nat.Nat44IdentityMappingDump") - api.RegisterMessage((*Nat44InterfaceAddDelFeature)(nil), "nat.Nat44InterfaceAddDelFeature") - api.RegisterMessage((*Nat44InterfaceAddDelFeatureReply)(nil), "nat.Nat44InterfaceAddDelFeatureReply") - api.RegisterMessage((*Nat44InterfaceAddDelOutputFeature)(nil), "nat.Nat44InterfaceAddDelOutputFeature") - api.RegisterMessage((*Nat44InterfaceAddDelOutputFeatureReply)(nil), "nat.Nat44InterfaceAddDelOutputFeatureReply") - api.RegisterMessage((*Nat44InterfaceAddrDetails)(nil), "nat.Nat44InterfaceAddrDetails") - api.RegisterMessage((*Nat44InterfaceAddrDump)(nil), "nat.Nat44InterfaceAddrDump") - api.RegisterMessage((*Nat44InterfaceDetails)(nil), "nat.Nat44InterfaceDetails") - api.RegisterMessage((*Nat44InterfaceDump)(nil), "nat.Nat44InterfaceDump") - api.RegisterMessage((*Nat44InterfaceOutputFeatureDetails)(nil), "nat.Nat44InterfaceOutputFeatureDetails") - api.RegisterMessage((*Nat44InterfaceOutputFeatureDump)(nil), "nat.Nat44InterfaceOutputFeatureDump") - api.RegisterMessage((*Nat44LbStaticMappingAddDelLocal)(nil), "nat.Nat44LbStaticMappingAddDelLocal") - api.RegisterMessage((*Nat44LbStaticMappingAddDelLocalReply)(nil), "nat.Nat44LbStaticMappingAddDelLocalReply") - api.RegisterMessage((*Nat44LbStaticMappingDetails)(nil), "nat.Nat44LbStaticMappingDetails") - api.RegisterMessage((*Nat44LbStaticMappingDump)(nil), "nat.Nat44LbStaticMappingDump") - api.RegisterMessage((*Nat44StaticMappingDetails)(nil), "nat.Nat44StaticMappingDetails") - api.RegisterMessage((*Nat44StaticMappingDump)(nil), "nat.Nat44StaticMappingDump") - api.RegisterMessage((*Nat44UserDetails)(nil), "nat.Nat44UserDetails") - api.RegisterMessage((*Nat44UserDump)(nil), "nat.Nat44UserDump") - api.RegisterMessage((*Nat44UserSessionDetails)(nil), "nat.Nat44UserSessionDetails") - api.RegisterMessage((*Nat44UserSessionDump)(nil), "nat.Nat44UserSessionDump") - api.RegisterMessage((*Nat64AddDelInterface)(nil), "nat.Nat64AddDelInterface") - api.RegisterMessage((*Nat64AddDelInterfaceAddr)(nil), "nat.Nat64AddDelInterfaceAddr") - api.RegisterMessage((*Nat64AddDelInterfaceAddrReply)(nil), "nat.Nat64AddDelInterfaceAddrReply") - api.RegisterMessage((*Nat64AddDelInterfaceReply)(nil), "nat.Nat64AddDelInterfaceReply") - api.RegisterMessage((*Nat64AddDelPoolAddrRange)(nil), "nat.Nat64AddDelPoolAddrRange") - api.RegisterMessage((*Nat64AddDelPoolAddrRangeReply)(nil), "nat.Nat64AddDelPoolAddrRangeReply") - api.RegisterMessage((*Nat64AddDelPrefix)(nil), "nat.Nat64AddDelPrefix") - api.RegisterMessage((*Nat64AddDelPrefixReply)(nil), "nat.Nat64AddDelPrefixReply") - api.RegisterMessage((*Nat64AddDelStaticBib)(nil), "nat.Nat64AddDelStaticBib") - api.RegisterMessage((*Nat64AddDelStaticBibReply)(nil), "nat.Nat64AddDelStaticBibReply") - api.RegisterMessage((*Nat64BibDetails)(nil), "nat.Nat64BibDetails") - api.RegisterMessage((*Nat64BibDump)(nil), "nat.Nat64BibDump") - api.RegisterMessage((*Nat64InterfaceDetails)(nil), "nat.Nat64InterfaceDetails") - api.RegisterMessage((*Nat64InterfaceDump)(nil), "nat.Nat64InterfaceDump") - api.RegisterMessage((*Nat64PoolAddrDetails)(nil), "nat.Nat64PoolAddrDetails") - api.RegisterMessage((*Nat64PoolAddrDump)(nil), "nat.Nat64PoolAddrDump") - api.RegisterMessage((*Nat64PrefixDetails)(nil), "nat.Nat64PrefixDetails") - api.RegisterMessage((*Nat64PrefixDump)(nil), "nat.Nat64PrefixDump") - api.RegisterMessage((*Nat64StDetails)(nil), "nat.Nat64StDetails") - api.RegisterMessage((*Nat64StDump)(nil), "nat.Nat64StDump") - api.RegisterMessage((*Nat66AddDelInterface)(nil), "nat.Nat66AddDelInterface") - api.RegisterMessage((*Nat66AddDelInterfaceReply)(nil), "nat.Nat66AddDelInterfaceReply") - api.RegisterMessage((*Nat66AddDelStaticMapping)(nil), "nat.Nat66AddDelStaticMapping") - api.RegisterMessage((*Nat66AddDelStaticMappingReply)(nil), "nat.Nat66AddDelStaticMappingReply") - api.RegisterMessage((*Nat66InterfaceDetails)(nil), "nat.Nat66InterfaceDetails") - api.RegisterMessage((*Nat66InterfaceDump)(nil), "nat.Nat66InterfaceDump") - api.RegisterMessage((*Nat66StaticMappingDetails)(nil), "nat.Nat66StaticMappingDetails") - api.RegisterMessage((*Nat66StaticMappingDump)(nil), "nat.Nat66StaticMappingDump") - api.RegisterMessage((*NatControlPing)(nil), "nat.NatControlPing") - api.RegisterMessage((*NatControlPingReply)(nil), "nat.NatControlPingReply") - api.RegisterMessage((*NatDetAddDelMap)(nil), "nat.NatDetAddDelMap") - api.RegisterMessage((*NatDetAddDelMapReply)(nil), "nat.NatDetAddDelMapReply") - api.RegisterMessage((*NatDetCloseSessionIn)(nil), "nat.NatDetCloseSessionIn") - api.RegisterMessage((*NatDetCloseSessionInReply)(nil), "nat.NatDetCloseSessionInReply") - api.RegisterMessage((*NatDetCloseSessionOut)(nil), "nat.NatDetCloseSessionOut") - api.RegisterMessage((*NatDetCloseSessionOutReply)(nil), "nat.NatDetCloseSessionOutReply") - api.RegisterMessage((*NatDetForward)(nil), "nat.NatDetForward") - api.RegisterMessage((*NatDetForwardReply)(nil), "nat.NatDetForwardReply") - api.RegisterMessage((*NatDetMapDetails)(nil), "nat.NatDetMapDetails") - api.RegisterMessage((*NatDetMapDump)(nil), "nat.NatDetMapDump") - api.RegisterMessage((*NatDetReverse)(nil), "nat.NatDetReverse") - api.RegisterMessage((*NatDetReverseReply)(nil), "nat.NatDetReverseReply") - api.RegisterMessage((*NatDetSessionDetails)(nil), "nat.NatDetSessionDetails") - api.RegisterMessage((*NatDetSessionDump)(nil), "nat.NatDetSessionDump") - api.RegisterMessage((*NatGetAddrAndPortAllocAlg)(nil), "nat.NatGetAddrAndPortAllocAlg") - api.RegisterMessage((*NatGetAddrAndPortAllocAlgReply)(nil), "nat.NatGetAddrAndPortAllocAlgReply") - api.RegisterMessage((*NatGetMssClamping)(nil), "nat.NatGetMssClamping") - api.RegisterMessage((*NatGetMssClampingReply)(nil), "nat.NatGetMssClampingReply") - api.RegisterMessage((*NatGetTimeouts)(nil), "nat.NatGetTimeouts") - api.RegisterMessage((*NatGetTimeoutsReply)(nil), "nat.NatGetTimeoutsReply") - api.RegisterMessage((*NatHaFlush)(nil), "nat.NatHaFlush") - api.RegisterMessage((*NatHaFlushReply)(nil), "nat.NatHaFlushReply") - api.RegisterMessage((*NatHaGetFailover)(nil), "nat.NatHaGetFailover") - api.RegisterMessage((*NatHaGetFailoverReply)(nil), "nat.NatHaGetFailoverReply") - api.RegisterMessage((*NatHaGetListener)(nil), "nat.NatHaGetListener") - api.RegisterMessage((*NatHaGetListenerReply)(nil), "nat.NatHaGetListenerReply") - api.RegisterMessage((*NatHaResync)(nil), "nat.NatHaResync") - api.RegisterMessage((*NatHaResyncCompletedEvent)(nil), "nat.NatHaResyncCompletedEvent") - api.RegisterMessage((*NatHaResyncReply)(nil), "nat.NatHaResyncReply") - api.RegisterMessage((*NatHaSetFailover)(nil), "nat.NatHaSetFailover") - api.RegisterMessage((*NatHaSetFailoverReply)(nil), "nat.NatHaSetFailoverReply") - api.RegisterMessage((*NatHaSetListener)(nil), "nat.NatHaSetListener") - api.RegisterMessage((*NatHaSetListenerReply)(nil), "nat.NatHaSetListenerReply") - api.RegisterMessage((*NatIpfixEnableDisable)(nil), "nat.NatIpfixEnableDisable") - api.RegisterMessage((*NatIpfixEnableDisableReply)(nil), "nat.NatIpfixEnableDisableReply") - api.RegisterMessage((*NatSetAddrAndPortAllocAlg)(nil), "nat.NatSetAddrAndPortAllocAlg") - api.RegisterMessage((*NatSetAddrAndPortAllocAlgReply)(nil), "nat.NatSetAddrAndPortAllocAlgReply") - api.RegisterMessage((*NatSetLogLevel)(nil), "nat.NatSetLogLevel") - api.RegisterMessage((*NatSetLogLevelReply)(nil), "nat.NatSetLogLevelReply") - api.RegisterMessage((*NatSetMssClamping)(nil), "nat.NatSetMssClamping") - api.RegisterMessage((*NatSetMssClampingReply)(nil), "nat.NatSetMssClampingReply") - api.RegisterMessage((*NatSetTimeouts)(nil), "nat.NatSetTimeouts") - api.RegisterMessage((*NatSetTimeoutsReply)(nil), "nat.NatSetTimeoutsReply") - api.RegisterMessage((*NatSetWorkers)(nil), "nat.NatSetWorkers") - api.RegisterMessage((*NatSetWorkersReply)(nil), "nat.NatSetWorkersReply") - api.RegisterMessage((*NatShowConfig)(nil), "nat.NatShowConfig") - api.RegisterMessage((*NatShowConfigReply)(nil), "nat.NatShowConfigReply") - api.RegisterMessage((*NatWorkerDetails)(nil), "nat.NatWorkerDetails") - api.RegisterMessage((*NatWorkerDump)(nil), "nat.NatWorkerDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*DsliteAddDelPoolAddrRange)(nil), - (*DsliteAddDelPoolAddrRangeReply)(nil), - (*DsliteAddressDetails)(nil), - (*DsliteAddressDump)(nil), - (*DsliteGetAftrAddr)(nil), - (*DsliteGetAftrAddrReply)(nil), - (*DsliteGetB4Addr)(nil), - (*DsliteGetB4AddrReply)(nil), - (*DsliteSetAftrAddr)(nil), - (*DsliteSetAftrAddrReply)(nil), - (*DsliteSetB4Addr)(nil), - (*DsliteSetB4AddrReply)(nil), - (*Nat44AddDelAddressRange)(nil), - (*Nat44AddDelAddressRangeReply)(nil), - (*Nat44AddDelIdentityMapping)(nil), - (*Nat44AddDelIdentityMappingReply)(nil), - (*Nat44AddDelInterfaceAddr)(nil), - (*Nat44AddDelInterfaceAddrReply)(nil), - (*Nat44AddDelLbStaticMapping)(nil), - (*Nat44AddDelLbStaticMappingReply)(nil), - (*Nat44AddDelStaticMapping)(nil), - (*Nat44AddDelStaticMappingReply)(nil), - (*Nat44AddressDetails)(nil), - (*Nat44AddressDump)(nil), - (*Nat44DelSession)(nil), - (*Nat44DelSessionReply)(nil), - (*Nat44ForwardingEnableDisable)(nil), - (*Nat44ForwardingEnableDisableReply)(nil), - (*Nat44ForwardingIsEnabled)(nil), - (*Nat44ForwardingIsEnabledReply)(nil), - (*Nat44IdentityMappingDetails)(nil), - (*Nat44IdentityMappingDump)(nil), - (*Nat44InterfaceAddDelFeature)(nil), - (*Nat44InterfaceAddDelFeatureReply)(nil), - (*Nat44InterfaceAddDelOutputFeature)(nil), - (*Nat44InterfaceAddDelOutputFeatureReply)(nil), - (*Nat44InterfaceAddrDetails)(nil), - (*Nat44InterfaceAddrDump)(nil), - (*Nat44InterfaceDetails)(nil), - (*Nat44InterfaceDump)(nil), - (*Nat44InterfaceOutputFeatureDetails)(nil), - (*Nat44InterfaceOutputFeatureDump)(nil), - (*Nat44LbStaticMappingAddDelLocal)(nil), - (*Nat44LbStaticMappingAddDelLocalReply)(nil), - (*Nat44LbStaticMappingDetails)(nil), - (*Nat44LbStaticMappingDump)(nil), - (*Nat44StaticMappingDetails)(nil), - (*Nat44StaticMappingDump)(nil), - (*Nat44UserDetails)(nil), - (*Nat44UserDump)(nil), - (*Nat44UserSessionDetails)(nil), - (*Nat44UserSessionDump)(nil), - (*Nat64AddDelInterface)(nil), - (*Nat64AddDelInterfaceAddr)(nil), - (*Nat64AddDelInterfaceAddrReply)(nil), - (*Nat64AddDelInterfaceReply)(nil), - (*Nat64AddDelPoolAddrRange)(nil), - (*Nat64AddDelPoolAddrRangeReply)(nil), - (*Nat64AddDelPrefix)(nil), - (*Nat64AddDelPrefixReply)(nil), - (*Nat64AddDelStaticBib)(nil), - (*Nat64AddDelStaticBibReply)(nil), - (*Nat64BibDetails)(nil), - (*Nat64BibDump)(nil), - (*Nat64InterfaceDetails)(nil), - (*Nat64InterfaceDump)(nil), - (*Nat64PoolAddrDetails)(nil), - (*Nat64PoolAddrDump)(nil), - (*Nat64PrefixDetails)(nil), - (*Nat64PrefixDump)(nil), - (*Nat64StDetails)(nil), - (*Nat64StDump)(nil), - (*Nat66AddDelInterface)(nil), - (*Nat66AddDelInterfaceReply)(nil), - (*Nat66AddDelStaticMapping)(nil), - (*Nat66AddDelStaticMappingReply)(nil), - (*Nat66InterfaceDetails)(nil), - (*Nat66InterfaceDump)(nil), - (*Nat66StaticMappingDetails)(nil), - (*Nat66StaticMappingDump)(nil), - (*NatControlPing)(nil), - (*NatControlPingReply)(nil), - (*NatDetAddDelMap)(nil), - (*NatDetAddDelMapReply)(nil), - (*NatDetCloseSessionIn)(nil), - (*NatDetCloseSessionInReply)(nil), - (*NatDetCloseSessionOut)(nil), - (*NatDetCloseSessionOutReply)(nil), - (*NatDetForward)(nil), - (*NatDetForwardReply)(nil), - (*NatDetMapDetails)(nil), - (*NatDetMapDump)(nil), - (*NatDetReverse)(nil), - (*NatDetReverseReply)(nil), - (*NatDetSessionDetails)(nil), - (*NatDetSessionDump)(nil), - (*NatGetAddrAndPortAllocAlg)(nil), - (*NatGetAddrAndPortAllocAlgReply)(nil), - (*NatGetMssClamping)(nil), - (*NatGetMssClampingReply)(nil), - (*NatGetTimeouts)(nil), - (*NatGetTimeoutsReply)(nil), - (*NatHaFlush)(nil), - (*NatHaFlushReply)(nil), - (*NatHaGetFailover)(nil), - (*NatHaGetFailoverReply)(nil), - (*NatHaGetListener)(nil), - (*NatHaGetListenerReply)(nil), - (*NatHaResync)(nil), - (*NatHaResyncCompletedEvent)(nil), - (*NatHaResyncReply)(nil), - (*NatHaSetFailover)(nil), - (*NatHaSetFailoverReply)(nil), - (*NatHaSetListener)(nil), - (*NatHaSetListenerReply)(nil), - (*NatIpfixEnableDisable)(nil), - (*NatIpfixEnableDisableReply)(nil), - (*NatSetAddrAndPortAllocAlg)(nil), - (*NatSetAddrAndPortAllocAlgReply)(nil), - (*NatSetLogLevel)(nil), - (*NatSetLogLevelReply)(nil), - (*NatSetMssClamping)(nil), - (*NatSetMssClampingReply)(nil), - (*NatSetTimeouts)(nil), - (*NatSetTimeoutsReply)(nil), - (*NatSetWorkers)(nil), - (*NatSetWorkersReply)(nil), - (*NatShowConfig)(nil), - (*NatShowConfigReply)(nil), - (*NatWorkerDetails)(nil), - (*NatWorkerDump)(nil), - } -} - -// RPCService represents RPC service API for nat module. -type RPCService interface { - DumpDsliteAddress(ctx context.Context, in *DsliteAddressDump) (RPCService_DumpDsliteAddressClient, error) - DumpNat44Address(ctx context.Context, in *Nat44AddressDump) (RPCService_DumpNat44AddressClient, error) - DumpNat44IdentityMapping(ctx context.Context, in *Nat44IdentityMappingDump) (RPCService_DumpNat44IdentityMappingClient, error) - DumpNat44InterfaceAddr(ctx context.Context, in *Nat44InterfaceAddrDump) (RPCService_DumpNat44InterfaceAddrClient, error) - DumpNat44Interface(ctx context.Context, in *Nat44InterfaceDump) (RPCService_DumpNat44InterfaceClient, error) - DumpNat44InterfaceOutputFeature(ctx context.Context, in *Nat44InterfaceOutputFeatureDump) (RPCService_DumpNat44InterfaceOutputFeatureClient, error) - DumpNat44LbStaticMapping(ctx context.Context, in *Nat44LbStaticMappingDump) (RPCService_DumpNat44LbStaticMappingClient, error) - DumpNat44StaticMapping(ctx context.Context, in *Nat44StaticMappingDump) (RPCService_DumpNat44StaticMappingClient, error) - DumpNat44User(ctx context.Context, in *Nat44UserDump) (RPCService_DumpNat44UserClient, error) - DumpNat44UserSession(ctx context.Context, in *Nat44UserSessionDump) (RPCService_DumpNat44UserSessionClient, error) - DumpNat64Bib(ctx context.Context, in *Nat64BibDump) (RPCService_DumpNat64BibClient, error) - DumpNat64Interface(ctx context.Context, in *Nat64InterfaceDump) (RPCService_DumpNat64InterfaceClient, error) - DumpNat64PoolAddr(ctx context.Context, in *Nat64PoolAddrDump) (RPCService_DumpNat64PoolAddrClient, error) - DumpNat64Prefix(ctx context.Context, in *Nat64PrefixDump) (RPCService_DumpNat64PrefixClient, error) - DumpNat64St(ctx context.Context, in *Nat64StDump) (RPCService_DumpNat64StClient, error) - DumpNat66Interface(ctx context.Context, in *Nat66InterfaceDump) (RPCService_DumpNat66InterfaceClient, error) - DumpNat66StaticMapping(ctx context.Context, in *Nat66StaticMappingDump) (RPCService_DumpNat66StaticMappingClient, error) - DumpNatDetMap(ctx context.Context, in *NatDetMapDump) (RPCService_DumpNatDetMapClient, error) - DumpNatDetSession(ctx context.Context, in *NatDetSessionDump) (RPCService_DumpNatDetSessionClient, error) - DumpNatWorker(ctx context.Context, in *NatWorkerDump) (RPCService_DumpNatWorkerClient, error) - DsliteAddDelPoolAddrRange(ctx context.Context, in *DsliteAddDelPoolAddrRange) (*DsliteAddDelPoolAddrRangeReply, error) - DsliteGetAftrAddr(ctx context.Context, in *DsliteGetAftrAddr) (*DsliteGetAftrAddrReply, error) - DsliteGetB4Addr(ctx context.Context, in *DsliteGetB4Addr) (*DsliteGetB4AddrReply, error) - DsliteSetAftrAddr(ctx context.Context, in *DsliteSetAftrAddr) (*DsliteSetAftrAddrReply, error) - DsliteSetB4Addr(ctx context.Context, in *DsliteSetB4Addr) (*DsliteSetB4AddrReply, error) - Nat44AddDelAddressRange(ctx context.Context, in *Nat44AddDelAddressRange) (*Nat44AddDelAddressRangeReply, error) - Nat44AddDelIdentityMapping(ctx context.Context, in *Nat44AddDelIdentityMapping) (*Nat44AddDelIdentityMappingReply, error) - Nat44AddDelInterfaceAddr(ctx context.Context, in *Nat44AddDelInterfaceAddr) (*Nat44AddDelInterfaceAddrReply, error) - Nat44AddDelLbStaticMapping(ctx context.Context, in *Nat44AddDelLbStaticMapping) (*Nat44AddDelLbStaticMappingReply, error) - Nat44AddDelStaticMapping(ctx context.Context, in *Nat44AddDelStaticMapping) (*Nat44AddDelStaticMappingReply, error) - Nat44DelSession(ctx context.Context, in *Nat44DelSession) (*Nat44DelSessionReply, error) - Nat44ForwardingEnableDisable(ctx context.Context, in *Nat44ForwardingEnableDisable) (*Nat44ForwardingEnableDisableReply, error) - Nat44ForwardingIsEnabled(ctx context.Context, in *Nat44ForwardingIsEnabled) (*Nat44ForwardingIsEnabledReply, error) - Nat44InterfaceAddDelFeature(ctx context.Context, in *Nat44InterfaceAddDelFeature) (*Nat44InterfaceAddDelFeatureReply, error) - Nat44InterfaceAddDelOutputFeature(ctx context.Context, in *Nat44InterfaceAddDelOutputFeature) (*Nat44InterfaceAddDelOutputFeatureReply, error) - Nat44LbStaticMappingAddDelLocal(ctx context.Context, in *Nat44LbStaticMappingAddDelLocal) (*Nat44LbStaticMappingAddDelLocalReply, error) - Nat64AddDelInterface(ctx context.Context, in *Nat64AddDelInterface) (*Nat64AddDelInterfaceReply, error) - Nat64AddDelInterfaceAddr(ctx context.Context, in *Nat64AddDelInterfaceAddr) (*Nat64AddDelInterfaceAddrReply, error) - Nat64AddDelPoolAddrRange(ctx context.Context, in *Nat64AddDelPoolAddrRange) (*Nat64AddDelPoolAddrRangeReply, error) - Nat64AddDelPrefix(ctx context.Context, in *Nat64AddDelPrefix) (*Nat64AddDelPrefixReply, error) - Nat64AddDelStaticBib(ctx context.Context, in *Nat64AddDelStaticBib) (*Nat64AddDelStaticBibReply, error) - Nat66AddDelInterface(ctx context.Context, in *Nat66AddDelInterface) (*Nat66AddDelInterfaceReply, error) - Nat66AddDelStaticMapping(ctx context.Context, in *Nat66AddDelStaticMapping) (*Nat66AddDelStaticMappingReply, error) - NatControlPing(ctx context.Context, in *NatControlPing) (*NatControlPingReply, error) - NatDetAddDelMap(ctx context.Context, in *NatDetAddDelMap) (*NatDetAddDelMapReply, error) - NatDetCloseSessionIn(ctx context.Context, in *NatDetCloseSessionIn) (*NatDetCloseSessionInReply, error) - NatDetCloseSessionOut(ctx context.Context, in *NatDetCloseSessionOut) (*NatDetCloseSessionOutReply, error) - NatDetForward(ctx context.Context, in *NatDetForward) (*NatDetForwardReply, error) - NatDetReverse(ctx context.Context, in *NatDetReverse) (*NatDetReverseReply, error) - NatGetAddrAndPortAllocAlg(ctx context.Context, in *NatGetAddrAndPortAllocAlg) (*NatGetAddrAndPortAllocAlgReply, error) - NatGetMssClamping(ctx context.Context, in *NatGetMssClamping) (*NatGetMssClampingReply, error) - NatGetTimeouts(ctx context.Context, in *NatGetTimeouts) (*NatGetTimeoutsReply, error) - NatHaFlush(ctx context.Context, in *NatHaFlush) (*NatHaFlushReply, error) - NatHaGetFailover(ctx context.Context, in *NatHaGetFailover) (*NatHaGetFailoverReply, error) - NatHaGetListener(ctx context.Context, in *NatHaGetListener) (*NatHaGetListenerReply, error) - NatHaResync(ctx context.Context, in *NatHaResync) (*NatHaResyncReply, error) - NatHaSetFailover(ctx context.Context, in *NatHaSetFailover) (*NatHaSetFailoverReply, error) - NatHaSetListener(ctx context.Context, in *NatHaSetListener) (*NatHaSetListenerReply, error) - NatIpfixEnableDisable(ctx context.Context, in *NatIpfixEnableDisable) (*NatIpfixEnableDisableReply, error) - NatSetAddrAndPortAllocAlg(ctx context.Context, in *NatSetAddrAndPortAllocAlg) (*NatSetAddrAndPortAllocAlgReply, error) - NatSetLogLevel(ctx context.Context, in *NatSetLogLevel) (*NatSetLogLevelReply, error) - NatSetMssClamping(ctx context.Context, in *NatSetMssClamping) (*NatSetMssClampingReply, error) - NatSetTimeouts(ctx context.Context, in *NatSetTimeouts) (*NatSetTimeoutsReply, error) - NatSetWorkers(ctx context.Context, in *NatSetWorkers) (*NatSetWorkersReply, error) - NatShowConfig(ctx context.Context, in *NatShowConfig) (*NatShowConfigReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpDsliteAddress(ctx context.Context, in *DsliteAddressDump) (RPCService_DumpDsliteAddressClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpDsliteAddressClient{stream} - return x, nil -} - -type RPCService_DumpDsliteAddressClient interface { - Recv() (*DsliteAddressDetails, error) -} - -type serviceClient_DumpDsliteAddressClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpDsliteAddressClient) Recv() (*DsliteAddressDetails, error) { - m := new(DsliteAddressDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44Address(ctx context.Context, in *Nat44AddressDump) (RPCService_DumpNat44AddressClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44AddressClient{stream} - return x, nil -} - -type RPCService_DumpNat44AddressClient interface { - Recv() (*Nat44AddressDetails, error) -} - -type serviceClient_DumpNat44AddressClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44AddressClient) Recv() (*Nat44AddressDetails, error) { - m := new(Nat44AddressDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44IdentityMapping(ctx context.Context, in *Nat44IdentityMappingDump) (RPCService_DumpNat44IdentityMappingClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44IdentityMappingClient{stream} - return x, nil -} - -type RPCService_DumpNat44IdentityMappingClient interface { - Recv() (*Nat44IdentityMappingDetails, error) -} - -type serviceClient_DumpNat44IdentityMappingClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44IdentityMappingClient) Recv() (*Nat44IdentityMappingDetails, error) { - m := new(Nat44IdentityMappingDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44InterfaceAddr(ctx context.Context, in *Nat44InterfaceAddrDump) (RPCService_DumpNat44InterfaceAddrClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44InterfaceAddrClient{stream} - return x, nil -} - -type RPCService_DumpNat44InterfaceAddrClient interface { - Recv() (*Nat44InterfaceAddrDetails, error) -} - -type serviceClient_DumpNat44InterfaceAddrClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44InterfaceAddrClient) Recv() (*Nat44InterfaceAddrDetails, error) { - m := new(Nat44InterfaceAddrDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44Interface(ctx context.Context, in *Nat44InterfaceDump) (RPCService_DumpNat44InterfaceClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44InterfaceClient{stream} - return x, nil -} - -type RPCService_DumpNat44InterfaceClient interface { - Recv() (*Nat44InterfaceDetails, error) -} - -type serviceClient_DumpNat44InterfaceClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44InterfaceClient) Recv() (*Nat44InterfaceDetails, error) { - m := new(Nat44InterfaceDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44InterfaceOutputFeature(ctx context.Context, in *Nat44InterfaceOutputFeatureDump) (RPCService_DumpNat44InterfaceOutputFeatureClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44InterfaceOutputFeatureClient{stream} - return x, nil -} - -type RPCService_DumpNat44InterfaceOutputFeatureClient interface { - Recv() (*Nat44InterfaceOutputFeatureDetails, error) -} - -type serviceClient_DumpNat44InterfaceOutputFeatureClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44InterfaceOutputFeatureClient) Recv() (*Nat44InterfaceOutputFeatureDetails, error) { - m := new(Nat44InterfaceOutputFeatureDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44LbStaticMapping(ctx context.Context, in *Nat44LbStaticMappingDump) (RPCService_DumpNat44LbStaticMappingClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44LbStaticMappingClient{stream} - return x, nil -} - -type RPCService_DumpNat44LbStaticMappingClient interface { - Recv() (*Nat44LbStaticMappingDetails, error) -} - -type serviceClient_DumpNat44LbStaticMappingClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44LbStaticMappingClient) Recv() (*Nat44LbStaticMappingDetails, error) { - m := new(Nat44LbStaticMappingDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44StaticMapping(ctx context.Context, in *Nat44StaticMappingDump) (RPCService_DumpNat44StaticMappingClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44StaticMappingClient{stream} - return x, nil -} - -type RPCService_DumpNat44StaticMappingClient interface { - Recv() (*Nat44StaticMappingDetails, error) -} - -type serviceClient_DumpNat44StaticMappingClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44StaticMappingClient) Recv() (*Nat44StaticMappingDetails, error) { - m := new(Nat44StaticMappingDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44User(ctx context.Context, in *Nat44UserDump) (RPCService_DumpNat44UserClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44UserClient{stream} - return x, nil -} - -type RPCService_DumpNat44UserClient interface { - Recv() (*Nat44UserDetails, error) -} - -type serviceClient_DumpNat44UserClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44UserClient) Recv() (*Nat44UserDetails, error) { - m := new(Nat44UserDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat44UserSession(ctx context.Context, in *Nat44UserSessionDump) (RPCService_DumpNat44UserSessionClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat44UserSessionClient{stream} - return x, nil -} - -type RPCService_DumpNat44UserSessionClient interface { - Recv() (*Nat44UserSessionDetails, error) -} - -type serviceClient_DumpNat44UserSessionClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat44UserSessionClient) Recv() (*Nat44UserSessionDetails, error) { - m := new(Nat44UserSessionDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat64Bib(ctx context.Context, in *Nat64BibDump) (RPCService_DumpNat64BibClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat64BibClient{stream} - return x, nil -} - -type RPCService_DumpNat64BibClient interface { - Recv() (*Nat64BibDetails, error) -} - -type serviceClient_DumpNat64BibClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat64BibClient) Recv() (*Nat64BibDetails, error) { - m := new(Nat64BibDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat64Interface(ctx context.Context, in *Nat64InterfaceDump) (RPCService_DumpNat64InterfaceClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat64InterfaceClient{stream} - return x, nil -} - -type RPCService_DumpNat64InterfaceClient interface { - Recv() (*Nat64InterfaceDetails, error) -} - -type serviceClient_DumpNat64InterfaceClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat64InterfaceClient) Recv() (*Nat64InterfaceDetails, error) { - m := new(Nat64InterfaceDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat64PoolAddr(ctx context.Context, in *Nat64PoolAddrDump) (RPCService_DumpNat64PoolAddrClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat64PoolAddrClient{stream} - return x, nil -} - -type RPCService_DumpNat64PoolAddrClient interface { - Recv() (*Nat64PoolAddrDetails, error) -} - -type serviceClient_DumpNat64PoolAddrClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat64PoolAddrClient) Recv() (*Nat64PoolAddrDetails, error) { - m := new(Nat64PoolAddrDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat64Prefix(ctx context.Context, in *Nat64PrefixDump) (RPCService_DumpNat64PrefixClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat64PrefixClient{stream} - return x, nil -} - -type RPCService_DumpNat64PrefixClient interface { - Recv() (*Nat64PrefixDetails, error) -} - -type serviceClient_DumpNat64PrefixClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat64PrefixClient) Recv() (*Nat64PrefixDetails, error) { - m := new(Nat64PrefixDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat64St(ctx context.Context, in *Nat64StDump) (RPCService_DumpNat64StClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat64StClient{stream} - return x, nil -} - -type RPCService_DumpNat64StClient interface { - Recv() (*Nat64StDetails, error) -} - -type serviceClient_DumpNat64StClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat64StClient) Recv() (*Nat64StDetails, error) { - m := new(Nat64StDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat66Interface(ctx context.Context, in *Nat66InterfaceDump) (RPCService_DumpNat66InterfaceClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat66InterfaceClient{stream} - return x, nil -} - -type RPCService_DumpNat66InterfaceClient interface { - Recv() (*Nat66InterfaceDetails, error) -} - -type serviceClient_DumpNat66InterfaceClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat66InterfaceClient) Recv() (*Nat66InterfaceDetails, error) { - m := new(Nat66InterfaceDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNat66StaticMapping(ctx context.Context, in *Nat66StaticMappingDump) (RPCService_DumpNat66StaticMappingClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNat66StaticMappingClient{stream} - return x, nil -} - -type RPCService_DumpNat66StaticMappingClient interface { - Recv() (*Nat66StaticMappingDetails, error) -} - -type serviceClient_DumpNat66StaticMappingClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNat66StaticMappingClient) Recv() (*Nat66StaticMappingDetails, error) { - m := new(Nat66StaticMappingDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNatDetMap(ctx context.Context, in *NatDetMapDump) (RPCService_DumpNatDetMapClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNatDetMapClient{stream} - return x, nil -} - -type RPCService_DumpNatDetMapClient interface { - Recv() (*NatDetMapDetails, error) -} - -type serviceClient_DumpNatDetMapClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNatDetMapClient) Recv() (*NatDetMapDetails, error) { - m := new(NatDetMapDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNatDetSession(ctx context.Context, in *NatDetSessionDump) (RPCService_DumpNatDetSessionClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNatDetSessionClient{stream} - return x, nil -} - -type RPCService_DumpNatDetSessionClient interface { - Recv() (*NatDetSessionDetails, error) -} - -type serviceClient_DumpNatDetSessionClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNatDetSessionClient) Recv() (*NatDetSessionDetails, error) { - m := new(NatDetSessionDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpNatWorker(ctx context.Context, in *NatWorkerDump) (RPCService_DumpNatWorkerClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpNatWorkerClient{stream} - return x, nil -} - -type RPCService_DumpNatWorkerClient interface { - Recv() (*NatWorkerDetails, error) -} - -type serviceClient_DumpNatWorkerClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpNatWorkerClient) Recv() (*NatWorkerDetails, error) { - m := new(NatWorkerDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DsliteAddDelPoolAddrRange(ctx context.Context, in *DsliteAddDelPoolAddrRange) (*DsliteAddDelPoolAddrRangeReply, error) { - out := new(DsliteAddDelPoolAddrRangeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DsliteGetAftrAddr(ctx context.Context, in *DsliteGetAftrAddr) (*DsliteGetAftrAddrReply, error) { - out := new(DsliteGetAftrAddrReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DsliteGetB4Addr(ctx context.Context, in *DsliteGetB4Addr) (*DsliteGetB4AddrReply, error) { - out := new(DsliteGetB4AddrReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DsliteSetAftrAddr(ctx context.Context, in *DsliteSetAftrAddr) (*DsliteSetAftrAddrReply, error) { - out := new(DsliteSetAftrAddrReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) DsliteSetB4Addr(ctx context.Context, in *DsliteSetB4Addr) (*DsliteSetB4AddrReply, error) { - out := new(DsliteSetB4AddrReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44AddDelAddressRange(ctx context.Context, in *Nat44AddDelAddressRange) (*Nat44AddDelAddressRangeReply, error) { - out := new(Nat44AddDelAddressRangeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44AddDelIdentityMapping(ctx context.Context, in *Nat44AddDelIdentityMapping) (*Nat44AddDelIdentityMappingReply, error) { - out := new(Nat44AddDelIdentityMappingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44AddDelInterfaceAddr(ctx context.Context, in *Nat44AddDelInterfaceAddr) (*Nat44AddDelInterfaceAddrReply, error) { - out := new(Nat44AddDelInterfaceAddrReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44AddDelLbStaticMapping(ctx context.Context, in *Nat44AddDelLbStaticMapping) (*Nat44AddDelLbStaticMappingReply, error) { - out := new(Nat44AddDelLbStaticMappingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44AddDelStaticMapping(ctx context.Context, in *Nat44AddDelStaticMapping) (*Nat44AddDelStaticMappingReply, error) { - out := new(Nat44AddDelStaticMappingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44DelSession(ctx context.Context, in *Nat44DelSession) (*Nat44DelSessionReply, error) { - out := new(Nat44DelSessionReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44ForwardingEnableDisable(ctx context.Context, in *Nat44ForwardingEnableDisable) (*Nat44ForwardingEnableDisableReply, error) { - out := new(Nat44ForwardingEnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44ForwardingIsEnabled(ctx context.Context, in *Nat44ForwardingIsEnabled) (*Nat44ForwardingIsEnabledReply, error) { - out := new(Nat44ForwardingIsEnabledReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44InterfaceAddDelFeature(ctx context.Context, in *Nat44InterfaceAddDelFeature) (*Nat44InterfaceAddDelFeatureReply, error) { - out := new(Nat44InterfaceAddDelFeatureReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44InterfaceAddDelOutputFeature(ctx context.Context, in *Nat44InterfaceAddDelOutputFeature) (*Nat44InterfaceAddDelOutputFeatureReply, error) { - out := new(Nat44InterfaceAddDelOutputFeatureReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat44LbStaticMappingAddDelLocal(ctx context.Context, in *Nat44LbStaticMappingAddDelLocal) (*Nat44LbStaticMappingAddDelLocalReply, error) { - out := new(Nat44LbStaticMappingAddDelLocalReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat64AddDelInterface(ctx context.Context, in *Nat64AddDelInterface) (*Nat64AddDelInterfaceReply, error) { - out := new(Nat64AddDelInterfaceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat64AddDelInterfaceAddr(ctx context.Context, in *Nat64AddDelInterfaceAddr) (*Nat64AddDelInterfaceAddrReply, error) { - out := new(Nat64AddDelInterfaceAddrReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat64AddDelPoolAddrRange(ctx context.Context, in *Nat64AddDelPoolAddrRange) (*Nat64AddDelPoolAddrRangeReply, error) { - out := new(Nat64AddDelPoolAddrRangeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat64AddDelPrefix(ctx context.Context, in *Nat64AddDelPrefix) (*Nat64AddDelPrefixReply, error) { - out := new(Nat64AddDelPrefixReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat64AddDelStaticBib(ctx context.Context, in *Nat64AddDelStaticBib) (*Nat64AddDelStaticBibReply, error) { - out := new(Nat64AddDelStaticBibReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat66AddDelInterface(ctx context.Context, in *Nat66AddDelInterface) (*Nat66AddDelInterfaceReply, error) { - out := new(Nat66AddDelInterfaceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Nat66AddDelStaticMapping(ctx context.Context, in *Nat66AddDelStaticMapping) (*Nat66AddDelStaticMappingReply, error) { - out := new(Nat66AddDelStaticMappingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatControlPing(ctx context.Context, in *NatControlPing) (*NatControlPingReply, error) { - out := new(NatControlPingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatDetAddDelMap(ctx context.Context, in *NatDetAddDelMap) (*NatDetAddDelMapReply, error) { - out := new(NatDetAddDelMapReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatDetCloseSessionIn(ctx context.Context, in *NatDetCloseSessionIn) (*NatDetCloseSessionInReply, error) { - out := new(NatDetCloseSessionInReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatDetCloseSessionOut(ctx context.Context, in *NatDetCloseSessionOut) (*NatDetCloseSessionOutReply, error) { - out := new(NatDetCloseSessionOutReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatDetForward(ctx context.Context, in *NatDetForward) (*NatDetForwardReply, error) { - out := new(NatDetForwardReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatDetReverse(ctx context.Context, in *NatDetReverse) (*NatDetReverseReply, error) { - out := new(NatDetReverseReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatGetAddrAndPortAllocAlg(ctx context.Context, in *NatGetAddrAndPortAllocAlg) (*NatGetAddrAndPortAllocAlgReply, error) { - out := new(NatGetAddrAndPortAllocAlgReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatGetMssClamping(ctx context.Context, in *NatGetMssClamping) (*NatGetMssClampingReply, error) { - out := new(NatGetMssClampingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatGetTimeouts(ctx context.Context, in *NatGetTimeouts) (*NatGetTimeoutsReply, error) { - out := new(NatGetTimeoutsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatHaFlush(ctx context.Context, in *NatHaFlush) (*NatHaFlushReply, error) { - out := new(NatHaFlushReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatHaGetFailover(ctx context.Context, in *NatHaGetFailover) (*NatHaGetFailoverReply, error) { - out := new(NatHaGetFailoverReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatHaGetListener(ctx context.Context, in *NatHaGetListener) (*NatHaGetListenerReply, error) { - out := new(NatHaGetListenerReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatHaResync(ctx context.Context, in *NatHaResync) (*NatHaResyncReply, error) { - out := new(NatHaResyncReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatHaSetFailover(ctx context.Context, in *NatHaSetFailover) (*NatHaSetFailoverReply, error) { - out := new(NatHaSetFailoverReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatHaSetListener(ctx context.Context, in *NatHaSetListener) (*NatHaSetListenerReply, error) { - out := new(NatHaSetListenerReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatIpfixEnableDisable(ctx context.Context, in *NatIpfixEnableDisable) (*NatIpfixEnableDisableReply, error) { - out := new(NatIpfixEnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatSetAddrAndPortAllocAlg(ctx context.Context, in *NatSetAddrAndPortAllocAlg) (*NatSetAddrAndPortAllocAlgReply, error) { - out := new(NatSetAddrAndPortAllocAlgReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatSetLogLevel(ctx context.Context, in *NatSetLogLevel) (*NatSetLogLevelReply, error) { - out := new(NatSetLogLevelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatSetMssClamping(ctx context.Context, in *NatSetMssClamping) (*NatSetMssClampingReply, error) { - out := new(NatSetMssClampingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatSetTimeouts(ctx context.Context, in *NatSetTimeouts) (*NatSetTimeoutsReply, error) { - out := new(NatSetTimeoutsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatSetWorkers(ctx context.Context, in *NatSetWorkers) (*NatSetWorkersReply, error) { - out := new(NatSetWorkersReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) NatShowConfig(ctx context.Context, in *NatShowConfig) (*NatShowConfigReply, error) { - out := new(NatShowConfigReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/punt/punt.ba.go b/plugins/vpp/binapi/vpp2001/punt/punt.ba.go deleted file mode 100644 index ed06fa762c..0000000000 --- a/plugins/vpp/binapi/vpp2001/punt/punt.ba.go +++ /dev/null @@ -1,440 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/punt.api.json - -/* -Package punt is a generated VPP binary API for 'punt' module. - -It consists of: - 5 enums - 5 aliases - 11 types - 2 unions - 10 messages - 5 services -*/ -package punt - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "punt" - // APIVersion is the API version of this module. - APIVersion = "2.2.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0x51716f7f -) - -type AddressFamily = ip_types.AddressFamily - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -// PuntType represents VPP binary API enum 'punt_type'. -type PuntType uint32 - -const ( - PUNT_API_TYPE_L4 PuntType = 1 - PUNT_API_TYPE_IP_PROTO PuntType = 2 - PUNT_API_TYPE_EXCEPTION PuntType = 3 -) - -var PuntType_name = map[uint32]string{ - 1: "PUNT_API_TYPE_L4", - 2: "PUNT_API_TYPE_IP_PROTO", - 3: "PUNT_API_TYPE_EXCEPTION", -} - -var PuntType_value = map[string]uint32{ - "PUNT_API_TYPE_L4": 1, - "PUNT_API_TYPE_IP_PROTO": 2, - "PUNT_API_TYPE_EXCEPTION": 3, -} - -func (x PuntType) String() string { - s, ok := PuntType_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -// Punt represents VPP binary API type 'punt'. -type Punt struct { - Type PuntType - Punt PuntUnion -} - -func (*Punt) GetTypeName() string { return "punt" } - -// PuntException represents VPP binary API type 'punt_exception'. -type PuntException struct { - ID uint32 -} - -func (*PuntException) GetTypeName() string { return "punt_exception" } - -// PuntIPProto represents VPP binary API type 'punt_ip_proto'. -type PuntIPProto struct { - Af AddressFamily - Protocol IPProto -} - -func (*PuntIPProto) GetTypeName() string { return "punt_ip_proto" } - -// PuntL4 represents VPP binary API type 'punt_l4'. -type PuntL4 struct { - Af AddressFamily - Protocol IPProto - Port uint16 -} - -func (*PuntL4) GetTypeName() string { return "punt_l4" } - -// PuntReason represents VPP binary API type 'punt_reason'. -type PuntReason struct { - ID uint32 - XXX_NameLen uint32 `struc:"sizeof=Name"` - Name string -} - -func (*PuntReason) GetTypeName() string { return "punt_reason" } - -type AddressUnion = ip_types.AddressUnion - -// PuntUnion represents VPP binary API union 'punt_union'. -type PuntUnion struct { - XXX_UnionData [10]byte -} - -func (*PuntUnion) GetTypeName() string { return "punt_union" } - -func PuntUnionException(a PuntException) (u PuntUnion) { - u.SetException(a) - return -} -func (u *PuntUnion) SetException(a PuntException) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *PuntUnion) GetException() (a PuntException) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} - -func PuntUnionL4(a PuntL4) (u PuntUnion) { - u.SetL4(a) - return -} -func (u *PuntUnion) SetL4(a PuntL4) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *PuntUnion) GetL4() (a PuntL4) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} - -func PuntUnionIPProto(a PuntIPProto) (u PuntUnion) { - u.SetIPProto(a) - return -} -func (u *PuntUnion) SetIPProto(a PuntIPProto) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *PuntUnion) GetIPProto() (a PuntIPProto) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} - -// PuntReasonDetails represents VPP binary API message 'punt_reason_details'. -type PuntReasonDetails struct { - Reason PuntReason -} - -func (m *PuntReasonDetails) Reset() { *m = PuntReasonDetails{} } -func (*PuntReasonDetails) GetMessageName() string { return "punt_reason_details" } -func (*PuntReasonDetails) GetCrcString() string { return "2c9d4a40" } -func (*PuntReasonDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// PuntReasonDump represents VPP binary API message 'punt_reason_dump'. -type PuntReasonDump struct { - Reason PuntReason -} - -func (m *PuntReasonDump) Reset() { *m = PuntReasonDump{} } -func (*PuntReasonDump) GetMessageName() string { return "punt_reason_dump" } -func (*PuntReasonDump) GetCrcString() string { return "5c0dd4fe" } -func (*PuntReasonDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// PuntSocketDeregister represents VPP binary API message 'punt_socket_deregister'. -type PuntSocketDeregister struct { - Punt Punt -} - -func (m *PuntSocketDeregister) Reset() { *m = PuntSocketDeregister{} } -func (*PuntSocketDeregister) GetMessageName() string { return "punt_socket_deregister" } -func (*PuntSocketDeregister) GetCrcString() string { return "98a444f4" } -func (*PuntSocketDeregister) GetMessageType() api.MessageType { return api.RequestMessage } - -// PuntSocketDeregisterReply represents VPP binary API message 'punt_socket_deregister_reply'. -type PuntSocketDeregisterReply struct { - Retval int32 -} - -func (m *PuntSocketDeregisterReply) Reset() { *m = PuntSocketDeregisterReply{} } -func (*PuntSocketDeregisterReply) GetMessageName() string { return "punt_socket_deregister_reply" } -func (*PuntSocketDeregisterReply) GetCrcString() string { return "e8d4e804" } -func (*PuntSocketDeregisterReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// PuntSocketDetails represents VPP binary API message 'punt_socket_details'. -type PuntSocketDetails struct { - Punt Punt - Pathname string `struc:"[108]byte"` -} - -func (m *PuntSocketDetails) Reset() { *m = PuntSocketDetails{} } -func (*PuntSocketDetails) GetMessageName() string { return "punt_socket_details" } -func (*PuntSocketDetails) GetCrcString() string { return "1de0ce75" } -func (*PuntSocketDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// PuntSocketDump represents VPP binary API message 'punt_socket_dump'. -type PuntSocketDump struct { - Type PuntType -} - -func (m *PuntSocketDump) Reset() { *m = PuntSocketDump{} } -func (*PuntSocketDump) GetMessageName() string { return "punt_socket_dump" } -func (*PuntSocketDump) GetCrcString() string { return "52974935" } -func (*PuntSocketDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// PuntSocketRegister represents VPP binary API message 'punt_socket_register'. -type PuntSocketRegister struct { - HeaderVersion uint32 - Punt Punt - Pathname string `struc:"[108]byte"` -} - -func (m *PuntSocketRegister) Reset() { *m = PuntSocketRegister{} } -func (*PuntSocketRegister) GetMessageName() string { return "punt_socket_register" } -func (*PuntSocketRegister) GetCrcString() string { return "c8cd10fa" } -func (*PuntSocketRegister) GetMessageType() api.MessageType { return api.RequestMessage } - -// PuntSocketRegisterReply represents VPP binary API message 'punt_socket_register_reply'. -type PuntSocketRegisterReply struct { - Retval int32 - Pathname string `struc:"[108]byte"` -} - -func (m *PuntSocketRegisterReply) Reset() { *m = PuntSocketRegisterReply{} } -func (*PuntSocketRegisterReply) GetMessageName() string { return "punt_socket_register_reply" } -func (*PuntSocketRegisterReply) GetCrcString() string { return "bd30ae90" } -func (*PuntSocketRegisterReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SetPunt represents VPP binary API message 'set_punt'. -type SetPunt struct { - IsAdd bool - Punt Punt -} - -func (m *SetPunt) Reset() { *m = SetPunt{} } -func (*SetPunt) GetMessageName() string { return "set_punt" } -func (*SetPunt) GetCrcString() string { return "83799618" } -func (*SetPunt) GetMessageType() api.MessageType { return api.RequestMessage } - -// SetPuntReply represents VPP binary API message 'set_punt_reply'. -type SetPuntReply struct { - Retval int32 -} - -func (m *SetPuntReply) Reset() { *m = SetPuntReply{} } -func (*SetPuntReply) GetMessageName() string { return "set_punt_reply" } -func (*SetPuntReply) GetCrcString() string { return "e8d4e804" } -func (*SetPuntReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*PuntReasonDetails)(nil), "punt.PuntReasonDetails") - api.RegisterMessage((*PuntReasonDump)(nil), "punt.PuntReasonDump") - api.RegisterMessage((*PuntSocketDeregister)(nil), "punt.PuntSocketDeregister") - api.RegisterMessage((*PuntSocketDeregisterReply)(nil), "punt.PuntSocketDeregisterReply") - api.RegisterMessage((*PuntSocketDetails)(nil), "punt.PuntSocketDetails") - api.RegisterMessage((*PuntSocketDump)(nil), "punt.PuntSocketDump") - api.RegisterMessage((*PuntSocketRegister)(nil), "punt.PuntSocketRegister") - api.RegisterMessage((*PuntSocketRegisterReply)(nil), "punt.PuntSocketRegisterReply") - api.RegisterMessage((*SetPunt)(nil), "punt.SetPunt") - api.RegisterMessage((*SetPuntReply)(nil), "punt.SetPuntReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*PuntReasonDetails)(nil), - (*PuntReasonDump)(nil), - (*PuntSocketDeregister)(nil), - (*PuntSocketDeregisterReply)(nil), - (*PuntSocketDetails)(nil), - (*PuntSocketDump)(nil), - (*PuntSocketRegister)(nil), - (*PuntSocketRegisterReply)(nil), - (*SetPunt)(nil), - (*SetPuntReply)(nil), - } -} - -// RPCService represents RPC service API for punt module. -type RPCService interface { - DumpPuntReason(ctx context.Context, in *PuntReasonDump) (RPCService_DumpPuntReasonClient, error) - DumpPuntSocket(ctx context.Context, in *PuntSocketDump) (RPCService_DumpPuntSocketClient, error) - PuntSocketDeregister(ctx context.Context, in *PuntSocketDeregister) (*PuntSocketDeregisterReply, error) - PuntSocketRegister(ctx context.Context, in *PuntSocketRegister) (*PuntSocketRegisterReply, error) - SetPunt(ctx context.Context, in *SetPunt) (*SetPuntReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpPuntReason(ctx context.Context, in *PuntReasonDump) (RPCService_DumpPuntReasonClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpPuntReasonClient{stream} - return x, nil -} - -type RPCService_DumpPuntReasonClient interface { - Recv() (*PuntReasonDetails, error) -} - -type serviceClient_DumpPuntReasonClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpPuntReasonClient) Recv() (*PuntReasonDetails, error) { - m := new(PuntReasonDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpPuntSocket(ctx context.Context, in *PuntSocketDump) (RPCService_DumpPuntSocketClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpPuntSocketClient{stream} - return x, nil -} - -type RPCService_DumpPuntSocketClient interface { - Recv() (*PuntSocketDetails, error) -} - -type serviceClient_DumpPuntSocketClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpPuntSocketClient) Recv() (*PuntSocketDetails, error) { - m := new(PuntSocketDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) PuntSocketDeregister(ctx context.Context, in *PuntSocketDeregister) (*PuntSocketDeregisterReply, error) { - out := new(PuntSocketDeregisterReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) PuntSocketRegister(ctx context.Context, in *PuntSocketRegister) (*PuntSocketRegisterReply, error) { - out := new(PuntSocketRegisterReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SetPunt(ctx context.Context, in *SetPunt) (*SetPuntReply, error) { - out := new(SetPuntReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/rd_cp/rd_cp.ba.go b/plugins/vpp/binapi/vpp2001/rd_cp/rd_cp.ba.go deleted file mode 100644 index e5be342ba1..0000000000 --- a/plugins/vpp/binapi/vpp2001/rd_cp/rd_cp.ba.go +++ /dev/null @@ -1,119 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/rd_cp.api.json - -/* -Package rd_cp is a generated VPP binary API for 'rd_cp' module. - -It consists of: - 6 enums - 1 alias - 2 messages - 1 service -*/ -package rd_cp - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "rd_cp" - // APIVersion is the API version of this module. - APIVersion = "1.0.1" - // VersionCrc is the CRC of this module. - VersionCrc = 0x5269dfb9 -) - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type InterfaceIndex = interface_types.InterfaceIndex - -// IP6NdAddressAutoconfig represents VPP binary API message 'ip6_nd_address_autoconfig'. -type IP6NdAddressAutoconfig struct { - SwIfIndex InterfaceIndex - Enable bool - InstallDefaultRoutes bool -} - -func (m *IP6NdAddressAutoconfig) Reset() { *m = IP6NdAddressAutoconfig{} } -func (*IP6NdAddressAutoconfig) GetMessageName() string { return "ip6_nd_address_autoconfig" } -func (*IP6NdAddressAutoconfig) GetCrcString() string { return "9e14a4a7" } -func (*IP6NdAddressAutoconfig) GetMessageType() api.MessageType { return api.RequestMessage } - -// IP6NdAddressAutoconfigReply represents VPP binary API message 'ip6_nd_address_autoconfig_reply'. -type IP6NdAddressAutoconfigReply struct { - Retval int32 -} - -func (m *IP6NdAddressAutoconfigReply) Reset() { *m = IP6NdAddressAutoconfigReply{} } -func (*IP6NdAddressAutoconfigReply) GetMessageName() string { return "ip6_nd_address_autoconfig_reply" } -func (*IP6NdAddressAutoconfigReply) GetCrcString() string { return "e8d4e804" } -func (*IP6NdAddressAutoconfigReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*IP6NdAddressAutoconfig)(nil), "rd_cp.IP6NdAddressAutoconfig") - api.RegisterMessage((*IP6NdAddressAutoconfigReply)(nil), "rd_cp.IP6NdAddressAutoconfigReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*IP6NdAddressAutoconfig)(nil), - (*IP6NdAddressAutoconfigReply)(nil), - } -} - -// RPCService represents RPC service API for rd_cp module. -type RPCService interface { - IP6NdAddressAutoconfig(ctx context.Context, in *IP6NdAddressAutoconfig) (*IP6NdAddressAutoconfigReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) IP6NdAddressAutoconfig(ctx context.Context, in *IP6NdAddressAutoconfig) (*IP6NdAddressAutoconfigReply, error) { - out := new(IP6NdAddressAutoconfigReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/rdma/rdma.ba.go b/plugins/vpp/binapi/vpp2001/rdma/rdma.ba.go deleted file mode 100644 index f90697dfab..0000000000 --- a/plugins/vpp/binapi/vpp2001/rdma/rdma.ba.go +++ /dev/null @@ -1,184 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/rdma.api.json - -/* -Package rdma is a generated VPP binary API for 'rdma' module. - -It consists of: - 7 enums - 1 alias - 4 messages - 2 services -*/ -package rdma - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "rdma" - // VersionCrc is the CRC of this module. - VersionCrc = 0x5ce233e0 -) - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -// RdmaMode represents VPP binary API enum 'rdma_mode'. -type RdmaMode uint32 - -const ( - RDMA_API_MODE_AUTO RdmaMode = 0 - RDMA_API_MODE_IBV RdmaMode = 1 - RDMA_API_MODE_DV RdmaMode = 2 -) - -var RdmaMode_name = map[uint32]string{ - 0: "RDMA_API_MODE_AUTO", - 1: "RDMA_API_MODE_IBV", - 2: "RDMA_API_MODE_DV", -} - -var RdmaMode_value = map[string]uint32{ - "RDMA_API_MODE_AUTO": 0, - "RDMA_API_MODE_IBV": 1, - "RDMA_API_MODE_DV": 2, -} - -func (x RdmaMode) String() string { - s, ok := RdmaMode_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type InterfaceIndex = interface_types.InterfaceIndex - -// RdmaCreate represents VPP binary API message 'rdma_create'. -type RdmaCreate struct { - HostIf string `struc:"[64]byte"` - Name string `struc:"[64]byte"` - RxqNum uint16 - RxqSize uint16 - TxqSize uint16 - Mode RdmaMode -} - -func (m *RdmaCreate) Reset() { *m = RdmaCreate{} } -func (*RdmaCreate) GetMessageName() string { return "rdma_create" } -func (*RdmaCreate) GetCrcString() string { return "076fe418" } -func (*RdmaCreate) GetMessageType() api.MessageType { return api.RequestMessage } - -// RdmaCreateReply represents VPP binary API message 'rdma_create_reply'. -type RdmaCreateReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *RdmaCreateReply) Reset() { *m = RdmaCreateReply{} } -func (*RdmaCreateReply) GetMessageName() string { return "rdma_create_reply" } -func (*RdmaCreateReply) GetCrcString() string { return "5383d31f" } -func (*RdmaCreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// RdmaDelete represents VPP binary API message 'rdma_delete'. -type RdmaDelete struct { - SwIfIndex InterfaceIndex -} - -func (m *RdmaDelete) Reset() { *m = RdmaDelete{} } -func (*RdmaDelete) GetMessageName() string { return "rdma_delete" } -func (*RdmaDelete) GetCrcString() string { return "f9e6675e" } -func (*RdmaDelete) GetMessageType() api.MessageType { return api.RequestMessage } - -// RdmaDeleteReply represents VPP binary API message 'rdma_delete_reply'. -type RdmaDeleteReply struct { - Retval int32 -} - -func (m *RdmaDeleteReply) Reset() { *m = RdmaDeleteReply{} } -func (*RdmaDeleteReply) GetMessageName() string { return "rdma_delete_reply" } -func (*RdmaDeleteReply) GetCrcString() string { return "e8d4e804" } -func (*RdmaDeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*RdmaCreate)(nil), "rdma.RdmaCreate") - api.RegisterMessage((*RdmaCreateReply)(nil), "rdma.RdmaCreateReply") - api.RegisterMessage((*RdmaDelete)(nil), "rdma.RdmaDelete") - api.RegisterMessage((*RdmaDeleteReply)(nil), "rdma.RdmaDeleteReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*RdmaCreate)(nil), - (*RdmaCreateReply)(nil), - (*RdmaDelete)(nil), - (*RdmaDeleteReply)(nil), - } -} - -// RPCService represents RPC service API for rdma module. -type RPCService interface { - RdmaCreate(ctx context.Context, in *RdmaCreate) (*RdmaCreateReply, error) - RdmaDelete(ctx context.Context, in *RdmaDelete) (*RdmaDeleteReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) RdmaCreate(ctx context.Context, in *RdmaCreate) (*RdmaCreateReply, error) { - out := new(RdmaCreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) RdmaDelete(ctx context.Context, in *RdmaDelete) (*RdmaDeleteReply, error) { - out := new(RdmaDeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/span/span.ba.go b/plugins/vpp/binapi/vpp2001/span/span.ba.go deleted file mode 100644 index 32b47206ed..0000000000 --- a/plugins/vpp/binapi/vpp2001/span/span.ba.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/span.api.json - -/* -Package span is a generated VPP binary API for 'span' module. - -It consists of: - 4 messages - 2 services -*/ -package span - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "span" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x10769b5 -) - -// SwInterfaceSpanDetails represents VPP binary API message 'sw_interface_span_details'. -type SwInterfaceSpanDetails struct { - SwIfIndexFrom uint32 - SwIfIndexTo uint32 - State uint8 - IsL2 uint8 -} - -func (m *SwInterfaceSpanDetails) Reset() { *m = SwInterfaceSpanDetails{} } -func (*SwInterfaceSpanDetails) GetMessageName() string { return "sw_interface_span_details" } -func (*SwInterfaceSpanDetails) GetCrcString() string { return "23966371" } -func (*SwInterfaceSpanDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceSpanDump represents VPP binary API message 'sw_interface_span_dump'. -type SwInterfaceSpanDump struct { - IsL2 uint8 -} - -func (m *SwInterfaceSpanDump) Reset() { *m = SwInterfaceSpanDump{} } -func (*SwInterfaceSpanDump) GetMessageName() string { return "sw_interface_span_dump" } -func (*SwInterfaceSpanDump) GetCrcString() string { return "67c54650" } -func (*SwInterfaceSpanDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSpanEnableDisable represents VPP binary API message 'sw_interface_span_enable_disable'. -type SwInterfaceSpanEnableDisable struct { - SwIfIndexFrom uint32 - SwIfIndexTo uint32 - State uint8 - IsL2 uint8 -} - -func (m *SwInterfaceSpanEnableDisable) Reset() { *m = SwInterfaceSpanEnableDisable{} } -func (*SwInterfaceSpanEnableDisable) GetMessageName() string { - return "sw_interface_span_enable_disable" -} -func (*SwInterfaceSpanEnableDisable) GetCrcString() string { return "7216258d" } -func (*SwInterfaceSpanEnableDisable) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSpanEnableDisableReply represents VPP binary API message 'sw_interface_span_enable_disable_reply'. -type SwInterfaceSpanEnableDisableReply struct { - Retval int32 -} - -func (m *SwInterfaceSpanEnableDisableReply) Reset() { *m = SwInterfaceSpanEnableDisableReply{} } -func (*SwInterfaceSpanEnableDisableReply) GetMessageName() string { - return "sw_interface_span_enable_disable_reply" -} -func (*SwInterfaceSpanEnableDisableReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSpanEnableDisableReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*SwInterfaceSpanDetails)(nil), "span.SwInterfaceSpanDetails") - api.RegisterMessage((*SwInterfaceSpanDump)(nil), "span.SwInterfaceSpanDump") - api.RegisterMessage((*SwInterfaceSpanEnableDisable)(nil), "span.SwInterfaceSpanEnableDisable") - api.RegisterMessage((*SwInterfaceSpanEnableDisableReply)(nil), "span.SwInterfaceSpanEnableDisableReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*SwInterfaceSpanDetails)(nil), - (*SwInterfaceSpanDump)(nil), - (*SwInterfaceSpanEnableDisable)(nil), - (*SwInterfaceSpanEnableDisableReply)(nil), - } -} - -// RPCService represents RPC service API for span module. -type RPCService interface { - DumpSwInterfaceSpan(ctx context.Context, in *SwInterfaceSpanDump) (RPCService_DumpSwInterfaceSpanClient, error) - SwInterfaceSpanEnableDisable(ctx context.Context, in *SwInterfaceSpanEnableDisable) (*SwInterfaceSpanEnableDisableReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpSwInterfaceSpan(ctx context.Context, in *SwInterfaceSpanDump) (RPCService_DumpSwInterfaceSpanClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceSpanClient{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceSpanClient interface { - Recv() (*SwInterfaceSpanDetails, error) -} - -type serviceClient_DumpSwInterfaceSpanClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSwInterfaceSpanClient) Recv() (*SwInterfaceSpanDetails, error) { - m := new(SwInterfaceSpanDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) SwInterfaceSpanEnableDisable(ctx context.Context, in *SwInterfaceSpanEnableDisable) (*SwInterfaceSpanEnableDisableReply, error) { - out := new(SwInterfaceSpanEnableDisableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/sr.patch b/plugins/vpp/binapi/vpp2001/sr.patch deleted file mode 100644 index f62f1a352e..0000000000 --- a/plugins/vpp/binapi/vpp2001/sr.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/plugins/vpp/binapi/vpp2001/sr/sr.ba.go b/plugins/vpp/binapi/vpp2001/sr/sr.ba.go -index 775dac6f4..c2847d341 100644 ---- a/plugins/vpp/binapi/vpp2001/sr/sr.ba.go -+++ b/plugins/vpp/binapi/vpp2001/sr/sr.ba.go -@@ -49,9 +49,9 @@ func (*Srv6Sid) GetTypeName() string { - - // Srv6SidList represents VPP binary API type 'srv6_sid_list'. - type Srv6SidList struct { -- NumSids uint8 -+ NumSids uint8 `struc:"sizeof=Sids"` - Weight uint32 -- Sids []Srv6Sid `struc:"[16]Srv6Sid"` -+ Sids []Srv6Sid - } - - func (*Srv6SidList) GetTypeName() string { diff --git a/plugins/vpp/binapi/vpp2001/sr/sr.ba.go b/plugins/vpp/binapi/vpp2001/sr/sr.ba.go deleted file mode 100644 index cd110881ec..0000000000 --- a/plugins/vpp/binapi/vpp2001/sr/sr.ba.go +++ /dev/null @@ -1,518 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/sr.api.json - -/* -Package sr is a generated VPP binary API for 'sr' module. - -It consists of: - 3 types - 20 messages - 10 services -*/ -package sr - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "sr" - // APIVersion is the API version of this module. - APIVersion = "1.2.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xbf277f96 -) - -// SrIP6Address represents VPP binary API type 'sr_ip6_address'. -type SrIP6Address struct { - Data []byte `struc:"[16]byte"` -} - -func (*SrIP6Address) GetTypeName() string { return "sr_ip6_address" } - -// Srv6Sid represents VPP binary API type 'srv6_sid'. -type Srv6Sid struct { - Addr []byte `struc:"[16]byte"` -} - -func (*Srv6Sid) GetTypeName() string { return "srv6_sid" } - -// Srv6SidList represents VPP binary API type 'srv6_sid_list'. -type Srv6SidList struct { - NumSids uint8 `struc:"sizeof=Sids"` - Weight uint32 - Sids []Srv6Sid -} - -func (*Srv6SidList) GetTypeName() string { return "srv6_sid_list" } - -// SrLocalsidAddDel represents VPP binary API message 'sr_localsid_add_del'. -type SrLocalsidAddDel struct { - IsDel uint8 - Localsid Srv6Sid - EndPsp uint8 - Behavior uint8 - SwIfIndex uint32 - VlanIndex uint32 - FibTable uint32 - NhAddr6 []byte `struc:"[16]byte"` - NhAddr4 []byte `struc:"[4]byte"` -} - -func (m *SrLocalsidAddDel) Reset() { *m = SrLocalsidAddDel{} } -func (*SrLocalsidAddDel) GetMessageName() string { return "sr_localsid_add_del" } -func (*SrLocalsidAddDel) GetCrcString() string { return "b30489eb" } -func (*SrLocalsidAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrLocalsidAddDelReply represents VPP binary API message 'sr_localsid_add_del_reply'. -type SrLocalsidAddDelReply struct { - Retval int32 -} - -func (m *SrLocalsidAddDelReply) Reset() { *m = SrLocalsidAddDelReply{} } -func (*SrLocalsidAddDelReply) GetMessageName() string { return "sr_localsid_add_del_reply" } -func (*SrLocalsidAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*SrLocalsidAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrLocalsidsDetails represents VPP binary API message 'sr_localsids_details'. -type SrLocalsidsDetails struct { - Addr Srv6Sid - EndPsp uint8 - Behavior uint16 - FibTable uint32 - VlanIndex uint32 - XconnectNhAddr6 []byte `struc:"[16]byte"` - XconnectNhAddr4 []byte `struc:"[4]byte"` - XconnectIfaceOrVrfTable uint32 -} - -func (m *SrLocalsidsDetails) Reset() { *m = SrLocalsidsDetails{} } -func (*SrLocalsidsDetails) GetMessageName() string { return "sr_localsids_details" } -func (*SrLocalsidsDetails) GetCrcString() string { return "0791babc" } -func (*SrLocalsidsDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrLocalsidsDump represents VPP binary API message 'sr_localsids_dump'. -type SrLocalsidsDump struct{} - -func (m *SrLocalsidsDump) Reset() { *m = SrLocalsidsDump{} } -func (*SrLocalsidsDump) GetMessageName() string { return "sr_localsids_dump" } -func (*SrLocalsidsDump) GetCrcString() string { return "51077d14" } -func (*SrLocalsidsDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrPoliciesDetails represents VPP binary API message 'sr_policies_details'. -type SrPoliciesDetails struct { - Bsid Srv6Sid - Type uint8 - IsEncap uint8 - FibTable uint32 - NumSidLists uint8 `struc:"sizeof=SidLists"` - SidLists []Srv6SidList -} - -func (m *SrPoliciesDetails) Reset() { *m = SrPoliciesDetails{} } -func (*SrPoliciesDetails) GetMessageName() string { return "sr_policies_details" } -func (*SrPoliciesDetails) GetCrcString() string { return "5087f460" } -func (*SrPoliciesDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrPoliciesDump represents VPP binary API message 'sr_policies_dump'. -type SrPoliciesDump struct{} - -func (m *SrPoliciesDump) Reset() { *m = SrPoliciesDump{} } -func (*SrPoliciesDump) GetMessageName() string { return "sr_policies_dump" } -func (*SrPoliciesDump) GetCrcString() string { return "51077d14" } -func (*SrPoliciesDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrPolicyAdd represents VPP binary API message 'sr_policy_add'. -type SrPolicyAdd struct { - BsidAddr []byte `struc:"[16]byte"` - Weight uint32 - IsEncap uint8 - Type uint8 - FibTable uint32 - Sids Srv6SidList -} - -func (m *SrPolicyAdd) Reset() { *m = SrPolicyAdd{} } -func (*SrPolicyAdd) GetMessageName() string { return "sr_policy_add" } -func (*SrPolicyAdd) GetCrcString() string { return "4b6e2484" } -func (*SrPolicyAdd) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrPolicyAddReply represents VPP binary API message 'sr_policy_add_reply'. -type SrPolicyAddReply struct { - Retval int32 -} - -func (m *SrPolicyAddReply) Reset() { *m = SrPolicyAddReply{} } -func (*SrPolicyAddReply) GetMessageName() string { return "sr_policy_add_reply" } -func (*SrPolicyAddReply) GetCrcString() string { return "e8d4e804" } -func (*SrPolicyAddReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrPolicyDel represents VPP binary API message 'sr_policy_del'. -type SrPolicyDel struct { - BsidAddr Srv6Sid - SrPolicyIndex uint32 -} - -func (m *SrPolicyDel) Reset() { *m = SrPolicyDel{} } -func (*SrPolicyDel) GetMessageName() string { return "sr_policy_del" } -func (*SrPolicyDel) GetCrcString() string { return "e4133171" } -func (*SrPolicyDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrPolicyDelReply represents VPP binary API message 'sr_policy_del_reply'. -type SrPolicyDelReply struct { - Retval int32 -} - -func (m *SrPolicyDelReply) Reset() { *m = SrPolicyDelReply{} } -func (*SrPolicyDelReply) GetMessageName() string { return "sr_policy_del_reply" } -func (*SrPolicyDelReply) GetCrcString() string { return "e8d4e804" } -func (*SrPolicyDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrPolicyMod represents VPP binary API message 'sr_policy_mod'. -type SrPolicyMod struct { - BsidAddr []byte `struc:"[16]byte"` - SrPolicyIndex uint32 - FibTable uint32 - Operation uint8 - SlIndex uint32 - Weight uint32 - Sids Srv6SidList -} - -func (m *SrPolicyMod) Reset() { *m = SrPolicyMod{} } -func (*SrPolicyMod) GetMessageName() string { return "sr_policy_mod" } -func (*SrPolicyMod) GetCrcString() string { return "c1dfaee0" } -func (*SrPolicyMod) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrPolicyModReply represents VPP binary API message 'sr_policy_mod_reply'. -type SrPolicyModReply struct { - Retval int32 -} - -func (m *SrPolicyModReply) Reset() { *m = SrPolicyModReply{} } -func (*SrPolicyModReply) GetMessageName() string { return "sr_policy_mod_reply" } -func (*SrPolicyModReply) GetCrcString() string { return "e8d4e804" } -func (*SrPolicyModReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrSetEncapHopLimit represents VPP binary API message 'sr_set_encap_hop_limit'. -type SrSetEncapHopLimit struct { - HopLimit uint8 -} - -func (m *SrSetEncapHopLimit) Reset() { *m = SrSetEncapHopLimit{} } -func (*SrSetEncapHopLimit) GetMessageName() string { return "sr_set_encap_hop_limit" } -func (*SrSetEncapHopLimit) GetCrcString() string { return "aa75d7d0" } -func (*SrSetEncapHopLimit) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrSetEncapHopLimitReply represents VPP binary API message 'sr_set_encap_hop_limit_reply'. -type SrSetEncapHopLimitReply struct { - Retval int32 -} - -func (m *SrSetEncapHopLimitReply) Reset() { *m = SrSetEncapHopLimitReply{} } -func (*SrSetEncapHopLimitReply) GetMessageName() string { return "sr_set_encap_hop_limit_reply" } -func (*SrSetEncapHopLimitReply) GetCrcString() string { return "e8d4e804" } -func (*SrSetEncapHopLimitReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrSetEncapSource represents VPP binary API message 'sr_set_encap_source'. -type SrSetEncapSource struct { - EncapsSource []byte `struc:"[16]byte"` -} - -func (m *SrSetEncapSource) Reset() { *m = SrSetEncapSource{} } -func (*SrSetEncapSource) GetMessageName() string { return "sr_set_encap_source" } -func (*SrSetEncapSource) GetCrcString() string { return "d05bb4de" } -func (*SrSetEncapSource) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrSetEncapSourceReply represents VPP binary API message 'sr_set_encap_source_reply'. -type SrSetEncapSourceReply struct { - Retval int32 -} - -func (m *SrSetEncapSourceReply) Reset() { *m = SrSetEncapSourceReply{} } -func (*SrSetEncapSourceReply) GetMessageName() string { return "sr_set_encap_source_reply" } -func (*SrSetEncapSourceReply) GetCrcString() string { return "e8d4e804" } -func (*SrSetEncapSourceReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrSteeringAddDel represents VPP binary API message 'sr_steering_add_del'. -type SrSteeringAddDel struct { - IsDel uint8 - BsidAddr []byte `struc:"[16]byte"` - SrPolicyIndex uint32 - TableID uint32 - PrefixAddr []byte `struc:"[16]byte"` - MaskWidth uint32 - SwIfIndex uint32 - TrafficType uint8 -} - -func (m *SrSteeringAddDel) Reset() { *m = SrSteeringAddDel{} } -func (*SrSteeringAddDel) GetMessageName() string { return "sr_steering_add_del" } -func (*SrSteeringAddDel) GetCrcString() string { return "28b5dcab" } -func (*SrSteeringAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -// SrSteeringAddDelReply represents VPP binary API message 'sr_steering_add_del_reply'. -type SrSteeringAddDelReply struct { - Retval int32 -} - -func (m *SrSteeringAddDelReply) Reset() { *m = SrSteeringAddDelReply{} } -func (*SrSteeringAddDelReply) GetMessageName() string { return "sr_steering_add_del_reply" } -func (*SrSteeringAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*SrSteeringAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrSteeringPolDetails represents VPP binary API message 'sr_steering_pol_details'. -type SrSteeringPolDetails struct { - TrafficType uint8 - FibTable uint32 - PrefixAddr []byte `struc:"[16]byte"` - MaskWidth uint32 - SwIfIndex uint32 - Bsid Srv6Sid -} - -func (m *SrSteeringPolDetails) Reset() { *m = SrSteeringPolDetails{} } -func (*SrSteeringPolDetails) GetMessageName() string { return "sr_steering_pol_details" } -func (*SrSteeringPolDetails) GetCrcString() string { return "5627d483" } -func (*SrSteeringPolDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SrSteeringPolDump represents VPP binary API message 'sr_steering_pol_dump'. -type SrSteeringPolDump struct{} - -func (m *SrSteeringPolDump) Reset() { *m = SrSteeringPolDump{} } -func (*SrSteeringPolDump) GetMessageName() string { return "sr_steering_pol_dump" } -func (*SrSteeringPolDump) GetCrcString() string { return "51077d14" } -func (*SrSteeringPolDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*SrLocalsidAddDel)(nil), "sr.SrLocalsidAddDel") - api.RegisterMessage((*SrLocalsidAddDelReply)(nil), "sr.SrLocalsidAddDelReply") - api.RegisterMessage((*SrLocalsidsDetails)(nil), "sr.SrLocalsidsDetails") - api.RegisterMessage((*SrLocalsidsDump)(nil), "sr.SrLocalsidsDump") - api.RegisterMessage((*SrPoliciesDetails)(nil), "sr.SrPoliciesDetails") - api.RegisterMessage((*SrPoliciesDump)(nil), "sr.SrPoliciesDump") - api.RegisterMessage((*SrPolicyAdd)(nil), "sr.SrPolicyAdd") - api.RegisterMessage((*SrPolicyAddReply)(nil), "sr.SrPolicyAddReply") - api.RegisterMessage((*SrPolicyDel)(nil), "sr.SrPolicyDel") - api.RegisterMessage((*SrPolicyDelReply)(nil), "sr.SrPolicyDelReply") - api.RegisterMessage((*SrPolicyMod)(nil), "sr.SrPolicyMod") - api.RegisterMessage((*SrPolicyModReply)(nil), "sr.SrPolicyModReply") - api.RegisterMessage((*SrSetEncapHopLimit)(nil), "sr.SrSetEncapHopLimit") - api.RegisterMessage((*SrSetEncapHopLimitReply)(nil), "sr.SrSetEncapHopLimitReply") - api.RegisterMessage((*SrSetEncapSource)(nil), "sr.SrSetEncapSource") - api.RegisterMessage((*SrSetEncapSourceReply)(nil), "sr.SrSetEncapSourceReply") - api.RegisterMessage((*SrSteeringAddDel)(nil), "sr.SrSteeringAddDel") - api.RegisterMessage((*SrSteeringAddDelReply)(nil), "sr.SrSteeringAddDelReply") - api.RegisterMessage((*SrSteeringPolDetails)(nil), "sr.SrSteeringPolDetails") - api.RegisterMessage((*SrSteeringPolDump)(nil), "sr.SrSteeringPolDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*SrLocalsidAddDel)(nil), - (*SrLocalsidAddDelReply)(nil), - (*SrLocalsidsDetails)(nil), - (*SrLocalsidsDump)(nil), - (*SrPoliciesDetails)(nil), - (*SrPoliciesDump)(nil), - (*SrPolicyAdd)(nil), - (*SrPolicyAddReply)(nil), - (*SrPolicyDel)(nil), - (*SrPolicyDelReply)(nil), - (*SrPolicyMod)(nil), - (*SrPolicyModReply)(nil), - (*SrSetEncapHopLimit)(nil), - (*SrSetEncapHopLimitReply)(nil), - (*SrSetEncapSource)(nil), - (*SrSetEncapSourceReply)(nil), - (*SrSteeringAddDel)(nil), - (*SrSteeringAddDelReply)(nil), - (*SrSteeringPolDetails)(nil), - (*SrSteeringPolDump)(nil), - } -} - -// RPCService represents RPC service API for sr module. -type RPCService interface { - DumpSrLocalsids(ctx context.Context, in *SrLocalsidsDump) (RPCService_DumpSrLocalsidsClient, error) - DumpSrPolicies(ctx context.Context, in *SrPoliciesDump) (RPCService_DumpSrPoliciesClient, error) - DumpSrSteeringPol(ctx context.Context, in *SrSteeringPolDump) (RPCService_DumpSrSteeringPolClient, error) - SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddDel) (*SrLocalsidAddDelReply, error) - SrPolicyAdd(ctx context.Context, in *SrPolicyAdd) (*SrPolicyAddReply, error) - SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPolicyDelReply, error) - SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPolicyModReply, error) - SrSetEncapHopLimit(ctx context.Context, in *SrSetEncapHopLimit) (*SrSetEncapHopLimitReply, error) - SrSetEncapSource(ctx context.Context, in *SrSetEncapSource) (*SrSetEncapSourceReply, error) - SrSteeringAddDel(ctx context.Context, in *SrSteeringAddDel) (*SrSteeringAddDelReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpSrLocalsids(ctx context.Context, in *SrLocalsidsDump) (RPCService_DumpSrLocalsidsClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSrLocalsidsClient{stream} - return x, nil -} - -type RPCService_DumpSrLocalsidsClient interface { - Recv() (*SrLocalsidsDetails, error) -} - -type serviceClient_DumpSrLocalsidsClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSrLocalsidsClient) Recv() (*SrLocalsidsDetails, error) { - m := new(SrLocalsidsDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpSrPolicies(ctx context.Context, in *SrPoliciesDump) (RPCService_DumpSrPoliciesClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSrPoliciesClient{stream} - return x, nil -} - -type RPCService_DumpSrPoliciesClient interface { - Recv() (*SrPoliciesDetails, error) -} - -type serviceClient_DumpSrPoliciesClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSrPoliciesClient) Recv() (*SrPoliciesDetails, error) { - m := new(SrPoliciesDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpSrSteeringPol(ctx context.Context, in *SrSteeringPolDump) (RPCService_DumpSrSteeringPolClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSrSteeringPolClient{stream} - return x, nil -} - -type RPCService_DumpSrSteeringPolClient interface { - Recv() (*SrSteeringPolDetails, error) -} - -type serviceClient_DumpSrSteeringPolClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSrSteeringPolClient) Recv() (*SrSteeringPolDetails, error) { - m := new(SrSteeringPolDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) SrLocalsidAddDel(ctx context.Context, in *SrLocalsidAddDel) (*SrLocalsidAddDelReply, error) { - out := new(SrLocalsidAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SrPolicyAdd(ctx context.Context, in *SrPolicyAdd) (*SrPolicyAddReply, error) { - out := new(SrPolicyAddReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SrPolicyDel(ctx context.Context, in *SrPolicyDel) (*SrPolicyDelReply, error) { - out := new(SrPolicyDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SrPolicyMod(ctx context.Context, in *SrPolicyMod) (*SrPolicyModReply, error) { - out := new(SrPolicyModReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SrSetEncapHopLimit(ctx context.Context, in *SrSetEncapHopLimit) (*SrSetEncapHopLimitReply, error) { - out := new(SrSetEncapHopLimitReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SrSetEncapSource(ctx context.Context, in *SrSetEncapSource) (*SrSetEncapSourceReply, error) { - out := new(SrSetEncapSourceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) SrSteeringAddDel(ctx context.Context, in *SrSteeringAddDel) (*SrSteeringAddDelReply, error) { - out := new(SrSteeringAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/stn/stn.ba.go b/plugins/vpp/binapi/vpp2001/stn/stn.ba.go deleted file mode 100644 index 3220aca4c6..0000000000 --- a/plugins/vpp/binapi/vpp2001/stn/stn.ba.go +++ /dev/null @@ -1,204 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/stn.api.json - -/* -Package stn is a generated VPP binary API for 'stn' module. - -It consists of: - 10 enums - 6 aliases - 6 types - 1 union - 4 messages - 2 services -*/ -package stn - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "stn" - // APIVersion is the API version of this module. - APIVersion = "2.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x619d8f3 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// StnAddDelRule represents VPP binary API message 'stn_add_del_rule'. -type StnAddDelRule struct { - IPAddress Address - SwIfIndex InterfaceIndex - IsAdd bool -} - -func (m *StnAddDelRule) Reset() { *m = StnAddDelRule{} } -func (*StnAddDelRule) GetMessageName() string { return "stn_add_del_rule" } -func (*StnAddDelRule) GetCrcString() string { return "53f751e6" } -func (*StnAddDelRule) GetMessageType() api.MessageType { return api.RequestMessage } - -// StnAddDelRuleReply represents VPP binary API message 'stn_add_del_rule_reply'. -type StnAddDelRuleReply struct { - Retval int32 -} - -func (m *StnAddDelRuleReply) Reset() { *m = StnAddDelRuleReply{} } -func (*StnAddDelRuleReply) GetMessageName() string { return "stn_add_del_rule_reply" } -func (*StnAddDelRuleReply) GetCrcString() string { return "e8d4e804" } -func (*StnAddDelRuleReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// StnRulesDetails represents VPP binary API message 'stn_rules_details'. -type StnRulesDetails struct { - IPAddress Address - SwIfIndex InterfaceIndex -} - -func (m *StnRulesDetails) Reset() { *m = StnRulesDetails{} } -func (*StnRulesDetails) GetMessageName() string { return "stn_rules_details" } -func (*StnRulesDetails) GetCrcString() string { return "b0f6606c" } -func (*StnRulesDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// StnRulesDump represents VPP binary API message 'stn_rules_dump'. -type StnRulesDump struct{} - -func (m *StnRulesDump) Reset() { *m = StnRulesDump{} } -func (*StnRulesDump) GetMessageName() string { return "stn_rules_dump" } -func (*StnRulesDump) GetCrcString() string { return "51077d14" } -func (*StnRulesDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*StnAddDelRule)(nil), "stn.StnAddDelRule") - api.RegisterMessage((*StnAddDelRuleReply)(nil), "stn.StnAddDelRuleReply") - api.RegisterMessage((*StnRulesDetails)(nil), "stn.StnRulesDetails") - api.RegisterMessage((*StnRulesDump)(nil), "stn.StnRulesDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*StnAddDelRule)(nil), - (*StnAddDelRuleReply)(nil), - (*StnRulesDetails)(nil), - (*StnRulesDump)(nil), - } -} - -// RPCService represents RPC service API for stn module. -type RPCService interface { - DumpStnRules(ctx context.Context, in *StnRulesDump) (RPCService_DumpStnRulesClient, error) - StnAddDelRule(ctx context.Context, in *StnAddDelRule) (*StnAddDelRuleReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpStnRules(ctx context.Context, in *StnRulesDump) (RPCService_DumpStnRulesClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpStnRulesClient{stream} - return x, nil -} - -type RPCService_DumpStnRulesClient interface { - Recv() (*StnRulesDetails, error) -} - -type serviceClient_DumpStnRulesClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpStnRulesClient) Recv() (*StnRulesDetails, error) { - m := new(StnRulesDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) StnAddDelRule(ctx context.Context, in *StnAddDelRule) (*StnAddDelRuleReply, error) { - out := new(StnAddDelRuleReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/tapv2/tapv2.ba.go b/plugins/vpp/binapi/vpp2001/tapv2/tapv2.ba.go deleted file mode 100644 index 8a84d6334b..0000000000 --- a/plugins/vpp/binapi/vpp2001/tapv2/tapv2.ba.go +++ /dev/null @@ -1,305 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/tapv2.api.json - -/* -Package tapv2 is a generated VPP binary API for 'tapv2' module. - -It consists of: - 11 enums - 7 aliases - 6 types - 1 union - 6 messages - 3 services -*/ -package tapv2 - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ip_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "tapv2" - // APIVersion is the API version of this module. - APIVersion = "3.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x7d58f9a4 -) - -type AddressFamily = ip_types.AddressFamily - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type IPDscp = ip_types.IPDscp - -type IPEcn = ip_types.IPEcn - -type IPProto = ip_types.IPProto - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -// TapFlags represents VPP binary API enum 'tap_flags'. -type TapFlags uint32 - -const ( - TAP_FLAG_GSO TapFlags = 1 - TAP_FLAG_CSUM_OFFLOAD TapFlags = 2 -) - -var TapFlags_name = map[uint32]string{ - 1: "TAP_FLAG_GSO", - 2: "TAP_FLAG_CSUM_OFFLOAD", -} - -var TapFlags_value = map[string]uint32{ - "TAP_FLAG_GSO": 1, - "TAP_FLAG_CSUM_OFFLOAD": 2, -} - -func (x TapFlags) String() string { - s, ok := TapFlags_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -type AddressWithPrefix = ip_types.AddressWithPrefix - -type InterfaceIndex = interface_types.InterfaceIndex - -type IP4Address = ip_types.IP4Address - -type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix - -type IP6Address = ip_types.IP6Address - -type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix - -type MacAddress = ethernet_types.MacAddress - -type Address = ip_types.Address - -type IP4Prefix = ip_types.IP4Prefix - -type IP6Prefix = ip_types.IP6Prefix - -type Mprefix = ip_types.Mprefix - -type Prefix = ip_types.Prefix - -type PrefixMatcher = ip_types.PrefixMatcher - -type AddressUnion = ip_types.AddressUnion - -// SwInterfaceTapV2Details represents VPP binary API message 'sw_interface_tap_v2_details'. -type SwInterfaceTapV2Details struct { - SwIfIndex uint32 - ID uint32 - TxRingSz uint16 - RxRingSz uint16 - HostMtuSize uint32 - HostMacAddr MacAddress - HostIP4Prefix IP4AddressWithPrefix - HostIP6Prefix IP6AddressWithPrefix - TapFlags TapFlags - DevName string `struc:"[64]byte"` - HostIfName string `struc:"[64]byte"` - HostNamespace string `struc:"[64]byte"` - HostBridge string `struc:"[64]byte"` -} - -func (m *SwInterfaceTapV2Details) Reset() { *m = SwInterfaceTapV2Details{} } -func (*SwInterfaceTapV2Details) GetMessageName() string { return "sw_interface_tap_v2_details" } -func (*SwInterfaceTapV2Details) GetCrcString() string { return "e53c16de" } -func (*SwInterfaceTapV2Details) GetMessageType() api.MessageType { return api.ReplyMessage } - -// SwInterfaceTapV2Dump represents VPP binary API message 'sw_interface_tap_v2_dump'. -type SwInterfaceTapV2Dump struct { - SwIfIndex InterfaceIndex -} - -func (m *SwInterfaceTapV2Dump) Reset() { *m = SwInterfaceTapV2Dump{} } -func (*SwInterfaceTapV2Dump) GetMessageName() string { return "sw_interface_tap_v2_dump" } -func (*SwInterfaceTapV2Dump) GetCrcString() string { return "f9e6675e" } -func (*SwInterfaceTapV2Dump) GetMessageType() api.MessageType { return api.RequestMessage } - -// TapCreateV2 represents VPP binary API message 'tap_create_v2'. -type TapCreateV2 struct { - ID uint32 - UseRandomMac bool - MacAddress MacAddress - NumRxQueues uint8 - TxRingSz uint16 - RxRingSz uint16 - HostMtuSet bool - HostMtuSize uint32 - HostMacAddrSet bool - HostMacAddr MacAddress - HostIP4PrefixSet bool - HostIP4Prefix IP4AddressWithPrefix - HostIP6PrefixSet bool - HostIP6Prefix IP6AddressWithPrefix - HostIP4GwSet bool - HostIP4Gw IP4Address - HostIP6GwSet bool - HostIP6Gw IP6Address - TapFlags TapFlags - HostNamespaceSet bool - HostNamespace string `struc:"[64]byte"` - HostIfNameSet bool - HostIfName string `struc:"[64]byte"` - HostBridgeSet bool - HostBridge string `struc:"[64]byte"` - XXX_TagLen uint32 `struc:"sizeof=Tag"` - Tag string -} - -func (m *TapCreateV2) Reset() { *m = TapCreateV2{} } -func (*TapCreateV2) GetMessageName() string { return "tap_create_v2" } -func (*TapCreateV2) GetCrcString() string { return "445835fd" } -func (*TapCreateV2) GetMessageType() api.MessageType { return api.RequestMessage } - -// TapCreateV2Reply represents VPP binary API message 'tap_create_v2_reply'. -type TapCreateV2Reply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *TapCreateV2Reply) Reset() { *m = TapCreateV2Reply{} } -func (*TapCreateV2Reply) GetMessageName() string { return "tap_create_v2_reply" } -func (*TapCreateV2Reply) GetCrcString() string { return "5383d31f" } -func (*TapCreateV2Reply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// TapDeleteV2 represents VPP binary API message 'tap_delete_v2'. -type TapDeleteV2 struct { - SwIfIndex InterfaceIndex -} - -func (m *TapDeleteV2) Reset() { *m = TapDeleteV2{} } -func (*TapDeleteV2) GetMessageName() string { return "tap_delete_v2" } -func (*TapDeleteV2) GetCrcString() string { return "f9e6675e" } -func (*TapDeleteV2) GetMessageType() api.MessageType { return api.RequestMessage } - -// TapDeleteV2Reply represents VPP binary API message 'tap_delete_v2_reply'. -type TapDeleteV2Reply struct { - Retval int32 -} - -func (m *TapDeleteV2Reply) Reset() { *m = TapDeleteV2Reply{} } -func (*TapDeleteV2Reply) GetMessageName() string { return "tap_delete_v2_reply" } -func (*TapDeleteV2Reply) GetCrcString() string { return "e8d4e804" } -func (*TapDeleteV2Reply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*SwInterfaceTapV2Details)(nil), "tapv2.SwInterfaceTapV2Details") - api.RegisterMessage((*SwInterfaceTapV2Dump)(nil), "tapv2.SwInterfaceTapV2Dump") - api.RegisterMessage((*TapCreateV2)(nil), "tapv2.TapCreateV2") - api.RegisterMessage((*TapCreateV2Reply)(nil), "tapv2.TapCreateV2Reply") - api.RegisterMessage((*TapDeleteV2)(nil), "tapv2.TapDeleteV2") - api.RegisterMessage((*TapDeleteV2Reply)(nil), "tapv2.TapDeleteV2Reply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*SwInterfaceTapV2Details)(nil), - (*SwInterfaceTapV2Dump)(nil), - (*TapCreateV2)(nil), - (*TapCreateV2Reply)(nil), - (*TapDeleteV2)(nil), - (*TapDeleteV2Reply)(nil), - } -} - -// RPCService represents RPC service API for tapv2 module. -type RPCService interface { - DumpSwInterfaceTapV2(ctx context.Context, in *SwInterfaceTapV2Dump) (RPCService_DumpSwInterfaceTapV2Client, error) - TapCreateV2(ctx context.Context, in *TapCreateV2) (*TapCreateV2Reply, error) - TapDeleteV2(ctx context.Context, in *TapDeleteV2) (*TapDeleteV2Reply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpSwInterfaceTapV2(ctx context.Context, in *SwInterfaceTapV2Dump) (RPCService_DumpSwInterfaceTapV2Client, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceTapV2Client{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceTapV2Client interface { - Recv() (*SwInterfaceTapV2Details, error) -} - -type serviceClient_DumpSwInterfaceTapV2Client struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSwInterfaceTapV2Client) Recv() (*SwInterfaceTapV2Details, error) { - m := new(SwInterfaceTapV2Details) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) TapCreateV2(ctx context.Context, in *TapCreateV2) (*TapCreateV2Reply, error) { - out := new(TapCreateV2Reply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) TapDeleteV2(ctx context.Context, in *TapDeleteV2) (*TapDeleteV2Reply, error) { - out := new(TapDeleteV2Reply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/vmxnet3/vmxnet3.ba.go b/plugins/vpp/binapi/vpp2001/vmxnet3/vmxnet3.ba.go deleted file mode 100644 index f5a20c04b0..0000000000 --- a/plugins/vpp/binapi/vpp2001/vmxnet3/vmxnet3.ba.go +++ /dev/null @@ -1,242 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/plugins/vmxnet3.api.json - -/* -Package vmxnet3 is a generated VPP binary API for 'vmxnet3' module. - -It consists of: - 6 enums - 2 aliases - 2 types - 6 messages - 3 services -*/ -package vmxnet3 - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - ethernet_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ethernet_types" - interface_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "vmxnet3" - // APIVersion is the API version of this module. - APIVersion = "1.1.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xe89a60f7 -) - -type IfStatusFlags = interface_types.IfStatusFlags - -type IfType = interface_types.IfType - -type LinkDuplex = interface_types.LinkDuplex - -type MtuProto = interface_types.MtuProto - -type RxMode = interface_types.RxMode - -type SubIfFlags = interface_types.SubIfFlags - -type InterfaceIndex = interface_types.InterfaceIndex - -type MacAddress = ethernet_types.MacAddress - -// Vmxnet3RxList represents VPP binary API type 'vmxnet3_rx_list'. -type Vmxnet3RxList struct { - RxQsize uint16 - RxFill []uint16 `struc:"[2]uint16"` - RxNext uint16 - RxProduce []uint16 `struc:"[2]uint16"` - RxConsume []uint16 `struc:"[2]uint16"` -} - -func (*Vmxnet3RxList) GetTypeName() string { return "vmxnet3_rx_list" } - -// Vmxnet3TxList represents VPP binary API type 'vmxnet3_tx_list'. -type Vmxnet3TxList struct { - TxQsize uint16 - TxNext uint16 - TxProduce uint16 - TxConsume uint16 -} - -func (*Vmxnet3TxList) GetTypeName() string { return "vmxnet3_tx_list" } - -// Vmxnet3Create represents VPP binary API message 'vmxnet3_create'. -type Vmxnet3Create struct { - PciAddr uint32 - EnableElog int32 - RxqSize uint16 - RxqNum uint16 - TxqSize uint16 - TxqNum uint16 - Bind uint8 - EnableGso bool -} - -func (m *Vmxnet3Create) Reset() { *m = Vmxnet3Create{} } -func (*Vmxnet3Create) GetMessageName() string { return "vmxnet3_create" } -func (*Vmxnet3Create) GetCrcString() string { return "71a07314" } -func (*Vmxnet3Create) GetMessageType() api.MessageType { return api.RequestMessage } - -// Vmxnet3CreateReply represents VPP binary API message 'vmxnet3_create_reply'. -type Vmxnet3CreateReply struct { - Retval int32 - SwIfIndex InterfaceIndex -} - -func (m *Vmxnet3CreateReply) Reset() { *m = Vmxnet3CreateReply{} } -func (*Vmxnet3CreateReply) GetMessageName() string { return "vmxnet3_create_reply" } -func (*Vmxnet3CreateReply) GetCrcString() string { return "5383d31f" } -func (*Vmxnet3CreateReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Vmxnet3Delete represents VPP binary API message 'vmxnet3_delete'. -type Vmxnet3Delete struct { - SwIfIndex InterfaceIndex -} - -func (m *Vmxnet3Delete) Reset() { *m = Vmxnet3Delete{} } -func (*Vmxnet3Delete) GetMessageName() string { return "vmxnet3_delete" } -func (*Vmxnet3Delete) GetCrcString() string { return "f9e6675e" } -func (*Vmxnet3Delete) GetMessageType() api.MessageType { return api.RequestMessage } - -// Vmxnet3DeleteReply represents VPP binary API message 'vmxnet3_delete_reply'. -type Vmxnet3DeleteReply struct { - Retval int32 -} - -func (m *Vmxnet3DeleteReply) Reset() { *m = Vmxnet3DeleteReply{} } -func (*Vmxnet3DeleteReply) GetMessageName() string { return "vmxnet3_delete_reply" } -func (*Vmxnet3DeleteReply) GetCrcString() string { return "e8d4e804" } -func (*Vmxnet3DeleteReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Vmxnet3Details represents VPP binary API message 'vmxnet3_details'. -type Vmxnet3Details struct { - SwIfIndex InterfaceIndex - IfName string `struc:"[64]byte"` - HwAddr MacAddress - PciAddr uint32 - Version uint8 - AdminUpDown bool - RxCount uint8 - RxList []Vmxnet3RxList `struc:"[16]Vmxnet3RxList"` - TxCount uint8 - TxList []Vmxnet3TxList `struc:"[8]Vmxnet3TxList"` -} - -func (m *Vmxnet3Details) Reset() { *m = Vmxnet3Details{} } -func (*Vmxnet3Details) GetMessageName() string { return "vmxnet3_details" } -func (*Vmxnet3Details) GetCrcString() string { return "829ba055" } -func (*Vmxnet3Details) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Vmxnet3Dump represents VPP binary API message 'vmxnet3_dump'. -type Vmxnet3Dump struct{} - -func (m *Vmxnet3Dump) Reset() { *m = Vmxnet3Dump{} } -func (*Vmxnet3Dump) GetMessageName() string { return "vmxnet3_dump" } -func (*Vmxnet3Dump) GetCrcString() string { return "51077d14" } -func (*Vmxnet3Dump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*Vmxnet3Create)(nil), "vmxnet3.Vmxnet3Create") - api.RegisterMessage((*Vmxnet3CreateReply)(nil), "vmxnet3.Vmxnet3CreateReply") - api.RegisterMessage((*Vmxnet3Delete)(nil), "vmxnet3.Vmxnet3Delete") - api.RegisterMessage((*Vmxnet3DeleteReply)(nil), "vmxnet3.Vmxnet3DeleteReply") - api.RegisterMessage((*Vmxnet3Details)(nil), "vmxnet3.Vmxnet3Details") - api.RegisterMessage((*Vmxnet3Dump)(nil), "vmxnet3.Vmxnet3Dump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*Vmxnet3Create)(nil), - (*Vmxnet3CreateReply)(nil), - (*Vmxnet3Delete)(nil), - (*Vmxnet3DeleteReply)(nil), - (*Vmxnet3Details)(nil), - (*Vmxnet3Dump)(nil), - } -} - -// RPCService represents RPC service API for vmxnet3 module. -type RPCService interface { - DumpVmxnet3(ctx context.Context, in *Vmxnet3Dump) (RPCService_DumpVmxnet3Client, error) - Vmxnet3Create(ctx context.Context, in *Vmxnet3Create) (*Vmxnet3CreateReply, error) - Vmxnet3Delete(ctx context.Context, in *Vmxnet3Delete) (*Vmxnet3DeleteReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpVmxnet3(ctx context.Context, in *Vmxnet3Dump) (RPCService_DumpVmxnet3Client, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpVmxnet3Client{stream} - return x, nil -} - -type RPCService_DumpVmxnet3Client interface { - Recv() (*Vmxnet3Details, error) -} - -type serviceClient_DumpVmxnet3Client struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpVmxnet3Client) Recv() (*Vmxnet3Details, error) { - m := new(Vmxnet3Details) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) Vmxnet3Create(ctx context.Context, in *Vmxnet3Create) (*Vmxnet3CreateReply, error) { - out := new(Vmxnet3CreateReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Vmxnet3Delete(ctx context.Context, in *Vmxnet3Delete) (*Vmxnet3DeleteReply, error) { - out := new(Vmxnet3DeleteReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/vpe/vpe.ba.go b/plugins/vpp/binapi/vpp2001/vpe/vpe.ba.go deleted file mode 100644 index 3e1ce76ef9..0000000000 --- a/plugins/vpp/binapi/vpp2001/vpe/vpe.ba.go +++ /dev/null @@ -1,564 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/vpe.api.json - -/* -Package vpe is a generated VPP binary API for 'vpe' module. - -It consists of: - 1 enum - 2 aliases - 2 types - 26 messages - 13 services -*/ -package vpe - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" - - vpe_types "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe_types" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "vpe" - // APIVersion is the API version of this module. - APIVersion = "1.6.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xc6c0bcf6 -) - -type LogLevel = vpe_types.LogLevel - -type Timedelta = vpe_types.Timedelta - -type Timestamp = vpe_types.Timestamp - -// ThreadData represents VPP binary API type 'thread_data'. -type ThreadData struct { - ID uint32 - Name []byte `struc:"[64]byte"` - Type []byte `struc:"[64]byte"` - PID uint32 - CPUID uint32 - Core uint32 - CPUSocket uint32 -} - -func (*ThreadData) GetTypeName() string { return "thread_data" } - -type Version = vpe_types.Version - -// AddNodeNext represents VPP binary API message 'add_node_next'. -type AddNodeNext struct { - NodeName []byte `struc:"[64]byte"` - NextName []byte `struc:"[64]byte"` -} - -func (m *AddNodeNext) Reset() { *m = AddNodeNext{} } -func (*AddNodeNext) GetMessageName() string { return "add_node_next" } -func (*AddNodeNext) GetCrcString() string { return "9ab92f7a" } -func (*AddNodeNext) GetMessageType() api.MessageType { return api.RequestMessage } - -// AddNodeNextReply represents VPP binary API message 'add_node_next_reply'. -type AddNodeNextReply struct { - Retval int32 - NextIndex uint32 -} - -func (m *AddNodeNextReply) Reset() { *m = AddNodeNextReply{} } -func (*AddNodeNextReply) GetMessageName() string { return "add_node_next_reply" } -func (*AddNodeNextReply) GetCrcString() string { return "2ed75f32" } -func (*AddNodeNextReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// Cli represents VPP binary API message 'cli'. -type Cli struct { - CmdInShmem uint64 -} - -func (m *Cli) Reset() { *m = Cli{} } -func (*Cli) GetMessageName() string { return "cli" } -func (*Cli) GetCrcString() string { return "23bfbfff" } -func (*Cli) GetMessageType() api.MessageType { return api.RequestMessage } - -// CliInband represents VPP binary API message 'cli_inband'. -type CliInband struct { - XXX_CmdLen uint32 `struc:"sizeof=Cmd"` - Cmd string -} - -func (m *CliInband) Reset() { *m = CliInband{} } -func (*CliInband) GetMessageName() string { return "cli_inband" } -func (*CliInband) GetCrcString() string { return "f8377302" } -func (*CliInband) GetMessageType() api.MessageType { return api.RequestMessage } - -// CliInbandReply represents VPP binary API message 'cli_inband_reply'. -type CliInbandReply struct { - Retval int32 - XXX_ReplyLen uint32 `struc:"sizeof=Reply"` - Reply string -} - -func (m *CliInbandReply) Reset() { *m = CliInbandReply{} } -func (*CliInbandReply) GetMessageName() string { return "cli_inband_reply" } -func (*CliInbandReply) GetCrcString() string { return "05879051" } -func (*CliInbandReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// CliReply represents VPP binary API message 'cli_reply'. -type CliReply struct { - Retval int32 - ReplyInShmem uint64 -} - -func (m *CliReply) Reset() { *m = CliReply{} } -func (*CliReply) GetMessageName() string { return "cli_reply" } -func (*CliReply) GetCrcString() string { return "06d68297" } -func (*CliReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ControlPing represents VPP binary API message 'control_ping'. -type ControlPing struct{} - -func (m *ControlPing) Reset() { *m = ControlPing{} } -func (*ControlPing) GetMessageName() string { return "control_ping" } -func (*ControlPing) GetCrcString() string { return "51077d14" } -func (*ControlPing) GetMessageType() api.MessageType { return api.RequestMessage } - -// ControlPingReply represents VPP binary API message 'control_ping_reply'. -type ControlPingReply struct { - Retval int32 - ClientIndex uint32 - VpePID uint32 -} - -func (m *ControlPingReply) Reset() { *m = ControlPingReply{} } -func (*ControlPingReply) GetMessageName() string { return "control_ping_reply" } -func (*ControlPingReply) GetCrcString() string { return "f6b0b8ca" } -func (*ControlPingReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GetF64EndianValue represents VPP binary API message 'get_f64_endian_value'. -type GetF64EndianValue struct { - F64One float64 -} - -func (m *GetF64EndianValue) Reset() { *m = GetF64EndianValue{} } -func (*GetF64EndianValue) GetMessageName() string { return "get_f64_endian_value" } -func (*GetF64EndianValue) GetCrcString() string { return "809fcd44" } -func (*GetF64EndianValue) GetMessageType() api.MessageType { return api.RequestMessage } - -// GetF64EndianValueReply represents VPP binary API message 'get_f64_endian_value_reply'. -type GetF64EndianValueReply struct { - Retval uint32 - F64OneResult float64 -} - -func (m *GetF64EndianValueReply) Reset() { *m = GetF64EndianValueReply{} } -func (*GetF64EndianValueReply) GetMessageName() string { return "get_f64_endian_value_reply" } -func (*GetF64EndianValueReply) GetCrcString() string { return "7e02e404" } -func (*GetF64EndianValueReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GetF64IncrementByOne represents VPP binary API message 'get_f64_increment_by_one'. -type GetF64IncrementByOne struct { - F64Value float64 -} - -func (m *GetF64IncrementByOne) Reset() { *m = GetF64IncrementByOne{} } -func (*GetF64IncrementByOne) GetMessageName() string { return "get_f64_increment_by_one" } -func (*GetF64IncrementByOne) GetCrcString() string { return "b64f027e" } -func (*GetF64IncrementByOne) GetMessageType() api.MessageType { return api.RequestMessage } - -// GetF64IncrementByOneReply represents VPP binary API message 'get_f64_increment_by_one_reply'. -type GetF64IncrementByOneReply struct { - Retval uint32 - F64Value float64 -} - -func (m *GetF64IncrementByOneReply) Reset() { *m = GetF64IncrementByOneReply{} } -func (*GetF64IncrementByOneReply) GetMessageName() string { return "get_f64_increment_by_one_reply" } -func (*GetF64IncrementByOneReply) GetCrcString() string { return "d25dbaa3" } -func (*GetF64IncrementByOneReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GetNextIndex represents VPP binary API message 'get_next_index'. -type GetNextIndex struct { - NodeName []byte `struc:"[64]byte"` - NextName []byte `struc:"[64]byte"` -} - -func (m *GetNextIndex) Reset() { *m = GetNextIndex{} } -func (*GetNextIndex) GetMessageName() string { return "get_next_index" } -func (*GetNextIndex) GetCrcString() string { return "9ab92f7a" } -func (*GetNextIndex) GetMessageType() api.MessageType { return api.RequestMessage } - -// GetNextIndexReply represents VPP binary API message 'get_next_index_reply'. -type GetNextIndexReply struct { - Retval int32 - NextIndex uint32 -} - -func (m *GetNextIndexReply) Reset() { *m = GetNextIndexReply{} } -func (*GetNextIndexReply) GetMessageName() string { return "get_next_index_reply" } -func (*GetNextIndexReply) GetCrcString() string { return "2ed75f32" } -func (*GetNextIndexReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GetNodeGraph represents VPP binary API message 'get_node_graph'. -type GetNodeGraph struct{} - -func (m *GetNodeGraph) Reset() { *m = GetNodeGraph{} } -func (*GetNodeGraph) GetMessageName() string { return "get_node_graph" } -func (*GetNodeGraph) GetCrcString() string { return "51077d14" } -func (*GetNodeGraph) GetMessageType() api.MessageType { return api.RequestMessage } - -// GetNodeGraphReply represents VPP binary API message 'get_node_graph_reply'. -type GetNodeGraphReply struct { - Retval int32 - ReplyInShmem uint64 -} - -func (m *GetNodeGraphReply) Reset() { *m = GetNodeGraphReply{} } -func (*GetNodeGraphReply) GetMessageName() string { return "get_node_graph_reply" } -func (*GetNodeGraphReply) GetCrcString() string { return "06d68297" } -func (*GetNodeGraphReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// GetNodeIndex represents VPP binary API message 'get_node_index'. -type GetNodeIndex struct { - NodeName []byte `struc:"[64]byte"` -} - -func (m *GetNodeIndex) Reset() { *m = GetNodeIndex{} } -func (*GetNodeIndex) GetMessageName() string { return "get_node_index" } -func (*GetNodeIndex) GetCrcString() string { return "6c9a495d" } -func (*GetNodeIndex) GetMessageType() api.MessageType { return api.RequestMessage } - -// GetNodeIndexReply represents VPP binary API message 'get_node_index_reply'. -type GetNodeIndexReply struct { - Retval int32 - NodeIndex uint32 -} - -func (m *GetNodeIndexReply) Reset() { *m = GetNodeIndexReply{} } -func (*GetNodeIndexReply) GetMessageName() string { return "get_node_index_reply" } -func (*GetNodeIndexReply) GetCrcString() string { return "a8600b89" } -func (*GetNodeIndexReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// LogDetails represents VPP binary API message 'log_details'. -type LogDetails struct { - Timestamp Timestamp - Level LogLevel - MsgClass string `struc:"[32]byte"` - Message string `struc:"[256]byte"` -} - -func (m *LogDetails) Reset() { *m = LogDetails{} } -func (*LogDetails) GetMessageName() string { return "log_details" } -func (*LogDetails) GetCrcString() string { return "255827a1" } -func (*LogDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// LogDump represents VPP binary API message 'log_dump'. -type LogDump struct { - StartTimestamp Timestamp -} - -func (m *LogDump) Reset() { *m = LogDump{} } -func (*LogDump) GetMessageName() string { return "log_dump" } -func (*LogDump) GetCrcString() string { return "6ab31753" } -func (*LogDump) GetMessageType() api.MessageType { return api.RequestMessage } - -// ShowThreads represents VPP binary API message 'show_threads'. -type ShowThreads struct{} - -func (m *ShowThreads) Reset() { *m = ShowThreads{} } -func (*ShowThreads) GetMessageName() string { return "show_threads" } -func (*ShowThreads) GetCrcString() string { return "51077d14" } -func (*ShowThreads) GetMessageType() api.MessageType { return api.RequestMessage } - -// ShowThreadsReply represents VPP binary API message 'show_threads_reply'. -type ShowThreadsReply struct { - Retval int32 - Count uint32 `struc:"sizeof=ThreadData"` - ThreadData []ThreadData -} - -func (m *ShowThreadsReply) Reset() { *m = ShowThreadsReply{} } -func (*ShowThreadsReply) GetMessageName() string { return "show_threads_reply" } -func (*ShowThreadsReply) GetCrcString() string { return "f5e0b66f" } -func (*ShowThreadsReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ShowVersion represents VPP binary API message 'show_version'. -type ShowVersion struct{} - -func (m *ShowVersion) Reset() { *m = ShowVersion{} } -func (*ShowVersion) GetMessageName() string { return "show_version" } -func (*ShowVersion) GetCrcString() string { return "51077d14" } -func (*ShowVersion) GetMessageType() api.MessageType { return api.RequestMessage } - -// ShowVersionReply represents VPP binary API message 'show_version_reply'. -type ShowVersionReply struct { - Retval int32 - Program string `struc:"[32]byte"` - Version string `struc:"[32]byte"` - BuildDate string `struc:"[32]byte"` - BuildDirectory string `struc:"[256]byte"` -} - -func (m *ShowVersionReply) Reset() { *m = ShowVersionReply{} } -func (*ShowVersionReply) GetMessageName() string { return "show_version_reply" } -func (*ShowVersionReply) GetCrcString() string { return "c919bde1" } -func (*ShowVersionReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// ShowVpeSystemTime represents VPP binary API message 'show_vpe_system_time'. -type ShowVpeSystemTime struct{} - -func (m *ShowVpeSystemTime) Reset() { *m = ShowVpeSystemTime{} } -func (*ShowVpeSystemTime) GetMessageName() string { return "show_vpe_system_time" } -func (*ShowVpeSystemTime) GetCrcString() string { return "51077d14" } -func (*ShowVpeSystemTime) GetMessageType() api.MessageType { return api.RequestMessage } - -// ShowVpeSystemTimeReply represents VPP binary API message 'show_vpe_system_time_reply'. -type ShowVpeSystemTimeReply struct { - Retval int32 - VpeSystemTime Timestamp -} - -func (m *ShowVpeSystemTimeReply) Reset() { *m = ShowVpeSystemTimeReply{} } -func (*ShowVpeSystemTimeReply) GetMessageName() string { return "show_vpe_system_time_reply" } -func (*ShowVpeSystemTimeReply) GetCrcString() string { return "7ffd8193" } -func (*ShowVpeSystemTimeReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func init() { - api.RegisterMessage((*AddNodeNext)(nil), "vpe.AddNodeNext") - api.RegisterMessage((*AddNodeNextReply)(nil), "vpe.AddNodeNextReply") - api.RegisterMessage((*Cli)(nil), "vpe.Cli") - api.RegisterMessage((*CliInband)(nil), "vpe.CliInband") - api.RegisterMessage((*CliInbandReply)(nil), "vpe.CliInbandReply") - api.RegisterMessage((*CliReply)(nil), "vpe.CliReply") - api.RegisterMessage((*ControlPing)(nil), "vpe.ControlPing") - api.RegisterMessage((*ControlPingReply)(nil), "vpe.ControlPingReply") - api.RegisterMessage((*GetF64EndianValue)(nil), "vpe.GetF64EndianValue") - api.RegisterMessage((*GetF64EndianValueReply)(nil), "vpe.GetF64EndianValueReply") - api.RegisterMessage((*GetF64IncrementByOne)(nil), "vpe.GetF64IncrementByOne") - api.RegisterMessage((*GetF64IncrementByOneReply)(nil), "vpe.GetF64IncrementByOneReply") - api.RegisterMessage((*GetNextIndex)(nil), "vpe.GetNextIndex") - api.RegisterMessage((*GetNextIndexReply)(nil), "vpe.GetNextIndexReply") - api.RegisterMessage((*GetNodeGraph)(nil), "vpe.GetNodeGraph") - api.RegisterMessage((*GetNodeGraphReply)(nil), "vpe.GetNodeGraphReply") - api.RegisterMessage((*GetNodeIndex)(nil), "vpe.GetNodeIndex") - api.RegisterMessage((*GetNodeIndexReply)(nil), "vpe.GetNodeIndexReply") - api.RegisterMessage((*LogDetails)(nil), "vpe.LogDetails") - api.RegisterMessage((*LogDump)(nil), "vpe.LogDump") - api.RegisterMessage((*ShowThreads)(nil), "vpe.ShowThreads") - api.RegisterMessage((*ShowThreadsReply)(nil), "vpe.ShowThreadsReply") - api.RegisterMessage((*ShowVersion)(nil), "vpe.ShowVersion") - api.RegisterMessage((*ShowVersionReply)(nil), "vpe.ShowVersionReply") - api.RegisterMessage((*ShowVpeSystemTime)(nil), "vpe.ShowVpeSystemTime") - api.RegisterMessage((*ShowVpeSystemTimeReply)(nil), "vpe.ShowVpeSystemTimeReply") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*AddNodeNext)(nil), - (*AddNodeNextReply)(nil), - (*Cli)(nil), - (*CliInband)(nil), - (*CliInbandReply)(nil), - (*CliReply)(nil), - (*ControlPing)(nil), - (*ControlPingReply)(nil), - (*GetF64EndianValue)(nil), - (*GetF64EndianValueReply)(nil), - (*GetF64IncrementByOne)(nil), - (*GetF64IncrementByOneReply)(nil), - (*GetNextIndex)(nil), - (*GetNextIndexReply)(nil), - (*GetNodeGraph)(nil), - (*GetNodeGraphReply)(nil), - (*GetNodeIndex)(nil), - (*GetNodeIndexReply)(nil), - (*LogDetails)(nil), - (*LogDump)(nil), - (*ShowThreads)(nil), - (*ShowThreadsReply)(nil), - (*ShowVersion)(nil), - (*ShowVersionReply)(nil), - (*ShowVpeSystemTime)(nil), - (*ShowVpeSystemTimeReply)(nil), - } -} - -// RPCService represents RPC service API for vpe module. -type RPCService interface { - DumpLog(ctx context.Context, in *LogDump) (RPCService_DumpLogClient, error) - AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error) - Cli(ctx context.Context, in *Cli) (*CliReply, error) - CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error) - ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) - GetF64EndianValue(ctx context.Context, in *GetF64EndianValue) (*GetF64EndianValueReply, error) - GetF64IncrementByOne(ctx context.Context, in *GetF64IncrementByOne) (*GetF64IncrementByOneReply, error) - GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextIndexReply, error) - GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeGraphReply, error) - GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeIndexReply, error) - ShowThreads(ctx context.Context, in *ShowThreads) (*ShowThreadsReply, error) - ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) - ShowVpeSystemTime(ctx context.Context, in *ShowVpeSystemTime) (*ShowVpeSystemTimeReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpLog(ctx context.Context, in *LogDump) (RPCService_DumpLogClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpLogClient{stream} - return x, nil -} - -type RPCService_DumpLogClient interface { - Recv() (*LogDetails, error) -} - -type serviceClient_DumpLogClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpLogClient) Recv() (*LogDetails, error) { - m := new(LogDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) AddNodeNext(ctx context.Context, in *AddNodeNext) (*AddNodeNextReply, error) { - out := new(AddNodeNextReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) Cli(ctx context.Context, in *Cli) (*CliReply, error) { - out := new(CliReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) CliInband(ctx context.Context, in *CliInband) (*CliInbandReply, error) { - out := new(CliInbandReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ControlPing(ctx context.Context, in *ControlPing) (*ControlPingReply, error) { - out := new(ControlPingReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetF64EndianValue(ctx context.Context, in *GetF64EndianValue) (*GetF64EndianValueReply, error) { - out := new(GetF64EndianValueReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetF64IncrementByOne(ctx context.Context, in *GetF64IncrementByOne) (*GetF64IncrementByOneReply, error) { - out := new(GetF64IncrementByOneReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetNextIndex(ctx context.Context, in *GetNextIndex) (*GetNextIndexReply, error) { - out := new(GetNextIndexReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetNodeGraph(ctx context.Context, in *GetNodeGraph) (*GetNodeGraphReply, error) { - out := new(GetNodeGraphReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetNodeIndex(ctx context.Context, in *GetNodeIndex) (*GetNodeIndexReply, error) { - out := new(GetNodeIndexReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ShowThreads(ctx context.Context, in *ShowThreads) (*ShowThreadsReply, error) { - out := new(ShowThreadsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) { - out := new(ShowVersionReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) ShowVpeSystemTime(ctx context.Context, in *ShowVpeSystemTime) (*ShowVpeSystemTimeReply, error) { - out := new(ShowVpeSystemTimeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/vpe_types/vpe_types.ba.go b/plugins/vpp/binapi/vpp2001/vpe_types/vpe_types.ba.go deleted file mode 100644 index dbe81e0402..0000000000 --- a/plugins/vpp/binapi/vpp2001/vpe_types/vpe_types.ba.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/vpe_types.api.json - -/* -Package vpe_types is a generated VPP binary API for 'vpe_types' module. - -It consists of: - 1 enum - 2 aliases - 1 type -*/ -package vpe_types - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "vpe_types" - // VersionCrc is the CRC of this module. - VersionCrc = 0x3369988d -) - -// LogLevel represents VPP binary API enum 'log_level'. -type LogLevel uint32 - -const ( - VPE_API_LOG_LEVEL_EMERG LogLevel = 0 - VPE_API_LOG_LEVEL_ALERT LogLevel = 1 - VPE_API_LOG_LEVEL_CRIT LogLevel = 2 - VPE_API_LOG_LEVEL_ERR LogLevel = 3 - VPE_API_LOG_LEVEL_WARNING LogLevel = 4 - VPE_API_LOG_LEVEL_NOTICE LogLevel = 5 - VPE_API_LOG_LEVEL_INFO LogLevel = 6 - VPE_API_LOG_LEVEL_DEBUG LogLevel = 7 - VPE_API_LOG_LEVEL_DISABLED LogLevel = 8 -) - -var LogLevel_name = map[uint32]string{ - 0: "VPE_API_LOG_LEVEL_EMERG", - 1: "VPE_API_LOG_LEVEL_ALERT", - 2: "VPE_API_LOG_LEVEL_CRIT", - 3: "VPE_API_LOG_LEVEL_ERR", - 4: "VPE_API_LOG_LEVEL_WARNING", - 5: "VPE_API_LOG_LEVEL_NOTICE", - 6: "VPE_API_LOG_LEVEL_INFO", - 7: "VPE_API_LOG_LEVEL_DEBUG", - 8: "VPE_API_LOG_LEVEL_DISABLED", -} - -var LogLevel_value = map[string]uint32{ - "VPE_API_LOG_LEVEL_EMERG": 0, - "VPE_API_LOG_LEVEL_ALERT": 1, - "VPE_API_LOG_LEVEL_CRIT": 2, - "VPE_API_LOG_LEVEL_ERR": 3, - "VPE_API_LOG_LEVEL_WARNING": 4, - "VPE_API_LOG_LEVEL_NOTICE": 5, - "VPE_API_LOG_LEVEL_INFO": 6, - "VPE_API_LOG_LEVEL_DEBUG": 7, - "VPE_API_LOG_LEVEL_DISABLED": 8, -} - -func (x LogLevel) String() string { - s, ok := LogLevel_name[uint32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} - -// Timedelta represents VPP binary API alias 'timedelta'. -type Timedelta float64 - -// Timestamp represents VPP binary API alias 'timestamp'. -type Timestamp float64 - -// Version represents VPP binary API type 'version'. -type Version struct { - Major uint32 - Minor uint32 - Patch uint32 - PreRelease []byte `struc:"[17]byte"` - BuildMetadata []byte `struc:"[17]byte"` -} - -func (*Version) GetTypeName() string { return "version" } - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/vpp2001.go b/plugins/vpp/binapi/vpp2001/vpp2001.go deleted file mode 100644 index 58ce429296..0000000000 --- a/plugins/vpp/binapi/vpp2001/vpp2001.go +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/abf" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/acl" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/af_packet" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/bond" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dns" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/flowprobe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gre" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gtpu" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipfix_export" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l3xc" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memclnt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memif" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/nat" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/punt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/rdma" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/span" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/sr" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/stn" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/tapv2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vmxnet3" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan_gpe" -) - -// Version is used to identify VPP binapi version -const Version = "20.01" - -func init() { - binapi.Versions[Version] = binapi.VersionMsgs{ - Core: vpp.Messages( - af_packet.AllMessages, - bond.AllMessages, - dhcp.AllMessages, - gre.AllMessages, - interfaces.AllMessages, - ip.AllMessages, - ipfix_export.AllMessages, - ipsec.AllMessages, - l2.AllMessages, - memclnt.AllMessages, - punt.AllMessages, - span.AllMessages, - sr.AllMessages, - tapv2.AllMessages, - vpe.AllMessages, - vxlan.AllMessages, - vxlan_gpe.AllMessages, - ipip.AllMessages, - ), - Plugins: vpp.Messages( - abf.AllMessages, - acl.AllMessages, - dns.AllMessages, - flowprobe.AllMessages, - gtpu.AllMessages, - l3xc.AllMessages, - memif.AllMessages, - nat.AllMessages, - rdma.AllMessages, - stn.AllMessages, - vmxnet3.AllMessages, - ), - } -} - -//go:generate -command binapigentypes binapi-generator --output-dir=. --import-prefix=go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ -//go:generate binapigentypes --input-file=$VPP_API_DIR/core/ethernet_types.api.json -//go:generate binapigentypes --input-file=$VPP_API_DIR/core/interface_types.api.json -//go:generate binapigentypes --input-file=$VPP_API_DIR/core/ip_types.api.json -//go:generate binapigentypes --input-file=$VPP_API_DIR/core/fib_types.api.json --input-types=$VPP_API_DIR/core/ethernet_types.api.json,$VPP_API_DIR/core/interface_types.api.json,$VPP_API_DIR/core/ip_types.api.json -//go:generate binapigentypes --input-file=$VPP_API_DIR/core/ipsec_types.api.json --input-types=$VPP_API_DIR/core/ethernet_types.api.json,$VPP_API_DIR/core/interface_types.api.json,$VPP_API_DIR/core/ip_types.api.json -//go:generate binapigentypes --input-file=$VPP_API_DIR/core/vpe_types.api.json - -//go:generate -command binapigen binapi-generator --output-dir=. --import-prefix=go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ --input-types=$VPP_API_DIR/core/ethernet_types.api.json,$VPP_API_DIR/core/interface_types.api.json,$VPP_API_DIR/core/ip_types.api.json,$VPP_API_DIR/core/fib_types.api.json,$VPP_API_DIR/core/ipsec_types.api.json,$VPP_API_DIR/core/vpe_types.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/af_packet.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/arp.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/bond.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/gre.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/interface.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/ip.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/ip_neighbor.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/ipfix_export.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/ipsec.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/l2.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/memclnt.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/punt.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/span.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/sr.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/tapv2.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/vpe.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/vxlan.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/vxlan_gpe.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/core/ipip.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/abf.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/acl.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/dns.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/flowprobe.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/gtpu.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/dhcp.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/l3xc.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/memif.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/nat.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/rdma.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/stn.api.json -//go:generate binapigen --input-file=$VPP_API_DIR/plugins/vmxnet3.api.json diff --git a/plugins/vpp/binapi/vpp2001/vxlan/vxlan.ba.go b/plugins/vpp/binapi/vpp2001/vxlan/vxlan.ba.go deleted file mode 100644 index a7650c8532..0000000000 --- a/plugins/vpp/binapi/vpp2001/vxlan/vxlan.ba.go +++ /dev/null @@ -1,241 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/vxlan.api.json - -/* -Package vxlan is a generated VPP binary API for 'vxlan' module. - -It consists of: - 8 messages - 4 services -*/ -package vxlan - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "vxlan" - // APIVersion is the API version of this module. - APIVersion = "1.1.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0xa95aa271 -) - -// SwInterfaceSetVxlanBypass represents VPP binary API message 'sw_interface_set_vxlan_bypass'. -type SwInterfaceSetVxlanBypass struct { - SwIfIndex uint32 - IsIPv6 uint8 - Enable uint8 -} - -func (m *SwInterfaceSetVxlanBypass) Reset() { *m = SwInterfaceSetVxlanBypass{} } -func (*SwInterfaceSetVxlanBypass) GetMessageName() string { return "sw_interface_set_vxlan_bypass" } -func (*SwInterfaceSetVxlanBypass) GetCrcString() string { return "e74ca095" } -func (*SwInterfaceSetVxlanBypass) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetVxlanBypassReply represents VPP binary API message 'sw_interface_set_vxlan_bypass_reply'. -type SwInterfaceSetVxlanBypassReply struct { - Retval int32 -} - -func (m *SwInterfaceSetVxlanBypassReply) Reset() { *m = SwInterfaceSetVxlanBypassReply{} } -func (*SwInterfaceSetVxlanBypassReply) GetMessageName() string { - return "sw_interface_set_vxlan_bypass_reply" -} -func (*SwInterfaceSetVxlanBypassReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetVxlanBypassReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// VxlanAddDelTunnel represents VPP binary API message 'vxlan_add_del_tunnel'. -type VxlanAddDelTunnel struct { - IsAdd uint8 - IsIPv6 uint8 - Instance uint32 - SrcAddress []byte `struc:"[16]byte"` - DstAddress []byte `struc:"[16]byte"` - McastSwIfIndex uint32 - EncapVrfID uint32 - DecapNextIndex uint32 - Vni uint32 -} - -func (m *VxlanAddDelTunnel) Reset() { *m = VxlanAddDelTunnel{} } -func (*VxlanAddDelTunnel) GetMessageName() string { return "vxlan_add_del_tunnel" } -func (*VxlanAddDelTunnel) GetCrcString() string { return "00f4bdd0" } -func (*VxlanAddDelTunnel) GetMessageType() api.MessageType { return api.RequestMessage } - -// VxlanAddDelTunnelReply represents VPP binary API message 'vxlan_add_del_tunnel_reply'. -type VxlanAddDelTunnelReply struct { - Retval int32 - SwIfIndex uint32 -} - -func (m *VxlanAddDelTunnelReply) Reset() { *m = VxlanAddDelTunnelReply{} } -func (*VxlanAddDelTunnelReply) GetMessageName() string { return "vxlan_add_del_tunnel_reply" } -func (*VxlanAddDelTunnelReply) GetCrcString() string { return "fda5941f" } -func (*VxlanAddDelTunnelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// VxlanOffloadRx represents VPP binary API message 'vxlan_offload_rx'. -type VxlanOffloadRx struct { - HwIfIndex uint32 - SwIfIndex uint32 - Enable uint8 -} - -func (m *VxlanOffloadRx) Reset() { *m = VxlanOffloadRx{} } -func (*VxlanOffloadRx) GetMessageName() string { return "vxlan_offload_rx" } -func (*VxlanOffloadRx) GetCrcString() string { return "f0b08786" } -func (*VxlanOffloadRx) GetMessageType() api.MessageType { return api.RequestMessage } - -// VxlanOffloadRxReply represents VPP binary API message 'vxlan_offload_rx_reply'. -type VxlanOffloadRxReply struct { - Retval int32 -} - -func (m *VxlanOffloadRxReply) Reset() { *m = VxlanOffloadRxReply{} } -func (*VxlanOffloadRxReply) GetMessageName() string { return "vxlan_offload_rx_reply" } -func (*VxlanOffloadRxReply) GetCrcString() string { return "e8d4e804" } -func (*VxlanOffloadRxReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// VxlanTunnelDetails represents VPP binary API message 'vxlan_tunnel_details'. -type VxlanTunnelDetails struct { - SwIfIndex uint32 - Instance uint32 - SrcAddress []byte `struc:"[16]byte"` - DstAddress []byte `struc:"[16]byte"` - McastSwIfIndex uint32 - EncapVrfID uint32 - DecapNextIndex uint32 - Vni uint32 - IsIPv6 uint8 -} - -func (m *VxlanTunnelDetails) Reset() { *m = VxlanTunnelDetails{} } -func (*VxlanTunnelDetails) GetMessageName() string { return "vxlan_tunnel_details" } -func (*VxlanTunnelDetails) GetCrcString() string { return "ce38e127" } -func (*VxlanTunnelDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// VxlanTunnelDump represents VPP binary API message 'vxlan_tunnel_dump'. -type VxlanTunnelDump struct { - SwIfIndex uint32 -} - -func (m *VxlanTunnelDump) Reset() { *m = VxlanTunnelDump{} } -func (*VxlanTunnelDump) GetMessageName() string { return "vxlan_tunnel_dump" } -func (*VxlanTunnelDump) GetCrcString() string { return "529cb13f" } -func (*VxlanTunnelDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*SwInterfaceSetVxlanBypass)(nil), "vxlan.SwInterfaceSetVxlanBypass") - api.RegisterMessage((*SwInterfaceSetVxlanBypassReply)(nil), "vxlan.SwInterfaceSetVxlanBypassReply") - api.RegisterMessage((*VxlanAddDelTunnel)(nil), "vxlan.VxlanAddDelTunnel") - api.RegisterMessage((*VxlanAddDelTunnelReply)(nil), "vxlan.VxlanAddDelTunnelReply") - api.RegisterMessage((*VxlanOffloadRx)(nil), "vxlan.VxlanOffloadRx") - api.RegisterMessage((*VxlanOffloadRxReply)(nil), "vxlan.VxlanOffloadRxReply") - api.RegisterMessage((*VxlanTunnelDetails)(nil), "vxlan.VxlanTunnelDetails") - api.RegisterMessage((*VxlanTunnelDump)(nil), "vxlan.VxlanTunnelDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*SwInterfaceSetVxlanBypass)(nil), - (*SwInterfaceSetVxlanBypassReply)(nil), - (*VxlanAddDelTunnel)(nil), - (*VxlanAddDelTunnelReply)(nil), - (*VxlanOffloadRx)(nil), - (*VxlanOffloadRxReply)(nil), - (*VxlanTunnelDetails)(nil), - (*VxlanTunnelDump)(nil), - } -} - -// RPCService represents RPC service API for vxlan module. -type RPCService interface { - DumpVxlanTunnel(ctx context.Context, in *VxlanTunnelDump) (RPCService_DumpVxlanTunnelClient, error) - SwInterfaceSetVxlanBypass(ctx context.Context, in *SwInterfaceSetVxlanBypass) (*SwInterfaceSetVxlanBypassReply, error) - VxlanAddDelTunnel(ctx context.Context, in *VxlanAddDelTunnel) (*VxlanAddDelTunnelReply, error) - VxlanOffloadRx(ctx context.Context, in *VxlanOffloadRx) (*VxlanOffloadRxReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpVxlanTunnel(ctx context.Context, in *VxlanTunnelDump) (RPCService_DumpVxlanTunnelClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpVxlanTunnelClient{stream} - return x, nil -} - -type RPCService_DumpVxlanTunnelClient interface { - Recv() (*VxlanTunnelDetails, error) -} - -type serviceClient_DumpVxlanTunnelClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpVxlanTunnelClient) Recv() (*VxlanTunnelDetails, error) { - m := new(VxlanTunnelDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) SwInterfaceSetVxlanBypass(ctx context.Context, in *SwInterfaceSetVxlanBypass) (*SwInterfaceSetVxlanBypassReply, error) { - out := new(SwInterfaceSetVxlanBypassReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) VxlanAddDelTunnel(ctx context.Context, in *VxlanAddDelTunnel) (*VxlanAddDelTunnelReply, error) { - out := new(VxlanAddDelTunnelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) VxlanOffloadRx(ctx context.Context, in *VxlanOffloadRx) (*VxlanOffloadRxReply, error) { - out := new(VxlanOffloadRxReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/binapi/vpp2001/vxlan_gpe/vxlan_gpe.ba.go b/plugins/vpp/binapi/vpp2001/vxlan_gpe/vxlan_gpe.ba.go deleted file mode 100644 index 677b98d2bf..0000000000 --- a/plugins/vpp/binapi/vpp2001/vxlan_gpe/vxlan_gpe.ba.go +++ /dev/null @@ -1,207 +0,0 @@ -// Code generated by GoVPP's binapi-generator. DO NOT EDIT. -// source: /usr/share/vpp/api/core/vxlan_gpe.api.json - -/* -Package vxlan_gpe is a generated VPP binary API for 'vxlan_gpe' module. - -It consists of: - 6 messages - 3 services -*/ -package vxlan_gpe - -import ( - "bytes" - "context" - "io" - "strconv" - - api "git.fd.io/govpp.git/api" - struc "github.com/lunixbochs/struc" -) - -const ( - // ModuleName is the name of this module. - ModuleName = "vxlan_gpe" - // APIVersion is the API version of this module. - APIVersion = "1.0.0" - // VersionCrc is the CRC of this module. - VersionCrc = 0x25bfb55d -) - -// SwInterfaceSetVxlanGpeBypass represents VPP binary API message 'sw_interface_set_vxlan_gpe_bypass'. -type SwInterfaceSetVxlanGpeBypass struct { - SwIfIndex uint32 - IsIPv6 uint8 - Enable uint8 -} - -func (m *SwInterfaceSetVxlanGpeBypass) Reset() { *m = SwInterfaceSetVxlanGpeBypass{} } -func (*SwInterfaceSetVxlanGpeBypass) GetMessageName() string { - return "sw_interface_set_vxlan_gpe_bypass" -} -func (*SwInterfaceSetVxlanGpeBypass) GetCrcString() string { return "e74ca095" } -func (*SwInterfaceSetVxlanGpeBypass) GetMessageType() api.MessageType { return api.RequestMessage } - -// SwInterfaceSetVxlanGpeBypassReply represents VPP binary API message 'sw_interface_set_vxlan_gpe_bypass_reply'. -type SwInterfaceSetVxlanGpeBypassReply struct { - Retval int32 -} - -func (m *SwInterfaceSetVxlanGpeBypassReply) Reset() { *m = SwInterfaceSetVxlanGpeBypassReply{} } -func (*SwInterfaceSetVxlanGpeBypassReply) GetMessageName() string { - return "sw_interface_set_vxlan_gpe_bypass_reply" -} -func (*SwInterfaceSetVxlanGpeBypassReply) GetCrcString() string { return "e8d4e804" } -func (*SwInterfaceSetVxlanGpeBypassReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// VxlanGpeAddDelTunnel represents VPP binary API message 'vxlan_gpe_add_del_tunnel'. -type VxlanGpeAddDelTunnel struct { - IsIPv6 uint8 - Local []byte `struc:"[16]byte"` - Remote []byte `struc:"[16]byte"` - McastSwIfIndex uint32 - EncapVrfID uint32 - DecapVrfID uint32 - Protocol uint8 - Vni uint32 - IsAdd uint8 -} - -func (m *VxlanGpeAddDelTunnel) Reset() { *m = VxlanGpeAddDelTunnel{} } -func (*VxlanGpeAddDelTunnel) GetMessageName() string { return "vxlan_gpe_add_del_tunnel" } -func (*VxlanGpeAddDelTunnel) GetCrcString() string { return "d15850ba" } -func (*VxlanGpeAddDelTunnel) GetMessageType() api.MessageType { return api.RequestMessage } - -// VxlanGpeAddDelTunnelReply represents VPP binary API message 'vxlan_gpe_add_del_tunnel_reply'. -type VxlanGpeAddDelTunnelReply struct { - Retval int32 - SwIfIndex uint32 -} - -func (m *VxlanGpeAddDelTunnelReply) Reset() { *m = VxlanGpeAddDelTunnelReply{} } -func (*VxlanGpeAddDelTunnelReply) GetMessageName() string { return "vxlan_gpe_add_del_tunnel_reply" } -func (*VxlanGpeAddDelTunnelReply) GetCrcString() string { return "fda5941f" } -func (*VxlanGpeAddDelTunnelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -// VxlanGpeTunnelDetails represents VPP binary API message 'vxlan_gpe_tunnel_details'. -type VxlanGpeTunnelDetails struct { - SwIfIndex uint32 - Local []byte `struc:"[16]byte"` - Remote []byte `struc:"[16]byte"` - Vni uint32 - Protocol uint8 - McastSwIfIndex uint32 - EncapVrfID uint32 - DecapVrfID uint32 - IsIPv6 uint8 -} - -func (m *VxlanGpeTunnelDetails) Reset() { *m = VxlanGpeTunnelDetails{} } -func (*VxlanGpeTunnelDetails) GetMessageName() string { return "vxlan_gpe_tunnel_details" } -func (*VxlanGpeTunnelDetails) GetCrcString() string { return "2673fbfa" } -func (*VxlanGpeTunnelDetails) GetMessageType() api.MessageType { return api.ReplyMessage } - -// VxlanGpeTunnelDump represents VPP binary API message 'vxlan_gpe_tunnel_dump'. -type VxlanGpeTunnelDump struct { - SwIfIndex uint32 -} - -func (m *VxlanGpeTunnelDump) Reset() { *m = VxlanGpeTunnelDump{} } -func (*VxlanGpeTunnelDump) GetMessageName() string { return "vxlan_gpe_tunnel_dump" } -func (*VxlanGpeTunnelDump) GetCrcString() string { return "529cb13f" } -func (*VxlanGpeTunnelDump) GetMessageType() api.MessageType { return api.RequestMessage } - -func init() { - api.RegisterMessage((*SwInterfaceSetVxlanGpeBypass)(nil), "vxlan_gpe.SwInterfaceSetVxlanGpeBypass") - api.RegisterMessage((*SwInterfaceSetVxlanGpeBypassReply)(nil), "vxlan_gpe.SwInterfaceSetVxlanGpeBypassReply") - api.RegisterMessage((*VxlanGpeAddDelTunnel)(nil), "vxlan_gpe.VxlanGpeAddDelTunnel") - api.RegisterMessage((*VxlanGpeAddDelTunnelReply)(nil), "vxlan_gpe.VxlanGpeAddDelTunnelReply") - api.RegisterMessage((*VxlanGpeTunnelDetails)(nil), "vxlan_gpe.VxlanGpeTunnelDetails") - api.RegisterMessage((*VxlanGpeTunnelDump)(nil), "vxlan_gpe.VxlanGpeTunnelDump") -} - -// Messages returns list of all messages in this module. -func AllMessages() []api.Message { - return []api.Message{ - (*SwInterfaceSetVxlanGpeBypass)(nil), - (*SwInterfaceSetVxlanGpeBypassReply)(nil), - (*VxlanGpeAddDelTunnel)(nil), - (*VxlanGpeAddDelTunnelReply)(nil), - (*VxlanGpeTunnelDetails)(nil), - (*VxlanGpeTunnelDump)(nil), - } -} - -// RPCService represents RPC service API for vxlan_gpe module. -type RPCService interface { - DumpVxlanGpeTunnel(ctx context.Context, in *VxlanGpeTunnelDump) (RPCService_DumpVxlanGpeTunnelClient, error) - SwInterfaceSetVxlanGpeBypass(ctx context.Context, in *SwInterfaceSetVxlanGpeBypass) (*SwInterfaceSetVxlanGpeBypassReply, error) - VxlanGpeAddDelTunnel(ctx context.Context, in *VxlanGpeAddDelTunnel) (*VxlanGpeAddDelTunnelReply, error) -} - -type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpVxlanGpeTunnel(ctx context.Context, in *VxlanGpeTunnelDump) (RPCService_DumpVxlanGpeTunnelClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpVxlanGpeTunnelClient{stream} - return x, nil -} - -type RPCService_DumpVxlanGpeTunnelClient interface { - Recv() (*VxlanGpeTunnelDetails, error) -} - -type serviceClient_DumpVxlanGpeTunnelClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpVxlanGpeTunnelClient) Recv() (*VxlanGpeTunnelDetails, error) { - m := new(VxlanGpeTunnelDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) SwInterfaceSetVxlanGpeBypass(ctx context.Context, in *SwInterfaceSetVxlanGpeBypass) (*SwInterfaceSetVxlanGpeBypassReply, error) { - out := new(SwInterfaceSetVxlanGpeBypassReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) VxlanGpeAddDelTunnel(ctx context.Context, in *VxlanGpeAddDelTunnel) (*VxlanGpeAddDelTunnelReply, error) { - out := new(VxlanGpeAddDelTunnelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) - if err != nil { - return nil, err - } - return out, nil -} - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the GoVPP api package it is being compiled against. -// A compilation error at this line likely means your copy of the -// GoVPP api package needs to be updated. -const _ = api.GoVppAPIPackageIsVersion1 // please upgrade the GoVPP api package - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = bytes.NewBuffer -var _ = context.Background -var _ = io.Copy -var _ = strconv.Itoa -var _ = struc.Pack diff --git a/plugins/vpp/dnsplugin/dnsplugin.go b/plugins/vpp/dnsplugin/dnsplugin.go index 5f41f2fbf2..20ee5d5b63 100644 --- a/plugins/vpp/dnsplugin/dnsplugin.go +++ b/plugins/vpp/dnsplugin/dnsplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Pantheon.tech +// Copyright (c) 2021 Pantheon.tech // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/descriptor" "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/dnsplugin/vppcalls/vpp2001/dns.go b/plugins/vpp/dnsplugin/vppcalls/vpp2001/dns.go deleted file mode 100644 index 3e79cd9361..0000000000 --- a/plugins/vpp/dnsplugin/vppcalls/vpp2001/dns.go +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2020 Pantheon.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "github.com/go-errors/errors" - vpp_dns "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dns" -) - -// EnableDNS make act VPP as DNS cache server -func (h *DNSVppHandler) EnableDNS() error { - h.log.Debug("Enabling DNS functionality of VPP") - if err := h.enableDisableDNS(true); err != nil { - return err - } - h.log.Debug("DNS functionality of VPP enabled.") - return nil -} - -// DisableDNS disables functionality that makes VPP act as DNS cache server -func (h *DNSVppHandler) DisableDNS() error { - h.log.Debug("Disabling DNS functionality of VPP") - if err := h.enableDisableDNS(false); err != nil { - return err - } - h.log.Debug("DNS functionality of VPP disabled.") - return nil -} - -func (h *DNSVppHandler) enableDisableDNS(enable bool) error { - req := &vpp_dns.DNSEnableDisable{} - if enable { - req.Enable = 1 - } - reply := &vpp_dns.DNSEnableDisableReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - return nil -} - -// AddUpstreamDNSServer adds new upstream DNS Server to the upstream DNS server list -func (h *DNSVppHandler) AddUpstreamDNSServer(serverIPAddress net.IP) error { - h.log.Debug("Adding upstream DNS server with IP %s", serverIPAddress) - if err := h.addRemoveUpstreamDNSServer(true, serverIPAddress); err != nil { - return err - } - h.log.Debug("Upstream DNS server with IP %s was added", serverIPAddress) - return nil -} - -// DeleteUpstreamDNSServer removes upstream DNS Server from the upstream DNS server list -func (h *DNSVppHandler) DeleteUpstreamDNSServer(serverIPAddress net.IP) error { - h.log.Debug("Removing upstream DNS server with IP %s", serverIPAddress) - if err := h.addRemoveUpstreamDNSServer(false, serverIPAddress); err != nil { - return err - } - h.log.Debug("Upstream DNS server with IP %s was removed", serverIPAddress) - return nil -} - -func (h *DNSVppHandler) addRemoveUpstreamDNSServer(addition bool, serverIPAddress net.IP) error { - if serverIPAddress == nil { - return errors.New("upstream DNS server IP address can't be nil") - } - req := &vpp_dns.DNSNameServerAddDel{ - IsAdd: boolToUint(addition), - } - if serverIPAddress.To4() == nil { // IPv6 - req.IsIP6 = 1 - req.ServerAddress = serverIPAddress.To16() - } else { - req.ServerAddress = serverIPAddress.To4() - } - reply := &vpp_dns.DNSNameServerAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - return nil -} - -func boolToUint(input bool) uint8 { - if input { - return uint8(1) - } - return uint8(0) -} diff --git a/plugins/vpp/dnsplugin/vppcalls/vpp2001/dns_test.go b/plugins/vpp/dnsplugin/vppcalls/vpp2001/dns_test.go deleted file mode 100644 index 42c8fac168..0000000000 --- a/plugins/vpp/dnsplugin/vppcalls/vpp2001/dns_test.go +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright (c) 2020 Pantheon.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "net" - "testing" - - govppapi "git.fd.io/govpp.git/api" - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dns" - "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" -) - -var ( - upstreamDNSServerIPv4 = net.ParseIP("8.8.8.8").To4() // google dns - upstreamDNSServerIPv6 = net.ParseIP("2001:4860:4860::8888") // google dns -) - -// TestEnableDisableDNS tests all cases for methods EnableDNS and DisableDNS -func TestEnableDisableDNS(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - TestEnable bool - FailInVPP bool - ExpectFailure bool - Expected govppapi.Message - }{ - { - Name: "successful enabling of DNS", - TestEnable: true, - Expected: &dns.DNSEnableDisable{ - Enable: 1, - }, - }, - { - Name: "enable failure", - TestEnable: true, - FailInVPP: true, - ExpectFailure: true, - }, - { - Name: "successful disabling of DNS", - TestEnable: false, - Expected: &dns.DNSEnableDisable{ - Enable: 0, - }, - }, - { - Name: "disable failure", - TestEnable: false, - FailInVPP: true, - ExpectFailure: true, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply - if td.FailInVPP { - ctx.MockVpp.MockReply(&dns.DNSEnableDisableReply{Retval: 1}) - } else { - ctx.MockVpp.MockReply(&dns.DNSEnableDisableReply{}) - } - - // make the call - var err error - if td.TestEnable { - err = vppCalls.EnableDNS() - } else { - err = vppCalls.DisableDNS() - } - - // verify result - if td.ExpectFailure { - Expect(err).Should(HaveOccurred()) - } else { - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(td.Expected)) - } - }) - } -} - -// TestAddRemoveUpstreamDNSServer tests all cases for methods AddUpstreamDNSServer and RemoveUpstreamDNSServer -func TestAddRemoveUpstreamDNSServer(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - TestAdding bool - FailInVPP bool - ExpectFailure bool - Input net.IP - Expected govppapi.Message - }{ - { - Name: "successful adding of IPv4 upstream DNS server", - TestAdding: true, - Input: upstreamDNSServerIPv4, - Expected: &dns.DNSNameServerAddDel{ - IsIP6: 0, - IsAdd: 1, - ServerAddress: upstreamDNSServerIPv4, - }, - }, - { - Name: "successful adding of IPv6 upstream DNS server", - TestAdding: true, - Input: upstreamDNSServerIPv6, - Expected: &dns.DNSNameServerAddDel{ - IsIP6: 1, - IsAdd: 1, - ServerAddress: upstreamDNSServerIPv6, - }, - }, - { - Name: "successful removal of IPv4 upstream DNS server", - TestAdding: false, - Input: upstreamDNSServerIPv4, - Expected: &dns.DNSNameServerAddDel{ - IsIP6: 0, - IsAdd: 0, - ServerAddress: upstreamDNSServerIPv4, - }, - }, - { - Name: "successful removal of IPv6 upstream DNS server", - TestAdding: false, - Input: upstreamDNSServerIPv6, - Expected: &dns.DNSNameServerAddDel{ - IsIP6: 1, - IsAdd: 0, - ServerAddress: upstreamDNSServerIPv6, - }, - }, - { - Name: "failure propagation from VPP", - TestAdding: false, - FailInVPP: true, - ExpectFailure: true, - Input: upstreamDNSServerIPv4, - }, - { - Name: "bad IP address input", - TestAdding: false, - FailInVPP: true, - ExpectFailure: true, - Input: nil, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply - if td.FailInVPP { - ctx.MockVpp.MockReply(&dns.DNSNameServerAddDelReply{Retval: 1}) - } else { - ctx.MockVpp.MockReply(&dns.DNSNameServerAddDelReply{}) - } - - // make the call - var err error - if td.TestAdding { - err = vppCalls.AddUpstreamDNSServer(td.Input) - } else { - err = vppCalls.DeleteUpstreamDNSServer(td.Input) - } - - // verify result - if td.ExpectFailure { - Expect(err).Should(HaveOccurred()) - } else { - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(td.Expected)) - } - }) - } -} - -func setup(t *testing.T) (*vppmock.TestCtx, vppcalls.DNSVppAPI) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test") - vppCalls := vpp2001.NewDNSVppHandler(ctx.MockVPPClient, log) - return ctx, vppCalls -} - -func teardown(ctx *vppmock.TestCtx) { - ctx.TeardownTestCtx() -} diff --git a/plugins/vpp/dnsplugin/vppcalls/vpp2001/vppcalls_handler.go b/plugins/vpp/dnsplugin/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 2d16fdb937..0000000000 --- a/plugins/vpp/dnsplugin/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2020 Pantheon.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - core_vppcalls "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls" - core_vpp2001 "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dns" - "go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls" -) - -func init() { - msgs := vpp.Messages( - dns.AllMessages, - ) - vppcalls.AddHandlerVersion(vpp2001.Version, msgs.AllMessages(), NewDNSVppHandler) -} - -// DNSVppHandler is accessor for DNS-related vppcalls methods -type DNSVppHandler struct { - core_vppcalls.VppCoreAPI - - log logging.Logger - callsChannel govppapi.Channel -} - -// NewDNSVppHandler creates new instance of DNS vppcalls handler -func NewDNSVppHandler(c vpp.Client, log logging.Logger) vppcalls.DNSVppAPI { - vppChan, err := c.NewAPIChannel() - if err != nil { - logging.Warnf("failed to create API channel") - return nil - } - return &DNSVppHandler{ - callsChannel: vppChan, - log: log, - VppCoreAPI: core_vpp2001.NewVpeHandler(vppChan), - } -} diff --git a/plugins/vpp/handlers_test.go b/plugins/vpp/handlers_test.go index 7d08ad240c..156f701888 100644 --- a/plugins/vpp/handlers_test.go +++ b/plugins/vpp/handlers_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ func TestRegisterHandlerVersions(t *testing.T) { vpp.ClearRegisteredHandlers() const ( - version vpp.Version = "19.08-test" + version vpp.Version = "21.06-test" ) handler := vpp.RegisterHandler(vpp.HandlerDesc{ diff --git a/plugins/vpp/ifplugin/ifplugin.go b/plugins/vpp/ifplugin/ifplugin.go index 2a2c981402..e2df2511f7 100644 --- a/plugins/vpp/ifplugin/ifplugin.go +++ b/plugins/vpp/ifplugin/ifplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -48,7 +48,6 @@ import ( "go.ligato.io/vpp-agent/v3/proto/ligato/vpp" interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/admin_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/admin_vppcalls.go deleted file mode 100644 index 419ba81c9f..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/admin_vppcalls.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func (h *InterfaceVppHandler) InterfaceAdminDown(ctx context.Context, ifIdx uint32) error { - return h.interfaceSetFlags(ifIdx, false) -} - -func (h *InterfaceVppHandler) InterfaceAdminUp(ctx context.Context, ifIdx uint32) error { - return h.interfaceSetFlags(ifIdx, true) -} - -func (h *InterfaceVppHandler) SetInterfaceTag(tag string, ifIdx uint32) error { - return h.handleInterfaceTag(tag, vpp_ifs.InterfaceIndex(ifIdx), true) -} - -func (h *InterfaceVppHandler) RemoveInterfaceTag(tag string, ifIdx uint32) error { - return h.handleInterfaceTag(tag, vpp_ifs.InterfaceIndex(ifIdx), false) -} - -func (h *InterfaceVppHandler) interfaceSetFlags(ifIdx uint32, adminUp bool) error { - req := &vpp_ifs.SwInterfaceSetFlags{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - Flags: setAdminUpFlag(adminUp), - } - reply := &vpp_ifs.SwInterfaceSetFlagsReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *InterfaceVppHandler) handleInterfaceTag(tag string, ifIdx vpp_ifs.InterfaceIndex, isAdd bool) error { - req := &vpp_ifs.SwInterfaceTagAddDel{ - Tag: tag, - IsAdd: isAdd, - } - // For some reason, if deleting tag, the software interface index has to be 0 and only name should be set. - // Otherwise reply returns with error core -2 (incorrect sw_if_idx) - if isAdd { - req.SwIfIndex = ifIdx - } - reply := &vpp_ifs.SwInterfaceTagAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func setAdminUpFlag(adminUp bool) vpp_ifs.IfStatusFlags { - if adminUp { - return interface_types.IF_STATUS_API_FLAG_ADMIN_UP - } - return 0 -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/admin_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/admin_vppcalls_test.go deleted file mode 100644 index e669177c70..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/admin_vppcalls_test.go +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" -) - -func TestInterfaceAdminDown(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetFlagsReply{}) - err := ifHandler.InterfaceAdminDown(ctx.Context, 1) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetFlags) - Expect(ok).To(BeTrue()) - Expect(vppMsg).NotTo(BeNil()) - Expect(vppMsg.SwIfIndex).To(Equal(vpp_ifs.InterfaceIndex(1))) - Expect(vppMsg.Flags).To(Equal(vpp_ifs.IfStatusFlags(0))) -} - -func TestInterfaceAdminDownError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{}) - err := ifHandler.InterfaceAdminDown(ctx.Context, 1) - - Expect(err).ToNot(BeNil()) -} - -func TestInterfaceAdminDownRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetFlagsReply{ - Retval: 1, - }) - err := ifHandler.InterfaceAdminDown(ctx.Context, 1) - - Expect(err).ToNot(BeNil()) -} - -func TestInterfaceAdminUp(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetFlagsReply{}) - err := ifHandler.InterfaceAdminUp(ctx.Context, 1) - - Expect(err).ShouldNot(HaveOccurred()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetFlags) - Expect(ok).To(BeTrue()) - Expect(vppMsg).NotTo(BeNil()) - Expect(vppMsg.SwIfIndex).To(Equal(vpp_ifs.InterfaceIndex(1))) - Expect(vppMsg.Flags).To(Equal(interface_types.IF_STATUS_API_FLAG_ADMIN_UP)) -} - -func TestInterfaceAdminUpError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{}) - err := ifHandler.InterfaceAdminDown(ctx.Context, 1) - - Expect(err).ToNot(BeNil()) -} - -func TestInterfaceAdminUpRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetFlagsReply{ - Retval: 1, - }) - err := ifHandler.InterfaceAdminDown(ctx.Context, 1) - - Expect(err).ToNot(BeNil()) -} - -func TestInterfaceSetTag(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - err := ifHandler.SetInterfaceTag("tag", 1) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceTagAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg).NotTo(BeNil()) - Expect(vppMsg.Tag).To(BeEquivalentTo("tag")) - Expect(vppMsg.SwIfIndex).To(Equal(vpp_ifs.InterfaceIndex(1))) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestInterfaceSetTagError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{}) - err := ifHandler.SetInterfaceTag("tag", 1) - - Expect(err).ToNot(BeNil()) -} - -func TestInterfaceSetTagRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{ - Retval: 1, - }) - err := ifHandler.SetInterfaceTag("tag", 1) - - Expect(err).ToNot(BeNil()) -} - -func TestInterfaceRemoveTag(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - err := ifHandler.RemoveInterfaceTag("tag", 1) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceTagAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg).NotTo(BeNil()) - Expect(vppMsg.Tag).To(BeEquivalentTo("tag")) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func TestInterfaceRemoveTagError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{}) - err := ifHandler.RemoveInterfaceTag("tag", 1) - - Expect(err).ToNot(BeNil()) -} - -func TestInterfaceRemoveTagRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{ - Retval: 1, - }) - err := ifHandler.RemoveInterfaceTag("tag", 1) - - Expect(err).ToNot(BeNil()) -} - -func ifTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.InterfaceVppAPI) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - ifHandler := vpp2001.NewInterfaceVppHandler(ctx.MockVPPClient, log) - return ctx, ifHandler -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/afpacket_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/afpacket_vppcalls.go deleted file mode 100644 index 0da6a6768a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/afpacket_vppcalls.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_afpacket "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/af_packet" -) - -// AddAfPacketInterface implements AfPacket handler. -func (h *InterfaceVppHandler) AddAfPacketInterface(ifName, hwAddr, targetHostIfName string) (swIndex uint32, err error) { - req := &vpp_afpacket.AfPacketCreate{ - HostIfName: targetHostIfName, - } - if hwAddr == "" { - req.UseRandomHwAddr = true - } else { - mac, err := ParseMAC(hwAddr) - if err != nil { - return 0, err - } - req.HwAddr = mac - } - reply := &vpp_afpacket.AfPacketCreateReply{} - - if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - - return uint32(reply.SwIfIndex), h.SetInterfaceTag(ifName, uint32(reply.SwIfIndex)) -} - -// DeleteAfPacketInterface implements AfPacket handler. -func (h *InterfaceVppHandler) DeleteAfPacketInterface(ifName string, idx uint32, targetHostIfName string) error { - req := &vpp_afpacket.AfPacketDelete{ - HostIfName: targetHostIfName, - } - reply := &vpp_afpacket.AfPacketDeleteReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return h.RemoveInterfaceTag(ifName, idx) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/afpacket_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/afpacket_vppcalls_test.go deleted file mode 100644 index 3be8d36066..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/afpacket_vppcalls_test.go +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2001" - - . "github.com/onsi/gomega" - vpp_afpacket "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/af_packet" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func TestAddAfPacketInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_afpacket.AfPacketCreateReply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - ifIndex, err := ifHandler.AddAfPacketInterface("if1", "", "host1") - - Expect(err).To(BeNil()) - Expect(ifIndex).ToNot(BeNil()) - Expect(len(ctx.MockChannel.Msgs)).To(BeEquivalentTo(2)) - for i, msg := range ctx.MockChannel.Msgs { - if i == 0 { - vppMsg, ok := msg.(*vpp_afpacket.AfPacketCreate) - Expect(ok).To(BeTrue()) - Expect(vppMsg).To(Equal(&vpp_afpacket.AfPacketCreate{ - HostIfName: "host1", - HwAddr: vpp_afpacket.MacAddress{}, - UseRandomHwAddr: true, - })) - } - } -} - -func TestAddAfPacketInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_afpacket.AfPacketDeleteReply{}) - - _, err := ifHandler.AddAfPacketInterface("if1", "", "host1") - - Expect(err).ToNot(BeNil()) -} - -func TestAddAfPacketInterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_afpacket.AfPacketCreateReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddAfPacketInterface("if1", "", "host1") - - Expect(err).ToNot(BeNil()) -} - -func TestDeleteAfPacketInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_afpacket.AfPacketDeleteReply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteAfPacketInterface("if1", 0, "host1") - - Expect(err).To(BeNil()) - Expect(len(ctx.MockChannel.Msgs)).To(BeEquivalentTo(2)) - for i, msg := range ctx.MockChannel.Msgs { - if i == 0 { - vppMsg, ok := msg.(*vpp_afpacket.AfPacketDelete) - Expect(ok).To(BeTrue()) - Expect(vppMsg).To(Equal(&vpp_afpacket.AfPacketDelete{ - HostIfName: "host1", - })) - } - } -} - -func TestDeleteAfPacketInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_afpacket.AfPacketCreateReply{}) - - err := ifHandler.DeleteAfPacketInterface("if1", 0, "host1") - - Expect(err).ToNot(BeNil()) -} - -func TestDeleteAfPacketInterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_afpacket.AfPacketDeleteReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteAfPacketInterface("if1", 0, "host1") - - Expect(err).ToNot(BeNil()) -} - -func TestAddAfPacketInterfaceMac(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_afpacket.AfPacketCreateReply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - ifIndex, err := ifHandler.AddAfPacketInterface("if1", "a2:01:01:01:01:01", "host1") - - Expect(err).To(BeNil()) - Expect(ifIndex).ToNot(BeNil()) - Expect(len(ctx.MockChannel.Msgs)).To(BeEquivalentTo(2)) - - mac, err := vpp2001.ParseMAC("a2:01:01:01:01:01") - Expect(err).To(BeNil()) - - for i, msg := range ctx.MockChannel.Msgs { - if i == 0 { - vppMsg, ok := msg.(*vpp_afpacket.AfPacketCreate) - Expect(ok).To(BeTrue()) - Expect(vppMsg).To(Equal(&vpp_afpacket.AfPacketCreate{ - HostIfName: "host1", - HwAddr: mac, - UseRandomHwAddr: false, - })) - } - } -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/bond_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/bond_vppcalls.go deleted file mode 100644 index e34d5c47da..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/bond_vppcalls.go +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_bond "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/bond" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) AddBondInterface(ifName string, mac string, bondLink *ifs.BondLink) (uint32, error) { - req := &vpp_bond.BondCreate{ - ID: bondLink.Id, - Mode: getBondMode(bondLink.Mode), - Lb: getLoadBalance(bondLink.Lb), - } - if mac != "" { - parsedMac, err := ParseMAC(mac) - if err != nil { - return 0, err - } - req.UseCustomMac = true - req.MacAddress = parsedMac - } - - reply := &vpp_bond.BondCreateReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - - return uint32(reply.SwIfIndex), h.SetInterfaceTag(ifName, uint32(reply.SwIfIndex)) -} - -func (h *InterfaceVppHandler) DeleteBondInterface(ifName string, ifIdx uint32) error { - req := &vpp_bond.BondDelete{ - SwIfIndex: vpp_bond.InterfaceIndex(ifIdx), - } - reply := &vpp_bond.BondDeleteReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return h.RemoveInterfaceTag(ifName, ifIdx) -} - -func getBondMode(mode ifs.BondLink_Mode) vpp_bond.BondMode { - switch mode { - case ifs.BondLink_ROUND_ROBIN: - return vpp_bond.BOND_API_MODE_ROUND_ROBIN - case ifs.BondLink_ACTIVE_BACKUP: - return vpp_bond.BOND_API_MODE_ACTIVE_BACKUP - case ifs.BondLink_XOR: - return vpp_bond.BOND_API_MODE_XOR - case ifs.BondLink_BROADCAST: - return vpp_bond.BOND_API_MODE_BROADCAST - case ifs.BondLink_LACP: - return vpp_bond.BOND_API_MODE_LACP - default: - // UNKNOWN - return 0 - } -} - -func (h *InterfaceVppHandler) AttachInterfaceToBond(ifIdx, bondIfIdx uint32, isPassive, isLongTimeout bool) error { - req := &vpp_bond.BondEnslave{ - SwIfIndex: vpp_bond.InterfaceIndex(ifIdx), - BondSwIfIndex: vpp_bond.InterfaceIndex(bondIfIdx), - IsPassive: isPassive, - IsLongTimeout: isLongTimeout, - } - reply := &vpp_bond.BondEnslaveReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *InterfaceVppHandler) DetachInterfaceFromBond(ifIdx uint32) error { - req := &vpp_bond.BondDetachSlave{ - SwIfIndex: vpp_bond.InterfaceIndex(ifIdx), - } - reply := &vpp_bond.BondDetachSlaveReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - return nil -} - -func getLoadBalance(lb ifs.BondLink_LoadBalance) vpp_bond.BondLbAlgo { - switch lb { - case ifs.BondLink_L34: - return vpp_bond.BOND_API_LB_ALGO_L34 - case ifs.BondLink_L23: - return vpp_bond.BOND_API_LB_ALGO_L23 - case ifs.BondLink_RR: - return vpp_bond.BOND_API_LB_ALGO_RR - case ifs.BondLink_BC: - return vpp_bond.BOND_API_LB_ALGO_BC - case ifs.BondLink_AB: - return vpp_bond.BOND_API_LB_ALGO_AB - default: - // L2 - return 0 - } -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/dhcp_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/dhcp_vppcalls.go deleted file mode 100644 index 35f375cbae..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/dhcp_vppcalls.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" -) - -func (h *InterfaceVppHandler) handleInterfaceDHCP(ifIdx uint32, hostName string, isAdd bool) error { - req := &vpp_dhcp.DHCPClientConfig{ - IsAdd: isAdd, - Client: vpp_dhcp.DHCPClient{ - SwIfIndex: vpp_dhcp.InterfaceIndex(ifIdx), - Hostname: hostName, - WantDHCPEvent: true, - }, - } - reply := &vpp_dhcp.DHCPClientConfigReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *InterfaceVppHandler) SetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error { - return h.handleInterfaceDHCP(ifIdx, hostName, true) -} - -func (h *InterfaceVppHandler) UnsetInterfaceAsDHCPClient(ifIdx uint32, hostName string) error { - return h.handleInterfaceDHCP(ifIdx, hostName, false) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/dhcp_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/dhcp_vppcalls_test.go deleted file mode 100644 index b9ec96b811..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/dhcp_vppcalls_test.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" -) - -func TestSetInterfaceAsDHCPClient(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_dhcp.DHCPClientConfigReply{}) - - err := ifHandler.SetInterfaceAsDHCPClient(1, "hostName") - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_dhcp.DHCPClientConfig) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Client.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Client.Hostname).To(BeEquivalentTo([]byte("hostName"))) - Expect(vppMsg.Client.WantDHCPEvent).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestSetInterfaceAsDHCPClientError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_dhcp.DHCPComplEvent{}) - - err := ifHandler.SetInterfaceAsDHCPClient(1, "hostName") - - Expect(err).ToNot(BeNil()) -} - -func TestSetInterfaceAsDHCPClientRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_dhcp.DHCPClientConfigReply{ - Retval: 1, - }) - - err := ifHandler.SetInterfaceAsDHCPClient(1, "hostName") - - Expect(err).ToNot(BeNil()) -} - -func TestUnsetInterfaceAsDHCPClient(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_dhcp.DHCPClientConfigReply{}) - - err := ifHandler.UnsetInterfaceAsDHCPClient(1, "hostName") - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_dhcp.DHCPClientConfig) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Client.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Client.Hostname).To(BeEquivalentTo([]byte("hostName"))) - Expect(vppMsg.Client.WantDHCPEvent).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func TestUnsetInterfaceAsDHCPClientError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_dhcp.DHCPComplEvent{}) - - err := ifHandler.UnsetInterfaceAsDHCPClient(1, "hostName") - - Expect(err).ToNot(BeNil()) -} - -func TestUnsetInterfaceAsDHCPClientRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_dhcp.DHCPClientConfigReply{ - Retval: 1, - }) - - err := ifHandler.UnsetInterfaceAsDHCPClient(1, "hostName") - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/doc.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/doc.go deleted file mode 100644 index 0d13d80b6a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package vppcalls contains wrappers over VPP binary APIs for all supported -// interface types and for dumping all interfaces configured in VPP. -package vpp2001 diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_status_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_status_test.go deleted file mode 100644 index 4628d2e55d..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_status_test.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "testing" - - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestIsAdminStateUp(t *testing.T) { - tests := []struct { - input vpp_ifs.IfStatusFlags - want bool - }{ - {input: 0, want: false}, - {input: 1, want: true}, - {input: 2, want: false}, - {input: 3, want: true}, - {input: 4, want: false}, - {input: 5, want: true}, - {input: 6, want: false}, - } - - for _, tc := range tests { - got := isAdminStateUp(tc.input) - if tc.want != got { - t.Fatalf("for input: %d, want: %v, got: %v", tc.input, tc.want, got) - } - } -} - -func TestIsLinkStateUp(t *testing.T) { - tests := []struct { - input vpp_ifs.IfStatusFlags - want bool - }{ - {input: 0, want: false}, - {input: 1, want: false}, - {input: 2, want: true}, - {input: 3, want: true}, - {input: 4, want: false}, - {input: 5, want: false}, - {input: 6, want: true}, - } - - for _, tc := range tests { - got := isLinkStateUp(tc.input) - if tc.want != got { - t.Fatalf("for input: %d, want: %v, got: %v", tc.input, tc.want, got) - } - } -} - -func TestAdminStateToInterfaceStatus(t *testing.T) { - tests := []struct { - input vpp_ifs.IfStatusFlags - want ifs.InterfaceState_Status - }{ - {input: 0, want: ifs.InterfaceState_DOWN}, - {input: 1, want: ifs.InterfaceState_UP}, - {input: 2, want: ifs.InterfaceState_DOWN}, - {input: 3, want: ifs.InterfaceState_UP}, - {input: 4, want: ifs.InterfaceState_DOWN}, - } - - for _, tc := range tests { - got := adminStateToInterfaceStatus(tc.input) - if tc.want != got { - t.Fatalf("for input: %d, want: %v, got: %v", tc.input, tc.want, got) - } - } -} - -func TestLinkStateToInterfaceStatus(t *testing.T) { - tests := []struct { - input vpp_ifs.IfStatusFlags - want ifs.InterfaceState_Status - }{ - {input: 0, want: ifs.InterfaceState_DOWN}, - {input: 1, want: ifs.InterfaceState_DOWN}, - {input: 2, want: ifs.InterfaceState_UP}, - {input: 3, want: ifs.InterfaceState_UP}, - {input: 4, want: ifs.InterfaceState_DOWN}, - } - - for _, tc := range tests { - got := linkStateToInterfaceStatus(tc.input) - if tc.want != got { - t.Fatalf("for input: %d, want: %v, got: %v", tc.input, tc.want, got) - } - } -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls.go deleted file mode 100644 index 3b32c311f3..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls.go +++ /dev/null @@ -1,1098 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "bytes" - "context" - "encoding/hex" - "fmt" - "net" - "strings" - - vpp_bond "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/bond" - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - vpp_gre "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gre" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipsec "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec_types" - vpp_memif "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memif" - vpp_tapv2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/tapv2" - vpp_vxlan "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan" - vpp_vxlangpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan_gpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" - ipsec "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipsec" -) - -const ( - // allInterfaces defines unspecified interface index - allInterfaces = ^uint32(0) - - // prefix prepended to internal names of untagged interfaces to construct unique - // logical names - untaggedIfPreffix = "UNTAGGED-" -) - -const ( - // Default VPP MTU value - defaultVPPMtu = 9216 - - // MAC length - macLength = 6 -) - -func getMtu(vppMtu uint16) uint32 { - // If default VPP MTU value is set, return 0 (it means MTU was not set in the NB config) - if vppMtu == defaultVPPMtu { - return 0 - } - return uint32(vppMtu) -} - -func (h *InterfaceVppHandler) DumpInterfacesByType(ctx context.Context, reqType ifs.Interface_Type) (map[uint32]*vppcalls.InterfaceDetails, error) { - // Dump all - ifs, err := h.DumpInterfaces(ctx) - if err != nil { - return nil, err - } - // Filter by type - for ifIdx, ifData := range ifs { - if ifData.Interface.Type != reqType { - delete(ifs, ifIdx) - } - } - - return ifs, nil -} - -func (h *InterfaceVppHandler) dumpInterfaces(ifIdxs ...uint32) (map[uint32]*vppcalls.InterfaceDetails, error) { - // map for the resulting interfaces - interfaces := make(map[uint32]*vppcalls.InterfaceDetails) - - ifIdx := allInterfaces - if len(ifIdxs) > 0 { - ifIdx = ifIdxs[0] - } - // First, dump all interfaces to create initial data. - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ifs.SwInterfaceDump{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - }) - for { - ifDetails := &vpp_ifs.SwInterfaceDetails{} - stop, err := reqCtx.ReceiveReply(ifDetails) - if stop { - break - } - if err != nil { - return nil, fmt.Errorf("failed to dump interface: %v", err) - } - - internalName := strings.TrimRight(ifDetails.InterfaceName, "\x00") - ifaceDevType := strings.TrimRight(ifDetails.InterfaceDevType, "\x00") - physAddr := make(net.HardwareAddr, macLength) - copy(physAddr, ifDetails.L2Address[:]) - - details := &vppcalls.InterfaceDetails{ - Interface: &ifs.Interface{ - Name: strings.TrimRight(ifDetails.Tag, "\x00"), - // the type may be amended later by further dumps - Type: guessInterfaceType(ifaceDevType, internalName), - Enabled: isAdminStateUp(ifDetails.Flags), - PhysAddress: net.HardwareAddr(ifDetails.L2Address[:]).String(), - Mtu: getMtu(ifDetails.LinkMtu), - }, - Meta: &vppcalls.InterfaceMeta{ - SwIfIndex: uint32(ifDetails.SwIfIndex), - SupSwIfIndex: ifDetails.SupSwIfIndex, - L2Address: physAddr, - InternalName: internalName, - DevType: ifaceDevType, - IsAdminStateUp: isAdminStateUp(ifDetails.Flags), - IsLinkStateUp: isLinkStateUp(ifDetails.Flags), - LinkDuplex: uint32(ifDetails.LinkDuplex), - LinkMTU: ifDetails.LinkMtu, - MTU: ifDetails.Mtu, - LinkSpeed: ifDetails.LinkSpeed, - SubID: ifDetails.SubID, - Tag: strings.TrimRight(ifDetails.Tag, "\x00"), - }, - } - - // sub interface - if ifDetails.SupSwIfIndex != uint32(ifDetails.SwIfIndex) { - details.Interface.Type = ifs.Interface_SUB_INTERFACE - details.Interface.Link = &ifs.Interface_Sub{ - Sub: &ifs.SubInterface{ - ParentName: interfaces[ifDetails.SupSwIfIndex].Interface.Name, - SubId: ifDetails.SubID, - TagRwOption: getTagRwOption(ifDetails.VtrOp), - PushDot1Q: uintToBool(uint8(ifDetails.VtrPushDot1q)), - Tag1: ifDetails.VtrTag1, - Tag2: ifDetails.VtrTag2, - }, - } - } - // Fill name for physical interfaces (they are mostly without tag) - switch details.Interface.Type { - case ifs.Interface_DPDK: - details.Interface.Name = internalName - case ifs.Interface_AF_PACKET: - details.Interface.Link = &ifs.Interface_Afpacket{ - Afpacket: &ifs.AfpacketLink{ - HostIfName: strings.TrimPrefix(internalName, "host-"), - }, - } - } - if details.Interface.Name == "" { - // untagged interface - generate a logical name for it - // (apart from local0 it will get removed by resync) - details.Interface.Name = untaggedIfPreffix + internalName - } - interfaces[uint32(ifDetails.SwIfIndex)] = details - } - - return interfaces, nil -} - -func (h *InterfaceVppHandler) DumpInterfaces(ctx context.Context) (map[uint32]*vppcalls.InterfaceDetails, error) { - interfaces, err := h.dumpInterfaces() - if err != nil { - return nil, err - } - - // Get DHCP clients - dhcpClients, err := h.DumpDhcpClients() - if err != nil { - return nil, fmt.Errorf("failed to dump interface DHCP clients: %v", err) - } - - // Get IP addresses before VRF - err = h.dumpIPAddressDetails(interfaces, false, dhcpClients) - if err != nil { - return nil, err - } - err = h.dumpIPAddressDetails(interfaces, true, dhcpClients) - if err != nil { - return nil, err - } - - // Get unnumbered interfaces - unnumbered, err := h.dumpUnnumberedDetails() - if err != nil { - return nil, fmt.Errorf("failed to dump unnumbered interfaces: %v", err) - } - - // dump VXLAN details before VRFs (used by isIpv6Interface) - err = h.dumpVxlanDetails(interfaces) - if err != nil { - return nil, err - } - - err = h.dumpVxLanGpeDetails(interfaces) - if err != nil { - return nil, err - } - - // Get interface VRF for every IP family, fill DHCP if set and resolve unnumbered interface setup - for _, ifData := range interfaces { - // VRF is stored in metadata for both, IPv4 and IPv6. If the interface is an IPv6 interface (it contains at least - // one IPv6 address), appropriate VRF is stored also in modelled data - ipv4Vrf, err := h.GetInterfaceVrf(ifData.Meta.SwIfIndex) - if err != nil { - return nil, fmt.Errorf("interface dump: failed to get IPv4 VRF from interface %d: %v", - ifData.Meta.SwIfIndex, err) - } - ifData.Meta.VrfIPv4 = ipv4Vrf - ipv6Vrf, err := h.GetInterfaceVrfIPv6(ifData.Meta.SwIfIndex) - if err != nil { - return nil, fmt.Errorf("interface dump: failed to get IPv6 VRF from interface %d: %v", - ifData.Meta.SwIfIndex, err) - } - ifData.Meta.VrfIPv6 = ipv6Vrf - if isIPv6If, err := isIpv6Interface(ifData.Interface); err != nil { - return interfaces, err - } else if isIPv6If { - ifData.Interface.Vrf = ipv6Vrf - } else { - ifData.Interface.Vrf = ipv4Vrf - } - - // DHCP - dhcpData, ok := dhcpClients[ifData.Meta.SwIfIndex] - if ok { - ifData.Interface.SetDhcpClient = true - ifData.Meta.Dhcp = dhcpData - } - // Unnumbered - ifWithIPIdx, ok := unnumbered[ifData.Meta.SwIfIndex] - if ok { - // Find unnumbered interface - var ifWithIPName string - ifWithIP, ok := interfaces[ifWithIPIdx] - if ok { - ifWithIPName = ifWithIP.Interface.Name - } else { - h.log.Debugf("cannot find name of the ip-interface for unnumbered %s", ifData.Interface.Name) - ifWithIPName = "" - } - ifData.Interface.Unnumbered = &ifs.Interface_Unnumbered{ - InterfaceWithIp: ifWithIPName, - } - } - } - - err = h.dumpMemifDetails(ctx, interfaces) - if err != nil { - return nil, err - } - - err = h.dumpTapDetails(interfaces) - if err != nil { - return nil, err - } - - err = h.dumpIPSecTunnelDetails(interfaces) - if err != nil { - return nil, err - } - - err = h.dumpVmxNet3Details(interfaces) - if err != nil { - return nil, err - } - - err = h.dumpBondDetails(interfaces) - if err != nil { - return nil, err - } - - err = h.dumpGreDetails(interfaces) - if err != nil { - return nil, err - } - - err = h.dumpGtpuDetails(interfaces) - if err != nil { - return nil, err - } - - err = h.dumpIpipDetails(interfaces) - if err != nil { - return nil, err - } - - // Rx-placement dump is last since it uses interface type-specific data - err = h.dumpRxPlacement(interfaces) - if err != nil { - return nil, err - } - - return interfaces, nil -} - -// DumpDhcpClients returns a slice of DhcpMeta with all interfaces and other DHCP-related information available -func (h *InterfaceVppHandler) DumpDhcpClients() (map[uint32]*vppcalls.Dhcp, error) { - dhcpData := make(map[uint32]*vppcalls.Dhcp) - reqCtx := h.callsChannel.SendMultiRequest(&vpp_dhcp.DHCPClientDump{}) - - for { - dhcpDetails := &vpp_dhcp.DHCPClientDetails{} - last, err := reqCtx.ReceiveReply(dhcpDetails) - if last { - break - } - if err != nil { - return nil, err - } - client := dhcpDetails.Client - lease := dhcpDetails.Lease - - // DHCP client data - dhcpClient := &vppcalls.Client{ - SwIfIndex: uint32(client.SwIfIndex), - Hostname: strings.TrimRight(client.Hostname, "\x00"), - ID: string(bytes.SplitN(client.ID, []byte{0x00}, 2)[0]), - WantDhcpEvent: client.WantDHCPEvent, - SetBroadcastFlag: client.SetBroadcastFlag, - PID: client.PID, - } - - // DHCP lease data - dhcpLease := &vppcalls.Lease{ - SwIfIndex: uint32(lease.SwIfIndex), - State: uint8(lease.State), - Hostname: strings.TrimRight(lease.Hostname, "\x00"), - IsIPv6: lease.IsIPv6, - HostAddress: dhcpAddressToString(lease.HostAddress, uint32(lease.MaskWidth), lease.IsIPv6), - RouterAddress: dhcpAddressToString(lease.RouterAddress, uint32(lease.MaskWidth), lease.IsIPv6), - HostMac: net.HardwareAddr(lease.HostMac[:]).String(), - } - - // DHCP metadata - dhcpData[uint32(client.SwIfIndex)] = &vppcalls.Dhcp{ - Client: dhcpClient, - Lease: dhcpLease, - } - } - - return dhcpData, nil -} - -// DumpInterfaceStates dumps link and administrative state of every interface. -func (h *InterfaceVppHandler) DumpInterfaceStates(ifIdxs ...uint32) (map[uint32]*vppcalls.InterfaceState, error) { - // Dump all interface states if not specified. - if len(ifIdxs) == 0 { - ifIdxs = []uint32{allInterfaces} - } - - ifStates := make(map[uint32]*vppcalls.InterfaceState) - for _, ifIdx := range ifIdxs { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ifs.SwInterfaceDump{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - }) - for { - ifDetails := &vpp_ifs.SwInterfaceDetails{} - stop, err := reqCtx.ReceiveReply(ifDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return nil, fmt.Errorf("failed to dump interface states: %v", err) - } - - physAddr := make(net.HardwareAddr, macLength) - copy(physAddr, ifDetails.L2Address[:]) - - ifaceState := vppcalls.InterfaceState{ - SwIfIndex: uint32(ifDetails.SwIfIndex), - InternalName: strings.TrimRight(ifDetails.InterfaceName, "\x00"), - PhysAddress: physAddr, - AdminState: adminStateToInterfaceStatus(ifDetails.Flags), - LinkState: linkStateToInterfaceStatus(ifDetails.Flags), - LinkDuplex: toLinkDuplex(ifDetails.LinkDuplex), - LinkSpeed: toLinkSpeed(ifDetails.LinkSpeed), - LinkMTU: ifDetails.LinkMtu, - } - ifStates[uint32(ifDetails.SwIfIndex)] = &ifaceState - } - } - - return ifStates, nil -} - -func toLinkDuplex(duplex vpp_ifs.LinkDuplex) ifs.InterfaceState_Duplex { - switch duplex { - case 1: - return ifs.InterfaceState_HALF - case 2: - return ifs.InterfaceState_FULL - default: - return ifs.InterfaceState_UNKNOWN_DUPLEX - } -} - -const megabit = 1000000 // one megabit in bytes - -func toLinkSpeed(speed uint32) uint64 { - switch speed { - case 1: - return 10 * megabit // 10M - case 2: - return 100 * megabit // 100M - case 4: - return 1000 * megabit // 1G - case 8: - return 10000 * megabit // 10G - case 16: - return 40000 * megabit // 40G - case 32: - return 100000 * megabit // 100G - default: - return 0 - } -} - -// Returns true if given interface contains at least one IPv6 address. For VxLAN, source and destination -// addresses are also checked -func isIpv6Interface(iface *ifs.Interface) (bool, error) { - if iface.Type == ifs.Interface_VXLAN_TUNNEL && iface.GetVxlan() != nil { - if ipAddress := net.ParseIP(iface.GetVxlan().SrcAddress); ipAddress.To4() == nil { - return true, nil - } - if ipAddress := net.ParseIP(iface.GetVxlan().DstAddress); ipAddress.To4() == nil { - return true, nil - } - } - for _, ifAddress := range iface.IpAddresses { - if ipAddress, _, err := net.ParseCIDR(ifAddress); err != nil { - return false, err - } else if ipAddress.To4() == nil { - return true, nil - } - } - return false, nil -} - -// dumpIPAddressDetails dumps IP address details of interfaces from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpIPAddressDetails(ifs map[uint32]*vppcalls.InterfaceDetails, isIPv6 bool, dhcpClients map[uint32]*vppcalls.Dhcp) error { - // Dump IP addresses of each interface. - for idx := range ifs { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ip.IPAddressDump{ - SwIfIndex: interface_types.InterfaceIndex(idx), - IsIPv6: isIPv6, - }) - for { - ipDetails := &vpp_ip.IPAddressDetails{} - stop, err := reqCtx.ReceiveReply(ipDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return fmt.Errorf("failed to dump interface %d IP address details: %v", idx, err) - } - h.processIPDetails(ifs, ipDetails, dhcpClients) - } - } - - return nil -} - -// processIPDetails processes ip.IPAddressDetails binary API message and fills the details into the provided interface map. -func (h *InterfaceVppHandler) processIPDetails(ifs map[uint32]*vppcalls.InterfaceDetails, ipDetails *vpp_ip.IPAddressDetails, dhcpClients map[uint32]*vppcalls.Dhcp) { - ifDetails, ifIdxExists := ifs[uint32(ipDetails.SwIfIndex)] - if !ifIdxExists { - return - } - - var ipAddr string - ipByte := make([]byte, 16) - copy(ipByte[:], ipDetails.Prefix.Address.Un.XXX_UnionData[:]) - if ipDetails.Prefix.Address.Af == ip_types.ADDRESS_IP6 { - ipAddr = fmt.Sprintf("%s/%d", net.IP(ipByte).To16().String(), uint32(ipDetails.Prefix.Len)) - } else { - ipAddr = fmt.Sprintf("%s/%d", net.IP(ipByte[:4]).To4().String(), uint32(ipDetails.Prefix.Len)) - } - - // skip IP addresses given by DHCP - if dhcpClient, hasDhcpClient := dhcpClients[uint32(ipDetails.SwIfIndex)]; hasDhcpClient { - if dhcpClient.Lease != nil && dhcpClient.Lease.HostAddress == ipAddr { - return - } - } - - ifDetails.Interface.IpAddresses = append(ifDetails.Interface.IpAddresses, ipAddr) -} - -// dumpTapDetails dumps tap interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpTapDetails(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - // Original TAP v1 was DEPRECATED - - // TAP v2 - reqCtx := h.callsChannel.SendMultiRequest(&vpp_tapv2.SwInterfaceTapV2Dump{ - SwIfIndex: ^vpp_tapv2.InterfaceIndex(0), - }) - for { - tapDetails := &vpp_tapv2.SwInterfaceTapV2Details{} - stop, err := reqCtx.ReceiveReply(tapDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return fmt.Errorf("failed to dump TAPv2 interface details: %v", err) - } - _, ifIdxExists := interfaces[tapDetails.SwIfIndex] - if !ifIdxExists { - continue - } - interfaces[tapDetails.SwIfIndex].Interface.Link = &ifs.Interface_Tap{ - Tap: &ifs.TapLink{ - Version: 2, - HostIfName: cleanString(tapDetails.HostIfName), - RxRingSize: uint32(tapDetails.RxRingSz), - TxRingSize: uint32(tapDetails.TxRingSz), - EnableGso: tapDetails.TapFlags&vpp_tapv2.TAP_FLAG_GSO == vpp_tapv2.TAP_FLAG_GSO, - }, - } - interfaces[tapDetails.SwIfIndex].Interface.Type = ifs.Interface_TAP - } - - return nil -} - -// dumpVxlanDetails dumps VXLAN interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpVxlanDetails(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_vxlan.VxlanTunnelDump{ - SwIfIndex: ^uint32(0), - }) - for { - vxlanDetails := &vpp_vxlan.VxlanTunnelDetails{} - stop, err := reqCtx.ReceiveReply(vxlanDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return fmt.Errorf("failed to dump VxLAN tunnel interface details: %v", err) - } - _, ifIdxExists := interfaces[vxlanDetails.SwIfIndex] - if !ifIdxExists { - continue - } - // Multicast interface - var multicastIfName string - _, exists := interfaces[vxlanDetails.McastSwIfIndex] - if exists { - multicastIfName = interfaces[vxlanDetails.McastSwIfIndex].Interface.Name - } - - if vxlanDetails.IsIPv6 == 1 { - interfaces[vxlanDetails.SwIfIndex].Interface.Link = &ifs.Interface_Vxlan{ - Vxlan: &ifs.VxlanLink{ - Multicast: multicastIfName, - SrcAddress: net.IP(vxlanDetails.SrcAddress).To16().String(), - DstAddress: net.IP(vxlanDetails.DstAddress).To16().String(), - Vni: vxlanDetails.Vni, - }, - } - } else { - interfaces[vxlanDetails.SwIfIndex].Interface.Link = &ifs.Interface_Vxlan{ - Vxlan: &ifs.VxlanLink{ - Multicast: multicastIfName, - SrcAddress: net.IP(vxlanDetails.SrcAddress[:4]).To4().String(), - DstAddress: net.IP(vxlanDetails.DstAddress[:4]).To4().String(), - Vni: vxlanDetails.Vni, - }, - } - } - interfaces[vxlanDetails.SwIfIndex].Interface.Type = ifs.Interface_VXLAN_TUNNEL - } - - return nil -} - -// dumpVxlanDetails dumps VXLAN-GPE interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpVxLanGpeDetails(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_vxlangpe.VxlanGpeTunnelDump{SwIfIndex: ^uint32(0)}) - for { - vxlanGpeDetails := &vpp_vxlangpe.VxlanGpeTunnelDetails{} - stop, err := reqCtx.ReceiveReply(vxlanGpeDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return fmt.Errorf("failed to dump VxLAN-GPE tunnel interface details: %v", err) - } - _, ifIdxExists := interfaces[vxlanGpeDetails.SwIfIndex] - if !ifIdxExists { - continue - } - // Multicast interface - var multicastIfName string - _, exists := interfaces[vxlanGpeDetails.McastSwIfIndex] - if exists { - multicastIfName = interfaces[vxlanGpeDetails.McastSwIfIndex].Interface.Name - } - - vxLan := &ifs.VxlanLink{ - Multicast: multicastIfName, - Vni: vxlanGpeDetails.Vni, - Gpe: &ifs.VxlanLink_Gpe{ - DecapVrfId: vxlanGpeDetails.DecapVrfID, - Protocol: getVxLanGpeProtocol(vxlanGpeDetails.Protocol), - }, - } - - if vxlanGpeDetails.IsIPv6 == 1 { - vxLan.SrcAddress = net.IP(vxlanGpeDetails.Local).To16().String() - vxLan.DstAddress = net.IP(vxlanGpeDetails.Remote).To16().String() - } else { - vxLan.SrcAddress = net.IP(vxlanGpeDetails.Local[:4]).To4().String() - vxLan.DstAddress = net.IP(vxlanGpeDetails.Remote[:4]).To4().String() - } - - interfaces[vxlanGpeDetails.SwIfIndex].Interface.Link = &ifs.Interface_Vxlan{Vxlan: vxLan} - interfaces[vxlanGpeDetails.SwIfIndex].Interface.Type = ifs.Interface_VXLAN_TUNNEL - } - - return nil -} - -// dumpIPSecTunnelDetails dumps IPSec tunnel interfaces from the VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpIPSecTunnelDetails(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - // tunnel interfaces are a part of security association dump - var tunnels []*vpp_ipsec.IpsecSaDetails - req := &vpp_ipsec.IpsecSaDump{ - SaID: ^uint32(0), - } - requestCtx := h.callsChannel.SendMultiRequest(req) - - for { - saDetails := &vpp_ipsec.IpsecSaDetails{} - stop, err := requestCtx.ReceiveReply(saDetails) - if stop { - break - } - if err != nil { - return err - } - // skip non-tunnel security associations - if saDetails.SwIfIndex != ^uint32(0) { - tunnels = append(tunnels, saDetails) - } - } - - // every tunnel interface is returned in two API calls. To reconstruct the correct proto-modelled data, - // first appearance is cached, and when the second part arrives, data are completed and stored. - tunnelParts := make(map[uint32]*vpp_ipsec.IpsecSaDetails) - - for _, tunnel := range tunnels { - // first appearance is stored in the map, the second one is used in configuration. - firstSaData, ok := tunnelParts[tunnel.SwIfIndex] - if !ok { - tunnelParts[tunnel.SwIfIndex] = tunnel - continue - } - - local := firstSaData - remote := tunnel - - // verify data for local & remote - if err := verifyIPSecTunnelDetails(local, remote); err != nil { - h.log.Warnf("IPSec SA dump for tunnel interface data does not match: %v", err) - continue - } - - var localIP, remoteIP net.IP - if tunnel.Entry.TunnelDst.Af == ip_types.ADDRESS_IP6 { - localSrc := local.Entry.TunnelSrc.Un.GetIP6() - remoteSrc := remote.Entry.TunnelSrc.Un.GetIP6() - localIP, remoteIP = net.IP(localSrc[:]), net.IP(remoteSrc[:]) - } else { - localSrc := local.Entry.TunnelSrc.Un.GetIP4() - remoteSrc := remote.Entry.TunnelSrc.Un.GetIP4() - localIP, remoteIP = net.IP(localSrc[:]), net.IP(remoteSrc[:]) - } - - ifDetails, ok := interfaces[tunnel.SwIfIndex] - if !ok { - h.log.Warnf("ipsec SA dump returned unrecognized swIfIndex: %v", tunnel.SwIfIndex) - continue - } - ifDetails.Interface.Type = ifs.Interface_IPSEC_TUNNEL - ifDetails.Interface.Link = &ifs.Interface_Ipsec{ - Ipsec: &ifs.IPSecLink{ - Esn: (tunnel.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_USE_ESN) != 0, - AntiReplay: (tunnel.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY) != 0, - LocalIp: localIP.String(), - RemoteIp: remoteIP.String(), - LocalSpi: local.Entry.Spi, - RemoteSpi: remote.Entry.Spi, - CryptoAlg: ipsec.CryptoAlg(tunnel.Entry.CryptoAlgorithm), - LocalCryptoKey: hex.EncodeToString(local.Entry.CryptoKey.Data[:local.Entry.CryptoKey.Length]), - RemoteCryptoKey: hex.EncodeToString(remote.Entry.CryptoKey.Data[:remote.Entry.CryptoKey.Length]), - IntegAlg: ipsec.IntegAlg(tunnel.Entry.IntegrityAlgorithm), - LocalIntegKey: hex.EncodeToString(local.Entry.IntegrityKey.Data[:local.Entry.IntegrityKey.Length]), - RemoteIntegKey: hex.EncodeToString(remote.Entry.IntegrityKey.Data[:remote.Entry.IntegrityKey.Length]), - EnableUdpEncap: (tunnel.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_UDP_ENCAP) != 0, - }, - } - } - - return nil -} - -func verifyIPSecTunnelDetails(local, remote *vpp_ipsec.IpsecSaDetails) error { - if local.SwIfIndex != remote.SwIfIndex { - return fmt.Errorf("swIfIndex data mismatch (local: %v, remote: %v)", - local.SwIfIndex, remote.SwIfIndex) - } - localIsTunnel := local.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL - remoteIsTunnel := remote.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL - if localIsTunnel != remoteIsTunnel { - return fmt.Errorf("tunnel data mismatch (local: %v, remote: %v)", - localIsTunnel, remoteIsTunnel) - } - - localSrc, localDst := local.Entry.TunnelSrc.Un.XXX_UnionData, local.Entry.TunnelDst.Un.XXX_UnionData - remoteSrc, remoteDst := remote.Entry.TunnelSrc.Un.XXX_UnionData, remote.Entry.TunnelDst.Un.XXX_UnionData - if (local.Entry.Flags&ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6) != (remote.Entry.Flags&ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6) || - !bytes.Equal(localSrc[:], remoteDst[:]) || - !bytes.Equal(localDst[:], remoteSrc[:]) { - return fmt.Errorf("src/dst IP mismatch (local: %+v, remote: %+v)", - local.Entry, remote.Entry) - } - - return nil -} - -// dumpBondDetails dumps bond interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpBondDetails(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - bondIndexes := make([]uint32, 0) - reqCtx := h.callsChannel.SendMultiRequest(&vpp_bond.SwInterfaceBondDump{}) - for { - bondDetails := &vpp_bond.SwInterfaceBondDetails{} - stop, err := reqCtx.ReceiveReply(bondDetails) - if err != nil { - return fmt.Errorf("failed to dump bond interface details: %v", err) - } - if stop { - break - } - _, ifIdxExists := interfaces[uint32(bondDetails.SwIfIndex)] - if !ifIdxExists { - continue - } - interfaces[uint32(bondDetails.SwIfIndex)].Interface.Link = &ifs.Interface_Bond{ - Bond: &ifs.BondLink{ - Id: bondDetails.ID, - Mode: getBondIfMode(bondDetails.Mode), - Lb: getBondLoadBalance(bondDetails.Lb), - }, - } - interfaces[uint32(bondDetails.SwIfIndex)].Interface.Type = ifs.Interface_BOND_INTERFACE - bondIndexes = append(bondIndexes, uint32(bondDetails.SwIfIndex)) - } - - // get slave interfaces for bonds - for _, bondIdx := range bondIndexes { - var bondSlaves []*ifs.BondLink_BondedInterface - reqSlCtx := h.callsChannel.SendMultiRequest(&vpp_bond.SwInterfaceSlaveDump{ - SwIfIndex: vpp_bond.InterfaceIndex(bondIdx), - }) - for { - slaveDetails := &vpp_bond.SwInterfaceSlaveDetails{} - stop, err := reqSlCtx.ReceiveReply(slaveDetails) - if err != nil { - return fmt.Errorf("failed to dump bond slave details: %v", err) - } - if stop { - break - } - slaveIf, ifIdxExists := interfaces[uint32(slaveDetails.SwIfIndex)] - if !ifIdxExists { - continue - } - bondSlaves = append(bondSlaves, &ifs.BondLink_BondedInterface{ - Name: slaveIf.Interface.Name, - IsPassive: slaveDetails.IsPassive, - IsLongTimeout: slaveDetails.IsLongTimeout, - }) - interfaces[bondIdx].Interface.GetBond().BondedInterfaces = bondSlaves - } - } - - return nil -} - -func (h *InterfaceVppHandler) dumpGreDetails(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - msg := &vpp_gre.GreTunnelDump{SwIfIndex: vpp_gre.InterfaceIndex(^uint32(0))} - reqCtx := h.callsChannel.SendMultiRequest(msg) - for { - greDetails := &vpp_gre.GreTunnelDetails{} - stop, err := reqCtx.ReceiveReply(greDetails) - if stop { - break - } - if err != nil { - return fmt.Errorf("failed to dump span: %v", err) - } - - tunnel := greDetails.Tunnel - swIfIndex := uint32(tunnel.SwIfIndex) - - var srcAddr, dstAddr net.IP - if tunnel.Src.Af == ip_types.ADDRESS_IP4 { - srcAddrArr := tunnel.Src.Un.GetIP4() - srcAddr = net.IP(srcAddrArr[:]) - } else { - srcAddrArr := tunnel.Src.Un.GetIP6() - srcAddr = net.IP(srcAddrArr[:]) - } - if tunnel.Dst.Af == ip_types.ADDRESS_IP4 { - dstAddrArr := tunnel.Dst.Un.GetIP4() - dstAddr = net.IP(dstAddrArr[:]) - } else { - dstAddrArr := tunnel.Dst.Un.GetIP6() - dstAddr = net.IP(dstAddrArr[:]) - } - - interfaces[swIfIndex].Interface.Link = &ifs.Interface_Gre{ - Gre: &ifs.GreLink{ - TunnelType: getGreTunnelType(tunnel.Type), - SrcAddr: srcAddr.String(), - DstAddr: dstAddr.String(), - OuterFibId: tunnel.OuterTableID, - SessionId: uint32(tunnel.SessionID), - }, - } - interfaces[swIfIndex].Interface.Type = ifs.Interface_GRE_TUNNEL - } - return nil -} - -// dumpUnnumberedDetails returns a map of unnumbered interface indexes, every with interface index of element with IP -func (h *InterfaceVppHandler) dumpUnnumberedDetails() (map[uint32]uint32, error) { - unIfMap := make(map[uint32]uint32) // unnumbered/ip-interface - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ip.IPUnnumberedDump{ - SwIfIndex: ^interface_types.InterfaceIndex(0), - }) - - for { - unDetails := &vpp_ip.IPUnnumberedDetails{} - last, err := reqCtx.ReceiveReply(unDetails) - if last { - break - } - if err != nil { - return nil, err - } - - unIfMap[uint32(unDetails.SwIfIndex)] = uint32(unDetails.IPSwIfIndex) - } - - return unIfMap, nil -} - -func (h *InterfaceVppHandler) dumpRxPlacement(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ifs.SwInterfaceRxPlacementDump{ - SwIfIndex: vpp_ifs.InterfaceIndex(^uint32(0)), - }) - for { - rxDetails := &vpp_ifs.SwInterfaceRxPlacementDetails{} - stop, err := reqCtx.ReceiveReply(rxDetails) - if err != nil { - return fmt.Errorf("failed to dump rx-placement details: %v", err) - } - if stop { - break - } - - ifData, ok := interfaces[uint32(rxDetails.SwIfIndex)] - if !ok { - h.log.Warnf("Received rx-placement data for unknown interface with index %d", rxDetails.SwIfIndex) - continue - } - - ifData.Interface.RxModes = append(ifData.Interface.RxModes, - &ifs.Interface_RxMode{ - Queue: rxDetails.QueueID, - Mode: getRxModeType(rxDetails.Mode), - }) - - var worker uint32 - if rxDetails.WorkerID > 0 { - worker = rxDetails.WorkerID - 1 - } - ifData.Interface.RxPlacements = append(ifData.Interface.RxPlacements, - &ifs.Interface_RxPlacement{ - Queue: rxDetails.QueueID, - Worker: worker, - MainThread: rxDetails.WorkerID == 0, - }) - } - return nil -} - -func dhcpAddressToString(address vpp_dhcp.Address, maskWidth uint32, isIPv6 bool) string { - dhcpIPByte := make([]byte, 16) - copy(dhcpIPByte[:], address.Un.XXX_UnionData[:]) - if isIPv6 { - return fmt.Sprintf("%s/%d", net.IP(dhcpIPByte).To16().String(), maskWidth) - } - return fmt.Sprintf("%s/%d", net.IP(dhcpIPByte[:4]).To4().String(), maskWidth) -} - -// guessInterfaceType attempts to guess the correct interface type from its internal name (as given by VPP). -// This is required mainly for those interface types, that do not provide dump binary API, -// such as loopback of af_packet. -func guessInterfaceType(ifDevType, ifName string) ifs.Interface_Type { - switch { - case ifDevType == "RDMA interface": - return ifs.Interface_RDMA - - case strings.HasPrefix(ifName, "loop"), - strings.HasPrefix(ifName, "local"): - return ifs.Interface_SOFTWARE_LOOPBACK - - case strings.HasPrefix(ifName, "memif"): - return ifs.Interface_MEMIF - - case strings.HasPrefix(ifName, "tap"): - return ifs.Interface_TAP - - case strings.HasPrefix(ifName, "host"): - return ifs.Interface_AF_PACKET - - case strings.HasPrefix(ifName, "vxlan"): - return ifs.Interface_VXLAN_TUNNEL - - case strings.HasPrefix(ifName, "ipsec"): - return ifs.Interface_IPSEC_TUNNEL - - case strings.HasPrefix(ifName, "vmxnet3"): - return ifs.Interface_VMXNET3_INTERFACE - - case strings.HasPrefix(ifName, "Bond"): - return ifs.Interface_BOND_INTERFACE - - case strings.HasPrefix(ifName, "gtpu"): - return ifs.Interface_GTPU_TUNNEL - - case strings.HasPrefix(ifName, "ipip"): - return ifs.Interface_IPIP_TUNNEL - - default: - return ifs.Interface_DPDK - } -} - -// memifModetoNB converts binary API type of memif mode to the northbound API type memif mode. -func memifModetoNB(mode vpp_memif.MemifMode) ifs.MemifLink_MemifMode { - switch mode { - case vpp_memif.MEMIF_MODE_API_IP: - return ifs.MemifLink_IP - case vpp_memif.MEMIF_MODE_API_PUNT_INJECT: - return ifs.MemifLink_PUNT_INJECT - default: - return ifs.MemifLink_ETHERNET - } -} - -// Convert binary API rx-mode to northbound representation -func getRxModeType(mode vpp_ifs.RxMode) ifs.Interface_RxMode_Type { - switch mode { - case 1: - return ifs.Interface_RxMode_POLLING - case 2: - return ifs.Interface_RxMode_INTERRUPT - case 3: - return ifs.Interface_RxMode_ADAPTIVE - case 4: - return ifs.Interface_RxMode_DEFAULT - default: - return ifs.Interface_RxMode_UNKNOWN - } -} - -func getBondIfMode(mode vpp_bond.BondMode) ifs.BondLink_Mode { - switch mode { - case vpp_bond.BOND_API_MODE_ROUND_ROBIN: - return ifs.BondLink_ROUND_ROBIN - case vpp_bond.BOND_API_MODE_ACTIVE_BACKUP: - return ifs.BondLink_ACTIVE_BACKUP - case vpp_bond.BOND_API_MODE_XOR: - return ifs.BondLink_XOR - case vpp_bond.BOND_API_MODE_BROADCAST: - return ifs.BondLink_BROADCAST - case vpp_bond.BOND_API_MODE_LACP: - return ifs.BondLink_LACP - default: - // UNKNOWN - return 0 - } -} - -func getBondLoadBalance(lb vpp_bond.BondLbAlgo) ifs.BondLink_LoadBalance { - switch lb { - case vpp_bond.BOND_API_LB_ALGO_L34: - return ifs.BondLink_L34 - case vpp_bond.BOND_API_LB_ALGO_L23: - return ifs.BondLink_L23 - case vpp_bond.BOND_API_LB_ALGO_RR: - return ifs.BondLink_RR - case vpp_bond.BOND_API_LB_ALGO_BC: - return ifs.BondLink_BC - case vpp_bond.BOND_API_LB_ALGO_AB: - return ifs.BondLink_AB - default: - return ifs.BondLink_L2 - } -} - -func getTagRwOption(op uint32) ifs.SubInterface_TagRewriteOptions { - switch op { - case 1: - return ifs.SubInterface_PUSH1 - case 2: - return ifs.SubInterface_PUSH2 - case 3: - return ifs.SubInterface_POP1 - case 4: - return ifs.SubInterface_POP2 - case 5: - return ifs.SubInterface_TRANSLATE11 - case 6: - return ifs.SubInterface_TRANSLATE12 - case 7: - return ifs.SubInterface_TRANSLATE21 - case 8: - return ifs.SubInterface_TRANSLATE22 - default: // disabled - return ifs.SubInterface_DISABLED - } -} - -func getGreTunnelType(tt vpp_gre.GreTunnelType) ifs.GreLink_Type { - switch tt { - case vpp_gre.GRE_API_TUNNEL_TYPE_L3: - return ifs.GreLink_L3 - case vpp_gre.GRE_API_TUNNEL_TYPE_TEB: - return ifs.GreLink_TEB - case vpp_gre.GRE_API_TUNNEL_TYPE_ERSPAN: - return ifs.GreLink_ERSPAN - default: - return ifs.GreLink_UNKNOWN - } -} - -func getVxLanGpeProtocol(p uint8) ifs.VxlanLink_Gpe_Protocol { - switch p { - case 1: - return ifs.VxlanLink_Gpe_IP4 - case 2: - return ifs.VxlanLink_Gpe_IP6 - case 3: - return ifs.VxlanLink_Gpe_ETHERNET - case 4: - return ifs.VxlanLink_Gpe_NSH - default: - return ifs.VxlanLink_Gpe_UNKNOWN - } -} - -func isAdminStateUp(flags vpp_ifs.IfStatusFlags) bool { - return flags&interface_types.IF_STATUS_API_FLAG_ADMIN_UP != 0 -} - -func isLinkStateUp(flags vpp_ifs.IfStatusFlags) bool { - return flags&interface_types.IF_STATUS_API_FLAG_LINK_UP != 0 -} - -func adminStateToInterfaceStatus(flags vpp_ifs.IfStatusFlags) ifs.InterfaceState_Status { - if isAdminStateUp(flags) { - return ifs.InterfaceState_UP - } - return ifs.InterfaceState_DOWN -} - -func linkStateToInterfaceStatus(flags vpp_ifs.IfStatusFlags) ifs.InterfaceState_Status { - if isLinkStateUp(flags) { - return ifs.InterfaceState_UP - } - return ifs.InterfaceState_DOWN -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls_test.go deleted file mode 100644 index f90bb856a4..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/dump_interface_vppcalls_test.go +++ /dev/null @@ -1,618 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "net" - "testing" - - govppapi "git.fd.io/govpp.git/api" - . "github.com/onsi/gomega" - - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - vpp_gtpu "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gtpu" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_interfaces "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipip" - vpp_memif "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memif" - vpp_tapv2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/tapv2" - vpp_vpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - vpp_vxlan "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -// Test dump of interfaces with vxlan type -func TestDumpInterfacesVxLan(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ipv61Parse := net.ParseIP("dead:beef:feed:face:cafe:babe:baad:c0de").To16() - ipv62Parse := net.ParseIP("d3ad:beef:feed:face:cafe:babe:baad:c0de").To16() - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_interfaces.SwInterfaceDump{}).GetMessageName(), - Ping: true, - Message: &vpp_interfaces.SwInterfaceDetails{ - InterfaceName: "vxlan1", - }, - }, - { - Name: (&vpp_interfaces.SwInterfaceGetTable{}).GetMessageName(), - Ping: false, - Message: &vpp_interfaces.SwInterfaceGetTableReply{}, - }, - { - Name: (&vpp_ip.IPAddressDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ip.IPAddressDetails{}, - }, - { - Name: (&vpp_memif.MemifSocketFilenameDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_memif.MemifDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_tapv2.SwInterfaceTapV2Dump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_vxlan.VxlanTunnelDump{}).GetMessageName(), - Ping: true, - Message: &vpp_vxlan.VxlanTunnelDetails{ - IsIPv6: 1, - SwIfIndex: 0, - SrcAddress: ipv61Parse, - DstAddress: ipv62Parse, - }, - }, - { - Name: (&vpp_gtpu.GtpuTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_ipip.IpipTunnelDump{}).GetMessageName(), - Ping: true, - }, - }) - - intfs, err := ifHandler.DumpInterfaces(ctx.Context) - Expect(err).To(BeNil()) - Expect(intfs).To(HaveLen(1)) - intface := intfs[0].Interface - - // Check vxlan - Expect(intface.GetVxlan().SrcAddress).To(Equal("dead:beef:feed:face:cafe:babe:baad:c0de")) - Expect(intface.GetVxlan().DstAddress).To(Equal("d3ad:beef:feed:face:cafe:babe:baad:c0de")) -} - -// Test dump of interfaces with host type -func TestDumpInterfacesHost(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_interfaces.SwInterfaceDump{}).GetMessageName(), - Ping: true, - Message: &vpp_interfaces.SwInterfaceDetails{ - InterfaceName: "host-localhost", - }, - }, - { - Name: (&vpp_interfaces.SwInterfaceGetTable{}).GetMessageName(), - Ping: false, - Message: &vpp_interfaces.SwInterfaceGetTableReply{}, - }, - { - Name: (&vpp_ip.IPAddressDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ip.IPAddressDetails{}, - }, - { - Name: (&vpp_memif.MemifSocketFilenameDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_memif.MemifDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_tapv2.SwInterfaceTapV2Dump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_vxlan.VxlanTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_gtpu.GtpuTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_ipip.IpipTunnelDump{}).GetMessageName(), - Ping: true, - }, - }) - - intfs, err := ifHandler.DumpInterfaces(ctx.Context) - Expect(err).To(BeNil()) - Expect(intfs).To(HaveLen(1)) - intface := intfs[0].Interface - - // Check interface data - Expect(intface.GetAfpacket().HostIfName).To(Equal("localhost")) -} - -// Test dump of interfaces with memif type -func TestDumpInterfacesMemif(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_interfaces.SwInterfaceDump{}).GetMessageName(), - Ping: true, - Message: &vpp_interfaces.SwInterfaceDetails{ - InterfaceName: "memif1", - }, - }, - { - Name: (&vpp_interfaces.SwInterfaceGetTable{}).GetMessageName(), - Ping: false, - Message: &vpp_interfaces.SwInterfaceGetTableReply{}, - }, - { - Name: (&vpp_ip.IPAddressDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ip.IPAddressDetails{}, - }, - { - Name: (&vpp_memif.MemifSocketFilenameDump{}).GetMessageName(), - Ping: true, - Message: &vpp_memif.MemifSocketFilenameDetails{ - SocketID: 1, - SocketFilename: "test", - }, - }, - { - Name: (&vpp_memif.MemifDump{}).GetMessageName(), - Ping: true, - Message: &vpp_memif.MemifDetails{ - ID: 2, - SwIfIndex: 0, - Role: 1, // Slave - Mode: 1, // IP - SocketID: 1, - RingSize: 0, - BufferSize: 0, - }, - }, - { - Name: (&vpp_tapv2.SwInterfaceTapV2Dump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_vxlan.VxlanTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_gtpu.GtpuTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_ipip.IpipTunnelDump{}).GetMessageName(), - Ping: true, - }, - }) - - intfs, err := ifHandler.DumpInterfaces(ctx.Context) - Expect(err).To(BeNil()) - Expect(intfs).To(HaveLen(1)) - intface := intfs[0].Interface - - // Check memif - Expect(intface.GetMemif().SocketFilename).To(Equal("test")) - Expect(intface.GetMemif().Id).To(Equal(uint32(2))) - Expect(intface.GetMemif().Mode).To(Equal(ifs.MemifLink_IP)) - Expect(intface.GetMemif().Master).To(BeFalse()) -} - -func TestDumpInterfacesTap2(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - hwAddr1Parse, err := vpp2001.ParseMAC("01:23:45:67:89:ab") - Expect(err).To(BeNil()) - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_interfaces.SwInterfaceDump{}).GetMessageName(), - Ping: true, - Message: &vpp_interfaces.SwInterfaceDetails{ - SwIfIndex: 0, - InterfaceName: "tap2", - Tag: "mytap2", - Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, - LinkMtu: 9216, - L2Address: hwAddr1Parse, - }, - }, - { - Name: (&vpp_interfaces.SwInterfaceGetTable{}).GetMessageName(), - Ping: false, - Message: &vpp_interfaces.SwInterfaceGetTableReply{ - Retval: 0, - VrfID: 42, - }, - }, - { - Name: (&vpp_ip.IPAddressDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ip.IPAddressDetails{}, - }, - { - Name: (&vpp_dhcp.DHCPClientDump{}).GetMessageName(), - Ping: true, - Message: &vpp_dhcp.DHCPClientDetails{ - Client: vpp_dhcp.DHCPClient{ - SwIfIndex: 0, - }, - }, - }, - { - Name: (&vpp_tapv2.SwInterfaceTapV2Dump{}).GetMessageName(), - Ping: true, - Message: &vpp_tapv2.SwInterfaceTapV2Details{ - SwIfIndex: 0, - HostIfName: "taptap2", - }, - }, - { - Name: (&vpp_vxlan.VxlanTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_gtpu.GtpuTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_ipip.IpipTunnelDump{}).GetMessageName(), - Ping: true, - }, - }) - - intfs, err := ifHandler.DumpInterfaces(ctx.Context) - Expect(err).To(BeNil()) - Expect(intfs).To(HaveLen(1)) - - intface := intfs[0].Interface - intMeta := intfs[0].Meta - - // This is last checked type, so it will be equal to that - Expect(intface.Type).To(Equal(ifs.Interface_TAP)) - Expect(intface.PhysAddress).To(Equal("01:23:45:67:89:ab")) - Expect(intface.Name).To(Equal("mytap2")) - Expect(intface.Mtu).To(Equal(uint32(0))) // default mtu - Expect(intface.Enabled).To(BeTrue()) - Expect(intface.Vrf).To(Equal(uint32(42))) - Expect(intface.SetDhcpClient).To(BeTrue()) - Expect(intface.GetTap().HostIfName).To(Equal("taptap2")) - Expect(intface.GetTap().Version).To(Equal(uint32(2))) - Expect(intMeta.VrfIPv4).To(Equal(uint32(42))) - Expect(intMeta.VrfIPv6).To(Equal(uint32(42))) -} - -// Test dump of memif socket details using standard reply mocking -func TestDumpMemifSocketDetails(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifSocketFilenameDetails{ - SocketID: 1, - SocketFilename: "test", - }) - - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - result, err := ifHandler.DumpMemifSocketDetails(ctx.Context) - Expect(err).To(BeNil()) - Expect(result).To(Not(BeEmpty())) - - socketID, ok := result["test"] - Expect(ok).To(BeTrue()) - Expect(socketID).To(Equal(uint32(1))) -} - -func TestDumpInterfacesRxPlacement(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_interfaces.SwInterfaceDump{}).GetMessageName(), - Ping: true, - Message: &vpp_interfaces.SwInterfaceDetails{ - InterfaceName: "memif1", - }, - }, - { - Name: (&vpp_interfaces.SwInterfaceGetTable{}).GetMessageName(), - Ping: false, - Message: &vpp_interfaces.SwInterfaceGetTableReply{}, - }, - { - Name: (&vpp_ip.IPAddressDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ip.IPAddressDetails{}, - }, - { - Name: (&vpp_memif.MemifSocketFilenameDump{}).GetMessageName(), - Ping: true, - Message: &vpp_memif.MemifSocketFilenameDetails{ - SocketID: 1, - SocketFilename: "test", - }, - }, - { - Name: (&vpp_memif.MemifDump{}).GetMessageName(), - Ping: true, - Message: &vpp_memif.MemifDetails{ - ID: 2, - SwIfIndex: 0, - Role: 1, // Slave - Mode: 1, // IP - SocketID: 1, - RingSize: 0, - BufferSize: 0, - }, - }, - { - Name: (&vpp_tapv2.SwInterfaceTapV2Dump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_vxlan.VxlanTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_gtpu.GtpuTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_ipip.IpipTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_interfaces.SwInterfaceRxPlacementDump{}).GetMessageName(), - Ping: true, - Messages: []govppapi.Message{ - &vpp_interfaces.SwInterfaceRxPlacementDetails{ - SwIfIndex: 0, - QueueID: 0, - WorkerID: 0, // main thread - Mode: 3, // adaptive - }, - &vpp_interfaces.SwInterfaceRxPlacementDetails{ - SwIfIndex: 0, - QueueID: 1, - WorkerID: 1, // worker 0 - Mode: 2, // interrupt - }, - &vpp_interfaces.SwInterfaceRxPlacementDetails{ - SwIfIndex: 0, - QueueID: 2, - WorkerID: 2, // worker 1 - Mode: 1, // polling - }, - }, - }, - }) - - intfs, err := ifHandler.DumpInterfaces(ctx.Context) - Expect(err).To(BeNil()) - Expect(intfs).To(HaveLen(1)) - intface := intfs[0].Interface - - // Check memif - Expect(intface.GetMemif().SocketFilename).To(Equal("test")) - Expect(intface.GetMemif().Id).To(Equal(uint32(2))) - Expect(intface.GetMemif().Mode).To(Equal(ifs.MemifLink_IP)) - Expect(intface.GetMemif().Master).To(BeFalse()) - - rxMode := intface.GetRxModes() - Expect(rxMode).To(HaveLen(3)) - Expect(rxMode[0].Queue).To(BeEquivalentTo(0)) - Expect(rxMode[0].Mode).To(BeEquivalentTo(ifs.Interface_RxMode_ADAPTIVE)) - Expect(rxMode[1].Queue).To(BeEquivalentTo(1)) - Expect(rxMode[1].Mode).To(BeEquivalentTo(ifs.Interface_RxMode_INTERRUPT)) - Expect(rxMode[2].Queue).To(BeEquivalentTo(2)) - Expect(rxMode[2].Mode).To(BeEquivalentTo(ifs.Interface_RxMode_POLLING)) - - rxPlacement := intface.GetRxPlacements() - Expect(rxPlacement).To(HaveLen(3)) - Expect(rxPlacement[0].Queue).To(BeEquivalentTo(0)) - Expect(rxPlacement[0].MainThread).To(BeTrue()) - Expect(rxPlacement[0].Worker).To(BeEquivalentTo(0)) - Expect(rxPlacement[1].Queue).To(BeEquivalentTo(1)) - Expect(rxPlacement[1].MainThread).To(BeFalse()) - Expect(rxPlacement[1].Worker).To(BeEquivalentTo(0)) - Expect(rxPlacement[2].Queue).To(BeEquivalentTo(2)) - Expect(rxPlacement[2].MainThread).To(BeFalse()) - Expect(rxPlacement[2].Worker).To(BeEquivalentTo(1)) -} - -// Test dump of interfaces with gtpu type -func TestDumpInterfacesGtpu(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ipv61Parse := ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xca, 0xfe, 0xba, 0xbe, 0xba, 0xad, 0xc0, 0xde, - }), - } - ipv62Parse := ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0xd3, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xca, 0xfe, 0xba, 0xbe, 0xba, 0xad, 0xc0, 0xde, - }), - } - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_interfaces.SwInterfaceDump{}).GetMessageName(), - Ping: true, - Message: &vpp_interfaces.SwInterfaceDetails{ - InterfaceName: "gtpu1", - }, - }, - { - Name: (&vpp_interfaces.SwInterfaceGetTable{}).GetMessageName(), - Ping: false, - Message: &vpp_interfaces.SwInterfaceGetTableReply{}, - }, - { - Name: (&vpp_ip.IPAddressDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ip.IPAddressDetails{}, - }, - { - Name: (&vpp_memif.MemifSocketFilenameDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_memif.MemifDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_tapv2.SwInterfaceTapV2Dump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_vxlan.VxlanTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_gtpu.GtpuTunnelDump{}).GetMessageName(), - Ping: true, - Message: &vpp_gtpu.GtpuTunnelDetails{ - SwIfIndex: 0, - SrcAddress: ipv61Parse, - DstAddress: ipv62Parse, - EncapVrfID: 16, - Teid: 100, - }, - }, - { - Name: (&vpp_ipip.IpipTunnelDump{}).GetMessageName(), - Ping: true, - }, - }) - - intfs, err := ifHandler.DumpInterfaces(ctx.Context) - Expect(err).To(BeNil()) - Expect(intfs).To(HaveLen(1)) - intface := intfs[0].Interface - - // Check gtpu - Expect(intface.Type).To(Equal(ifs.Interface_GTPU_TUNNEL)) - Expect(intface.GetGtpu().SrcAddr).To(Equal("dead:beef:feed:face:cafe:babe:baad:c0de")) - Expect(intface.GetGtpu().DstAddr).To(Equal("d3ad:beef:feed:face:cafe:babe:baad:c0de")) - Expect(intface.GetGtpu().EncapVrfId).To(Equal(uint32(16))) - Expect(intface.GetGtpu().Teid).To(Equal(uint32(100))) -} - -// Test dump of interfaces with IPIP type -func TestDumpInterfacesIPIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_interfaces.SwInterfaceDump{}).GetMessageName(), - Ping: true, - Message: &vpp_interfaces.SwInterfaceDetails{ - InterfaceName: "vxlan1", - }, - }, - { - Name: (&vpp_interfaces.SwInterfaceGetTable{}).GetMessageName(), - Ping: false, - Message: &vpp_interfaces.SwInterfaceGetTableReply{}, - }, - { - Name: (&vpp_ip.IPAddressDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ip.IPAddressDetails{}, - }, - { - Name: (&vpp_memif.MemifSocketFilenameDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_memif.MemifDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_tapv2.SwInterfaceTapV2Dump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_vxlan.VxlanTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_gtpu.GtpuTunnelDump{}).GetMessageName(), - Ping: true, - }, - { - Name: (&vpp_ipip.IpipTunnelDump{}).GetMessageName(), - Ping: true, - Message: &vpp_ipip.IpipTunnelDetails{ - Tunnel: vpp_ipip.IpipTunnel{ - Dst: ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xca, 0xfe, 0xba, 0xbe, 0xba, 0xad, 0xc0, 0xde, - })}, - Src: ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0xd3, 0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce, 0xca, 0xfe, 0xba, 0xbe, 0xba, 0xad, 0xc0, 0xde, - })}, - }, - }, - }, - }) - - intfs, err := ifHandler.DumpInterfaces(ctx.Context) - Expect(err).To(BeNil()) - Expect(intfs).To(HaveLen(1)) - intface := intfs[0].Interface - - // Check IPIP - Expect(intface.GetIpip()).ToNot(BeNil()) - Expect(intface.GetIpip().DstAddr).To(Equal("dead:beef:feed:face:cafe:babe:baad:c0de")) - Expect(intface.GetIpip().SrcAddr).To(Equal("d3ad:beef:feed:face:cafe:babe:baad:c0de")) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/gre_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/gre_vppcalls.go deleted file mode 100644 index 1e4dad64e5..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/gre_vppcalls.go +++ /dev/null @@ -1,125 +0,0 @@ -package vpp2001 - -import ( - "errors" - "net" - - vpp_gre "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gre" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) greAddDelTunnel(isAdd bool, greLink *ifs.GreLink) (uint32, error) { - if greLink.TunnelType == ifs.GreLink_UNKNOWN { - err := errors.New("bad GRE tunnel type") - return 0, err - } - - greSource := net.ParseIP(greLink.SrcAddr) - if greSource == nil { - err := errors.New("bad source address for GRE tunnel") - return 0, err - } - greDestination := net.ParseIP(greLink.DstAddr) - if greDestination == nil { - err := errors.New("bad destination address for GRE tunnel") - return 0, err - } - - if greLink.SrcAddr == greLink.DstAddr { - err := errors.New("source and destination are the same") - return 0, err - } - - if greLink.TunnelType == ifs.GreLink_ERSPAN && greLink.SessionId > 1023 { - err := errors.New("set session id for ERSPAN tunnel type") - return 0, err - } - - var tt vpp_gre.GreTunnelType - switch greLink.TunnelType { - case ifs.GreLink_L3: - tt = vpp_gre.GRE_API_TUNNEL_TYPE_L3 - case ifs.GreLink_TEB: - tt = vpp_gre.GRE_API_TUNNEL_TYPE_TEB - case ifs.GreLink_ERSPAN: - tt = vpp_gre.GRE_API_TUNNEL_TYPE_ERSPAN - default: - return 0, errors.New("bad GRE tunnel type") - } - - tunnel := vpp_gre.GreTunnel{ - Type: tt, - Mode: vpp_gre.GRE_API_TUNNEL_MODE_P2P, // TODO: add mode to proto model - Instance: ^uint32(0), - OuterTableID: greLink.OuterFibId, - SessionID: uint16(greLink.SessionId), - } - - var isSrcIPv6, isDstIPv6 bool - - if greSource.To4() == nil { - isSrcIPv6 = true - } - if greDestination.To4() == nil { - isDstIPv6 = true - } - if isSrcIPv6 != isDstIPv6 { - return 0, errors.New("source and destination addresses must be both either in IPv4 or IPv6") - } - - if isSrcIPv6 { - var src, dst [16]uint8 - copy(src[:], greSource.To16()) - copy(dst[:], greDestination.To16()) - tunnel.Src = vpp_gre.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(src), - } - tunnel.Dst = vpp_gre.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(dst), - } - } else { - var src, dst [4]uint8 - copy(src[:], greSource.To4()) - copy(dst[:], greDestination.To4()) - tunnel.Src = vpp_gre.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(src), - } - tunnel.Dst = vpp_gre.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(dst), - } - } - - req := &vpp_gre.GreTunnelAddDel{ - IsAdd: isAdd, - Tunnel: tunnel, - } - reply := &vpp_gre.GreTunnelAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - return uint32(reply.SwIfIndex), nil -} - -// AddGreTunnel adds new GRE interface. -func (h *InterfaceVppHandler) AddGreTunnel(ifName string, greLink *ifs.GreLink) (uint32, error) { - swIfIndex, err := h.greAddDelTunnel(true, greLink) - if err != nil { - return 0, err - } - return swIfIndex, h.SetInterfaceTag(ifName, swIfIndex) -} - -// DelGreTunnel removes GRE interface. -func (h *InterfaceVppHandler) DelGreTunnel(ifName string, greLink *ifs.GreLink) (uint32, error) { - swIfIndex, err := h.greAddDelTunnel(false, greLink) - if err != nil { - return 0, err - } - return swIfIndex, h.RemoveInterfaceTag(ifName, swIfIndex) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/gtpu_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/gtpu_vppcalls.go deleted file mode 100644 index bd7e5f2c11..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/gtpu_vppcalls.go +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (c) 2019 EMnify -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gtpu" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -const defaultDecapNextIndex = 0xFFFFFFFF - -func (h *InterfaceVppHandler) gtpuAddDelTunnel(isAdd bool, gtpuLink *interfaces.GtpuLink, multicastIf uint32) (uint32, error) { - var decapNextNode uint32 = defaultDecapNextIndex - if gtpuLink.DecapNextNode != 0 { - decapNextNode = gtpuLink.DecapNextNode - } else { - // backwards compatible fallback - if gtpuLink.DecapNext != interfaces.GtpuLink_DEFAULT { - decapNextNode = uint32(gtpuLink.DecapNext) - } - } - - req := >pu.GtpuAddDelTunnel{ - IsAdd: isAdd, - McastSwIfIndex: interface_types.InterfaceIndex(multicastIf), - EncapVrfID: gtpuLink.EncapVrfId, - Teid: gtpuLink.Teid, - DecapNextIndex: decapNextNode, - } - - srcAddr := net.ParseIP(gtpuLink.SrcAddr) - if srcAddr == nil { - err := errors.New("bad source address for GTPU tunnel") - return 0, err - } - - dstAddr := net.ParseIP(gtpuLink.DstAddr) - if dstAddr == nil { - err := errors.New("bad destination address for GTPU tunnel") - return 0, err - } - - if gtpuLink.SrcAddr == gtpuLink.DstAddr { - err := errors.New("source and destination are the same") - return 0, err - } - - var isSrcIPv6, isDstIPv6 bool - - if srcAddr.To4() == nil { - isSrcIPv6 = true - } - if dstAddr.To4() == nil { - isDstIPv6 = true - } - - if !isSrcIPv6 && !isDstIPv6 { - var src, dst [4]uint8 - copy(src[:], srcAddr.To4()) - copy(dst[:], dstAddr.To4()) - req.SrcAddress = ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(src), - } - req.DstAddress = ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(dst), - } - } else if isSrcIPv6 && isDstIPv6 { - var src, dst [16]uint8 - copy(src[:], srcAddr.To16()) - copy(dst[:], dstAddr.To16()) - req.SrcAddress = ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(src), - } - req.DstAddress = ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(dst), - } - } else { - return 0, errors.New("source and destination addresses must be both either IPv4 or IPv6") - } - - reply := >pu.GtpuAddDelTunnelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - return uint32(reply.SwIfIndex), nil -} - -// AddGtpuTunnel adds new GTPU interface. -func (h *InterfaceVppHandler) AddGtpuTunnel(ifName string, gtpuLink *interfaces.GtpuLink, multicastIf uint32) (uint32, error) { - if h.gtpu == nil { - return 0, errors.WithMessage(vpp.ErrPluginDisabled, "gtpu") - } - if gtpuLink == nil { - return 0, errors.New("missing GTPU tunnel information") - } - - swIfIndex, err := h.gtpuAddDelTunnel(true, gtpuLink, multicastIf) - if err != nil { - return 0, err - } - return swIfIndex, h.SetInterfaceTag(ifName, swIfIndex) -} - -// DelGtpuTunnel removes GTPU interface. -func (h *InterfaceVppHandler) DelGtpuTunnel(ifName string, gtpuLink *interfaces.GtpuLink) error { - if h.gtpu == nil { - return errors.WithMessage(vpp.ErrPluginDisabled, "gtpu") - } - if gtpuLink == nil { - return errors.New("missing GTPU tunnel information") - } - - swIfIndex, err := h.gtpuAddDelTunnel(false, gtpuLink, 0) - if err != nil { - return err - } - return h.RemoveInterfaceTag(ifName, swIfIndex) -} - -// dumpGtpuDetails dumps GTP-U interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpGtpuDetails(ifc map[uint32]*vppcalls.InterfaceDetails) error { - if h.gtpu == nil { - // no-op when disabled - return nil - } - - reqCtx := h.callsChannel.SendMultiRequest(>pu.GtpuTunnelDump{ - SwIfIndex: ^interface_types.InterfaceIndex(0), - }) - for { - gtpuDetails := >pu.GtpuTunnelDetails{} - stop, err := reqCtx.ReceiveReply(gtpuDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return fmt.Errorf("failed to dump GTP-U tunnel interface details: %v", err) - } - _, ifIdxExists := ifc[uint32(gtpuDetails.SwIfIndex)] - if !ifIdxExists { - continue - } - // Multicast interface - var multicastIfName string - _, exists := ifc[uint32(gtpuDetails.McastSwIfIndex)] - if exists { - multicastIfName = ifc[uint32(gtpuDetails.McastSwIfIndex)].Interface.Name - } - - gtpuLink := &interfaces.GtpuLink{ - Multicast: multicastIfName, - EncapVrfId: gtpuDetails.EncapVrfID, - Teid: gtpuDetails.Teid, - DecapNext: interfaces.GtpuLink_NextNode(gtpuDetails.DecapNextIndex), - DecapNextNode: gtpuDetails.DecapNextIndex, - } - - if gtpuDetails.SrcAddress.Af == ip_types.ADDRESS_IP6 { - srcAddrArr := gtpuDetails.SrcAddress.Un.GetIP6() - gtpuLink.SrcAddr = net.IP(srcAddrArr[:]).To16().String() - dstAddrArr := gtpuDetails.DstAddress.Un.GetIP6() - gtpuLink.DstAddr = net.IP(dstAddrArr[:]).To16().String() - } else { - srcAddrArr := gtpuDetails.SrcAddress.Un.GetIP4() - gtpuLink.SrcAddr = net.IP(srcAddrArr[:4]).To4().String() - dstAddrArr := gtpuDetails.DstAddress.Un.GetIP4() - gtpuLink.DstAddr = net.IP(dstAddrArr[:4]).To4().String() - } - - ifc[uint32(gtpuDetails.SwIfIndex)].Interface.Link = &interfaces.Interface_Gtpu{Gtpu: gtpuLink} - ifc[uint32(gtpuDetails.SwIfIndex)].Interface.Type = interfaces.Interface_GTPU_TUNNEL - } - - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/gtpu_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/gtpu_vppcalls_test.go deleted file mode 100644 index 4dba8650b8..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/gtpu_vppcalls_test.go +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright (c) 2019 EMnify -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_gtpu "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gtpu" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddGtpuTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.1", - EncapVrfId: 10, - Teid: 100, - }, 2) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_gtpu.GtpuAddDelTunnel) - if ok { - Expect(vppMsg.SrcAddress).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(ip_types.IP4Address{10, 0, 0, 1}), - })) - Expect(vppMsg.DstAddress).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(ip_types.IP4Address{20, 0, 0, 1}), - })) - Expect(vppMsg.IsAdd).To(BeTrue()) - Expect(vppMsg.EncapVrfID).To(BeEquivalentTo(10)) - Expect(vppMsg.McastSwIfIndex).To(BeEquivalentTo(2)) - Expect(vppMsg.Teid).To(BeEquivalentTo(100)) - Expect(vppMsg.SrcAddress.Af).To(Equal(ip_types.ADDRESS_IP4)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddGtpuTunnelIPv6(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "2001:db8:0:1:1:1:1:1", - DstAddr: "2002:db8:0:1:1:1:1:1", - EncapVrfId: 10, - Teid: 200, - }, 0xFFFFFFFF) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_gtpu.GtpuAddDelTunnel) - if ok { - Expect(vppMsg.SrcAddress).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, - }), - })) - Expect(vppMsg.DstAddress).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0x20, 0x02, 0x0d, 0xb8, 0, 0, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, - }), - })) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddGtpuTunnelIPMismatch(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0.1", - DstAddr: "2001:db8:0:1:1:1:1:1", - EncapVrfId: 0, - Teid: 100, - }, 0xFFFFFFFF) - Expect(err).ToNot(BeNil()) -} - -func TestAddGtpuTunnelInvalidIPv4(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0", - DstAddr: "20.0.0.1", - EncapVrfId: 0, - Teid: 100, - }, 0xFFFFFFFF) - Expect(err).ToNot(BeNil()) -} - -func TestAddGtpuTunnelInvalidIPv6(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "2001:db8:0:1:1:1:1:1", - DstAddr: "2002:db8:0:1:1:1:1:1:1", - EncapVrfId: 0, - Teid: 100, - }, 0xFFFFFFFF) - Expect(err).ToNot(BeNil()) -} - -func TestAddGtpuTunnelError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnel{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.2", - EncapVrfId: 0, - Teid: 100, - }, 0xFFFFFFFF) - Expect(err).ToNot(BeNil()) -} - -func TestAddGtpuTunnelRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.2", - EncapVrfId: 0, - Teid: 100, - }, 0xFFFFFFFF) - Expect(err).ToNot(BeNil()) -} - -func TestDelGtpuTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DelGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.2", - EncapVrfId: 0, - Teid: 100, - }) - Expect(err).To(BeNil()) -} - -func TestDelGtpuTunnelError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnel{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DelGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.2", - EncapVrfId: 0, - Teid: 100, - }) - Expect(err).ToNot(BeNil()) -} - -func TestDelGtpuTunnelRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnelReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DelGtpuTunnel("ifName", &ifs.GtpuLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.1", - EncapVrfId: 0, - Teid: 100, - }) - Expect(err).ToNot(BeNil()) -} - -func TestAddNilGtpuTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnel{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddGtpuTunnel("ifName", nil, 0xFFFFFFFF) - Expect(err).ToNot(BeNil()) -} - -func TestDelNilGtpuTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_gtpu.GtpuAddDelTunnel{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DelGtpuTunnel("ifName", nil) - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/helpers.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/helpers.go deleted file mode 100644 index 3b728829af..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/helpers.go +++ /dev/null @@ -1,44 +0,0 @@ -package vpp2001 - -import ( - "fmt" - "net" - "strings" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -// IPToAddress converts string type IP address to VPP ip.api address representation -func IPToAddress(ipStr string) (addr ip_types.Address, err error) { - netIP := net.ParseIP(ipStr) - if netIP == nil { - return ip_types.Address{}, fmt.Errorf("invalid IP: %q", ipStr) - } - if ip4 := netIP.To4(); ip4 == nil { - addr.Af = ip_types.ADDRESS_IP6 - var ip6addr ip_types.IP6Address - copy(ip6addr[:], netIP.To16()) - addr.Un.SetIP6(ip6addr) - } else { - addr.Af = ip_types.ADDRESS_IP4 - var ip4addr ip_types.IP4Address - copy(ip4addr[:], ip4) - addr.Un.SetIP4(ip4addr) - } - return -} - -func boolToUint(input bool) uint8 { - if input { - return 1 - } - return 0 -} - -func uintToBool(value uint8) bool { - return value != 0 -} - -func cleanString(s string) string { - return strings.SplitN(s, "\x00", 2)[0] -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip6nd_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ip6nd_vppcalls.go deleted file mode 100644 index 1ea558292f..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip6nd_vppcalls.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/rd_cp" -) - -func (h *InterfaceVppHandler) SetIP6ndAutoconfig(ctx context.Context, ifIdx uint32, enable, installDefaultRoutes bool) error { - _, err := h.rpcRdCp.IP6NdAddressAutoconfig(ctx, &rd_cp.IP6NdAddressAutoconfig{ - SwIfIndex: interface_types.InterfaceIndex(ifIdx), - Enable: enable, - InstallDefaultRoutes: installDefaultRoutes, - }) - if err != nil { - return err - } - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_container_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_container_vppcalls.go deleted file mode 100644 index 6dae9bbc79..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_container_vppcalls.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "go.ligato.io/cn-infra/v2/utils/addrs" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -func (h *InterfaceVppHandler) sendAndLogMessageForVpp(ifIdx uint32, addr string, isAdd bool) error { - req := &vpp_ip.IPContainerProxyAddDel{ - SwIfIndex: interface_types.InterfaceIndex(ifIdx), - IsAdd: isAdd, - } - - IPaddr, isIPv6, err := addrs.ParseIPWithPrefix(addr) - if err != nil { - return err - } - - prefix, _ := IPaddr.Mask.Size() - req.Pfx.Len = byte(prefix) - if isIPv6 { - copy(req.Pfx.Address.Un.XXX_UnionData[:], IPaddr.IP.To16()) - req.Pfx.Address.Af = ip_types.ADDRESS_IP6 - } else { - copy(req.Pfx.Address.Un.XXX_UnionData[:], IPaddr.IP.To4()) - req.Pfx.Address.Af = ip_types.ADDRESS_IP4 - } - reply := &vpp_ip.IPContainerProxyAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *InterfaceVppHandler) AddContainerIP(ifIdx uint32, addr string) error { - return h.sendAndLogMessageForVpp(ifIdx, addr, true) -} - -func (h *InterfaceVppHandler) DelContainerIP(ifIdx uint32, addr string) error { - return h.sendAndLogMessageForVpp(ifIdx, addr, false) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_container_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_container_vppcalls_test.go deleted file mode 100644 index 55eaf2454a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_container_vppcalls_test.go +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "fmt" - "testing" - - . "github.com/onsi/gomega" - - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2001" -) - -func ipToAddr(ip string) vpp_ip.Address { - addr, err := vpp2001.IPToAddress(ip) - if err != nil { - panic(fmt.Sprintf("invalid IP: %s", ip)) - } - return addr -} - -func TestAddContainerIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPContainerProxyAddDelReply{}) - - err := ifHandler.AddContainerIP(1, "10.0.0.1/24") - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPContainerProxyAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Pfx).To(BeEquivalentTo(vpp_ip.Prefix{ - Address: ipToAddr("10.0.0.1"), - Len: 24, - })) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestAddContainerIPv6(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPContainerProxyAddDelReply{}) - - err := ifHandler.AddContainerIP(1, "2001:db8:0:1:1:1:1:1/128") - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPContainerProxyAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Pfx).To(BeEquivalentTo(vpp_ip.Prefix{ - Address: ipToAddr("2001:db8:0:1:1:1:1:1"), - Len: 128, - })) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestAddContainerIPInvalidIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPAddressDetails{}) - - err := ifHandler.AddContainerIP(1, "invalid-ip") - - Expect(err).ToNot(BeNil()) -} - -func TestAddContainerIPError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPAddressDetails{}) - - err := ifHandler.AddContainerIP(1, "10.0.0.1/24") - - Expect(err).ToNot(BeNil()) -} - -func TestAddContainerIPRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPContainerProxyAddDelReply{ - Retval: 1, - }) - - err := ifHandler.AddContainerIP(1, "10.0.0.1/24") - - Expect(err).ToNot(BeNil()) -} - -func TestDelContainerIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPContainerProxyAddDelReply{}) - - err := ifHandler.DelContainerIP(1, "10.0.0.1/24") - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPContainerProxyAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Pfx).To(BeEquivalentTo(vpp_ip.Prefix{ - Address: ipToAddr("10.0.0.1"), - Len: 24, - })) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func TestDelContainerIPv6(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPContainerProxyAddDelReply{}) - - err := ifHandler.DelContainerIP(1, "2001:db8:0:1:1:1:1:1/128") - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPContainerProxyAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Pfx).To(BeEquivalentTo(vpp_ip.Prefix{ - Address: ipToAddr("2001:db8:0:1:1:1:1:1"), - Len: 128, - })) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func TestDelContainerIPError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPAddressDetails{}) - - err := ifHandler.DelContainerIP(1, "10.0.0.1/24") - - Expect(err).ToNot(BeNil()) -} - -func TestDelContainerIPRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPContainerProxyAddDelReply{ - Retval: 1, - }) - - err := ifHandler.DelContainerIP(1, "10.0.0.1/24") - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_vppcalls.go deleted file mode 100644 index 873104db5e..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_vppcalls.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "net" - - "go.ligato.io/cn-infra/v2/utils/addrs" - - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -func (h *InterfaceVppHandler) addDelInterfaceIP(ifIdx uint32, addr *net.IPNet, isAdd bool) error { - req := &vpp_ifs.SwInterfaceAddDelAddress{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - IsAdd: isAdd, - } - - isIPv6, err := addrs.IsIPv6(addr.IP.String()) - if err != nil { - return err - } - req.Prefix.Address = ipToAddress(addr, isIPv6) - prefix, _ := addr.Mask.Size() - req.Prefix.Len = byte(prefix) - - reply := &vpp_ifs.SwInterfaceAddDelAddressReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *InterfaceVppHandler) AddInterfaceIP(ifIdx uint32, addr *net.IPNet) error { - return h.addDelInterfaceIP(ifIdx, addr, true) -} - -func (h *InterfaceVppHandler) DelInterfaceIP(ifIdx uint32, addr *net.IPNet) error { - return h.addDelInterfaceIP(ifIdx, addr, false) -} - -func (h *InterfaceVppHandler) setUnsetUnnumberedIP(uIfIdx uint32, ifIdxWithIP uint32, isAdd bool) error { - req := &vpp_ifs.SwInterfaceSetUnnumbered{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdxWithIP), - UnnumberedSwIfIndex: vpp_ifs.InterfaceIndex(uIfIdx), - IsAdd: isAdd, - } - reply := &vpp_ifs.SwInterfaceSetUnnumberedReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *InterfaceVppHandler) SetUnnumberedIP(ctx context.Context, uIfIdx uint32, ifIdxWithIP uint32) error { - return h.setUnsetUnnumberedIP(uIfIdx, ifIdxWithIP, true) -} - -func (h *InterfaceVppHandler) UnsetUnnumberedIP(ctx context.Context, uIfIdx uint32) error { - return h.setUnsetUnnumberedIP(uIfIdx, 0, false) -} - -func ipToAddress(address *net.IPNet, isIPv6 bool) (ipAddr vpp_ifs.Address) { - if isIPv6 { - ipAddr.Af = ip_types.ADDRESS_IP6 - var ip6addr vpp_ifs.IP6Address - copy(ip6addr[:], address.IP.To16()) - ipAddr.Un.SetIP6(ip6addr) - } else { - ipAddr.Af = ip_types.ADDRESS_IP4 - var ip4addr vpp_ifs.IP4Address - copy(ip4addr[:], address.IP.To4()) - ipAddr.Un.SetIP4(ip4addr) - } - return -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_vppcalls_test.go deleted file mode 100644 index 6ac72539fe..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ip_vppcalls_test.go +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "net" - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" -) - -func TestAddInterfaceIP(t *testing.T) { - var ipv4Addr [4]uint8 - - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{}) - - _, ipNet, err := net.ParseCIDR("10.0.0.1/24") - Expect(err).To(BeNil()) - err = ifHandler.AddInterfaceIP(1, ipNet) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceAddDelAddress) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Prefix.Address.Af).To(BeEquivalentTo(ip_types.ADDRESS_IP4)) - copy(ipv4Addr[:], ipNet.IP.To4()) - Expect(vppMsg.Prefix.Address.Un.GetIP4()).To(BeEquivalentTo(ipv4Addr)) - Expect(vppMsg.Prefix.Len).To(BeEquivalentTo(24)) - Expect(vppMsg.DelAll).To(BeFalse()) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestAddInterfaceIPv6(t *testing.T) { - var ipv6Addr [16]uint8 - - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{}) - - _, ipNet, err := net.ParseCIDR("2001:db8:0:1:1:1:1:1/128") - Expect(err).To(BeNil()) - err = ifHandler.AddInterfaceIP(1, ipNet) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceAddDelAddress) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Prefix.Address.Af).To(BeEquivalentTo(ip_types.ADDRESS_IP6)) - copy(ipv6Addr[:], ipNet.IP.To16()) - Expect(vppMsg.Prefix.Address.Un.GetIP6()).To(BeEquivalentTo(ipv6Addr)) - Expect(vppMsg.Prefix.Len).To(BeEquivalentTo(128)) - Expect(vppMsg.DelAll).To(BeFalse()) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestAddInterfaceInvalidIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{}) - - err := ifHandler.AddInterfaceIP(1, &net.IPNet{ - IP: []byte("invalid-ip"), - }) - - Expect(err).ToNot(BeNil()) -} - -func TestAddInterfaceIPError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - _, ipNet, err := net.ParseCIDR("10.0.0.1/24") - Expect(err).To(BeNil()) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddress{}) - - err = ifHandler.AddInterfaceIP(1, ipNet) - - Expect(err).ToNot(BeNil()) -} - -func TestAddInterfaceIPRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - _, ipNet, err := net.ParseCIDR("10.0.0.1/24") - Expect(err).To(BeNil()) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{ - Retval: 1, - }) - - err = ifHandler.AddInterfaceIP(1, ipNet) - - Expect(err).ToNot(BeNil()) -} - -func TestDelInterfaceIP(t *testing.T) { - var ipv4Addr [4]uint8 - - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{}) - - _, ipNet, err := net.ParseCIDR("10.0.0.1/24") - Expect(err).To(BeNil()) - err = ifHandler.DelInterfaceIP(1, ipNet) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceAddDelAddress) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Prefix.Address.Af).To(BeEquivalentTo(ip_types.ADDRESS_IP4)) - copy(ipv4Addr[:], ipNet.IP.To4()) - Expect(vppMsg.Prefix.Address.Un.GetIP4()).To(BeEquivalentTo(ipv4Addr)) - Expect(vppMsg.Prefix.Len).To(BeEquivalentTo(24)) - Expect(vppMsg.DelAll).To(BeFalse()) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func TestDelInterfaceIPv6(t *testing.T) { - var ipv6Addr [16]uint8 - - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{}) - - _, ipNet, err := net.ParseCIDR("2001:db8:0:1:1:1:1:1/128") - Expect(err).To(BeNil()) - err = ifHandler.DelInterfaceIP(1, ipNet) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceAddDelAddress) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Prefix.Address.Af).To(BeEquivalentTo(ip_types.ADDRESS_IP6)) - copy(ipv6Addr[:], ipNet.IP.To16()) - Expect(vppMsg.Prefix.Address.Un.GetIP6()).To(BeEquivalentTo(ipv6Addr)) - Expect(vppMsg.Prefix.Len).To(BeEquivalentTo(128)) - Expect(vppMsg.DelAll).To(BeFalse()) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func TestDelInterfaceInvalidIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{}) - - err := ifHandler.DelInterfaceIP(1, &net.IPNet{ - IP: []byte("invalid-ip"), - }) - - Expect(err).ToNot(BeNil()) -} - -func TestDelInterfaceIPError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - _, ipNet, err := net.ParseCIDR("10.0.0.1/24") - Expect(err).To(BeNil()) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddress{}) - - err = ifHandler.DelInterfaceIP(1, ipNet) - - Expect(err).ToNot(BeNil()) -} - -func TestDelInterfaceIPRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - _, ipNet, err := net.ParseCIDR("10.0.0.1/24") - Expect(err).To(BeNil()) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceAddDelAddressReply{ - Retval: 1, - }) - - err = ifHandler.DelInterfaceIP(1, ipNet) - - Expect(err).ToNot(BeNil()) -} - -func TestSetUnnumberedIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetUnnumberedReply{}) - - err := ifHandler.SetUnnumberedIP(ctx.Context, 1, 2) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetUnnumbered) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(2)) - Expect(vppMsg.UnnumberedSwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestSetUnnumberedIPError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetUnnumbered{}) - - err := ifHandler.SetUnnumberedIP(ctx.Context, 1, 2) - - Expect(err).ToNot(BeNil()) -} - -func TestSetUnnumberedIPRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetUnnumberedReply{ - Retval: 1, - }) - - err := ifHandler.SetUnnumberedIP(ctx.Context, 1, 2) - - Expect(err).ToNot(BeNil()) -} - -func TestUnsetUnnumberedIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetUnnumberedReply{}) - - err := ifHandler.UnsetUnnumberedIP(ctx.Context, 1) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetUnnumbered) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(0)) - Expect(vppMsg.UnnumberedSwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func TestUnsetUnnumberedIPError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetUnnumbered{}) - - err := ifHandler.UnsetUnnumberedIP(ctx.Context, 1) - - Expect(err).ToNot(BeNil()) -} - -func TestUnsetUnnumberedIPRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetUnnumberedReply{ - Retval: 1, - }) - - err := ifHandler.UnsetUnnumberedIP(ctx.Context, 1) - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipip_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ipip_vppcalls.go deleted file mode 100644 index a1c8b3acc5..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipip_vppcalls.go +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -// AddIpipTunnel adds new IPIP tunnel interface. -func (h *InterfaceVppHandler) AddIpipTunnel(ifName string, vrf uint32, ipipLink *interfaces.IPIPLink) (uint32, error) { - req := &ipip.IpipAddTunnel{ - Tunnel: ipip.IpipTunnel{ - Instance: ^uint32(0), - TableID: vrf, - }, - } - - if ipipLink == nil { - return 0, errors.New("missing IPIP tunnel information") - } - srcAddr := net.ParseIP(ipipLink.SrcAddr) - if srcAddr == nil { - err := errors.New("bad source address for IPIP tunnel") - return 0, err - } - dstAddr := net.ParseIP(ipipLink.DstAddr) - if dstAddr == nil { - err := errors.New("bad destination address for IPIP tunnel") - return 0, err - } - - var isSrcIPv6, isDstIPv6 bool - if srcAddr.To4() == nil { - isSrcIPv6 = true - } - if dstAddr.To4() == nil { - isDstIPv6 = true - } - - if !isSrcIPv6 && !isDstIPv6 { - var src, dst [4]uint8 - copy(src[:], srcAddr.To4()) - copy(dst[:], dstAddr.To4()) - req.Tunnel.Src = ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(src), - } - req.Tunnel.Dst = ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(dst), - } - } else if isSrcIPv6 && isDstIPv6 { - var src, dst [16]uint8 - copy(src[:], srcAddr.To16()) - copy(dst[:], dstAddr.To16()) - req.Tunnel.Src = ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(src), - } - req.Tunnel.Dst = ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(dst), - } - } else { - return 0, errors.New("source and destination addresses must be both either IPv4 or IPv6") - } - - reply := &ipip.IpipAddTunnelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - swIfIndex := uint32(reply.SwIfIndex) - return swIfIndex, h.SetInterfaceTag(ifName, swIfIndex) -} - -// DelIpipTunnel removes IPIP tunnel interface. -func (h *InterfaceVppHandler) DelIpipTunnel(ifName string, ifIdx uint32) error { - req := &ipip.IpipDelTunnel{ - SwIfIndex: ipip.InterfaceIndex(ifIdx), - } - reply := &ipip.IpipDelTunnelReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - return h.RemoveInterfaceTag(ifName, ifIdx) -} - -// dumpIpipDetails dumps IPIP interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpIpipDetails(ifc map[uint32]*vppcalls.InterfaceDetails) error { - - reqCtx := h.callsChannel.SendMultiRequest(&ipip.IpipTunnelDump{ - SwIfIndex: ^interface_types.InterfaceIndex(0), - }) - for { - ipipDetails := &ipip.IpipTunnelDetails{} - stop, err := reqCtx.ReceiveReply(ipipDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return fmt.Errorf("failed to dump IPIP tunnel interface details: %v", err) - } - _, ifIdxExists := ifc[uint32(ipipDetails.Tunnel.SwIfIndex)] - if !ifIdxExists { - continue - } - - ipipLink := &interfaces.IPIPLink{} - if ipipDetails.Tunnel.Src.Af == ip_types.ADDRESS_IP6 { - srcAddrArr := ipipDetails.Tunnel.Src.Un.GetIP6() - ipipLink.SrcAddr = net.IP(srcAddrArr[:]).To16().String() - dstAddrArr := ipipDetails.Tunnel.Dst.Un.GetIP6() - ipipLink.DstAddr = net.IP(dstAddrArr[:]).To16().String() - } else { - srcAddrArr := ipipDetails.Tunnel.Src.Un.GetIP4() - ipipLink.SrcAddr = net.IP(srcAddrArr[:4]).To4().String() - dstAddrArr := ipipDetails.Tunnel.Dst.Un.GetIP4() - ipipLink.DstAddr = net.IP(dstAddrArr[:4]).To4().String() - } - - ifc[uint32(ipipDetails.Tunnel.SwIfIndex)].Interface.Link = &interfaces.Interface_Ipip{Ipip: ipipLink} - ifc[uint32(ipipDetails.Tunnel.SwIfIndex)].Interface.Type = interfaces.Interface_IPIP_TUNNEL - } - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipip_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ipip_vppcalls_test.go deleted file mode 100644 index dba41b5b42..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipip_vppcalls_test.go +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipip" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddIpipTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipAddTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddIpipTunnel("ipiptun1", 0, &ifs.IPIPLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.1", - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_ipip.IpipAddTunnel) - if ok { - Expect(vppMsg.Tunnel.Src).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(ip_types.IP4Address{10, 0, 0, 1}), - })) - Expect(vppMsg.Tunnel.Dst).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(ip_types.IP4Address{20, 0, 0, 1}), - })) - Expect(vppMsg.Tunnel.TableID).To(BeEquivalentTo(0)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddIpipTunnelWithVrf(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipAddTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddIpipTunnel("ipiptun1", 1, &ifs.IPIPLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.1", - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_ipip.IpipAddTunnel) - if ok { - Expect(vppMsg.Tunnel.Src).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(ip_types.IP4Address{10, 0, 0, 1}), - })) - Expect(vppMsg.Tunnel.Dst).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(ip_types.IP4Address{20, 0, 0, 1}), - })) - Expect(vppMsg.Tunnel.TableID).To(BeEquivalentTo(1)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddIpipTunnelIPv6(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipAddTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddIpipTunnel("ipiptun1", 0, &ifs.IPIPLink{ - SrcAddr: "2001:db8:0:1:1:1:1:1", - DstAddr: "2002:db8:0:1:1:1:1:1", - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_ipip.IpipAddTunnel) - if ok { - Expect(vppMsg.Tunnel.Src).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, - }), - })) - Expect(vppMsg.Tunnel.Dst).To(Equal(ip_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6(ip_types.IP6Address{ - 0x20, 0x02, 0x0d, 0xb8, 0, 0, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, 0, 0x01, - }), - })) - Expect(vppMsg.Tunnel.TableID).To(BeEquivalentTo(0)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddIpipTunnelIPMismatch(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipAddTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddIpipTunnel("ipiptun1", 0, &ifs.IPIPLink{ - SrcAddr: "10.0.0.1", - DstAddr: "2001:db8:0:1:1:1:1:1", - }) - Expect(err).ToNot(BeNil()) -} - -func TestAddIpipTunnelInvalidIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipAddTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddIpipTunnel("ipiptun1", 0, &ifs.IPIPLink{ - SrcAddr: "invalid-ip", - DstAddr: "2001:db8:0:1:1:1:1:1", - }) - Expect(err).ToNot(BeNil()) -} - -func TestAddIpipTunnelNoIPs(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipAddTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddIpipTunnel("ipiptun1", 0, &ifs.IPIPLink{}) - Expect(err).ToNot(BeNil()) -} - -func TestAddIpipTunnelRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipAddTunnelReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddIpipTunnel("ipiptun1", 0, &ifs.IPIPLink{ - SrcAddr: "10.0.0.1", - DstAddr: "20.0.0.2", - }) - Expect(err).ToNot(BeNil()) -} - -func TestDeleteIpipTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipDelTunnelReply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DelIpipTunnel("ipiptun1", 1) - Expect(err).To(BeNil()) -} - -func TestDeleteIpipTunnelRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipip.IpipDelTunnelReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DelIpipTunnel("ipiptun1", 1) - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipsec_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ipsec_vppcalls.go deleted file mode 100644 index 8be7c87869..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipsec_vppcalls.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "encoding/hex" - - vpp_ipsec "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -// AddIPSecTunnelInterface adds a new IPSec tunnel interface. -func (h *InterfaceVppHandler) AddIPSecTunnelInterface(ctx context.Context, ifName string, ipSecLink *ifs.IPSecLink) (uint32, error) { - return h.tunnelIfAddDel(ctx, ifName, ipSecLink, true) -} - -// DeleteIPSecTunnelInterface removes existing IPSec tunnel interface. -func (h *InterfaceVppHandler) DeleteIPSecTunnelInterface(ctx context.Context, ifName string, idx uint32, ipSecLink *ifs.IPSecLink) error { - // Note: ifIdx is not used now, tunnel should be matched based on parameters - _, err := h.tunnelIfAddDel(ctx, ifName, ipSecLink, false) - return err -} - -func (h *InterfaceVppHandler) tunnelIfAddDel(ctx context.Context, ifName string, ipSecLink *ifs.IPSecLink, isAdd bool) (uint32, error) { - localCryptoKey, err := hex.DecodeString(ipSecLink.LocalCryptoKey) - if err != nil { - return 0, err - } - remoteCryptoKey, err := hex.DecodeString(ipSecLink.RemoteCryptoKey) - if err != nil { - return 0, err - } - localIntegKey, err := hex.DecodeString(ipSecLink.LocalIntegKey) - if err != nil { - return 0, err - } - remoteIntegKey, err := hex.DecodeString(ipSecLink.RemoteIntegKey) - if err != nil { - return 0, err - } - - localIP, err := IPToAddress(ipSecLink.LocalIp) - if err != nil { - return 0, err - } - remoteIP, err := IPToAddress(ipSecLink.RemoteIp) - if err != nil { - return 0, err - } - - req := &vpp_ipsec.IpsecTunnelIfAddDel{ - IsAdd: boolToUint(isAdd), - Esn: boolToUint(ipSecLink.Esn), - AntiReplay: boolToUint(ipSecLink.AntiReplay), - LocalIP: localIP, - RemoteIP: remoteIP, - LocalSpi: ipSecLink.LocalSpi, - RemoteSpi: ipSecLink.RemoteSpi, - CryptoAlg: uint8(ipSecLink.CryptoAlg), - LocalCryptoKey: localCryptoKey, - LocalCryptoKeyLen: uint8(len(localCryptoKey)), - RemoteCryptoKey: remoteCryptoKey, - RemoteCryptoKeyLen: uint8(len(remoteCryptoKey)), - IntegAlg: uint8(ipSecLink.IntegAlg), - LocalIntegKey: localIntegKey, - LocalIntegKeyLen: uint8(len(localIntegKey)), - RemoteIntegKey: remoteIntegKey, - RemoteIntegKeyLen: uint8(len(remoteIntegKey)), - UDPEncap: boolToUint(ipSecLink.EnableUdpEncap), - } - reply, err := h.ipsec.IpsecTunnelIfAddDel(ctx, req) - if err != nil { - return 0, err - } - - return reply.SwIfIndex, nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipsec_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/ipsec_vppcalls_test.go deleted file mode 100644 index 60a0ad0fa0..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/ipsec_vppcalls_test.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "encoding/hex" - "net" - "testing" - - . "github.com/onsi/gomega" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipsec "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddIPSecTunnelInterface(t *testing.T) { - var ipv4Addr [16]byte - - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecTunnelIfAddDelReply{ - SwIfIndex: 2, - }) - - ipSecLink := &ifs.IPSecLink{ - Esn: true, - AntiReplay: true, - LocalIp: "10.10.0.1", - RemoteIp: "10.10.0.2", - LocalSpi: 1500, - RemoteSpi: 2000, - CryptoAlg: 9, - LocalCryptoKey: "4a506a794f574265564551694d653768", - RemoteCryptoKey: "9a506a794f574265564551694d653456", - IntegAlg: 4, - LocalIntegKey: "3a506a794f574265564551694d653769", - RemoteIntegKey: "8a506a794f574265564551694d653457", - EnableUdpEncap: true, - } - index, err := ifHandler.AddIPSecTunnelInterface(ctx.Context, "if1", ipSecLink) - Expect(err).To(BeNil()) - Expect(index).To(Equal(uint32(2))) - - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ipsec.IpsecTunnelIfAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg).ToNot(BeNil()) - localCryptoKey, err := hex.DecodeString("4a506a794f574265564551694d653768") - Expect(err).To(BeNil()) - remoteCryptoKey, err := hex.DecodeString("9a506a794f574265564551694d653456") - Expect(err).To(BeNil()) - localIntegKey, err := hex.DecodeString("3a506a794f574265564551694d653769") - Expect(err).To(BeNil()) - remoteIntegKey, err := hex.DecodeString("8a506a794f574265564551694d653457") - Expect(err).To(BeNil()) - - Expect(vppMsg.Esn).To(Equal(uint8(1))) - Expect(vppMsg.IsAdd).To(Equal(uint8(1))) - Expect(vppMsg.AntiReplay).To(Equal(uint8(1))) - Expect(vppMsg.LocalIP.Af).To(Equal(ip_types.ADDRESS_IP4)) - copy(ipv4Addr[:], net.ParseIP(ipSecLink.LocalIp)[12:]) - Expect(vppMsg.LocalIP.Un).To(BeEquivalentTo(vpp_ipsec.AddressUnion{XXX_UnionData: ipv4Addr})) - Expect(vppMsg.LocalSpi).To(Equal(uint32(1500))) - Expect(vppMsg.RemoteSpi).To(Equal(uint32(2000))) - Expect(vppMsg.CryptoAlg).To(Equal(uint8(9))) - Expect(vppMsg.LocalCryptoKey).To(BeEquivalentTo(localCryptoKey)) - Expect(vppMsg.LocalCryptoKeyLen).To(Equal(uint8(16))) - Expect(vppMsg.RemoteCryptoKey).To(BeEquivalentTo(remoteCryptoKey)) - Expect(vppMsg.RemoteCryptoKeyLen).To(Equal(uint8(16))) - Expect(vppMsg.IntegAlg).To(Equal(uint8(4))) - Expect(vppMsg.LocalIntegKey).To(BeEquivalentTo(localIntegKey)) - Expect(vppMsg.LocalIntegKeyLen).To(Equal(uint8(16))) - Expect(vppMsg.RemoteIntegKey).To(BeEquivalentTo(remoteIntegKey)) - Expect(vppMsg.RemoteIntegKeyLen).To(Equal(uint8(16))) - Expect(vppMsg.UDPEncap).To(Equal(uint8(1))) -} - -func TestAddIPSecTunnelInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecTunnelIfAddDelReply{ - SwIfIndex: 2, - Retval: 9, - }) - - index, err := ifHandler.AddIPSecTunnelInterface(ctx.Context, "if1", &ifs.IPSecLink{ - Esn: true, - LocalIp: "10.10.0.1", - LocalCryptoKey: "4a506a794f574265564551694d653768", - }) - Expect(err).ToNot(BeNil()) - Expect(index).To(Equal(uint32(0))) -} - -func TestDeleteIPSecTunnelInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecTunnelIfAddDelReply{ - SwIfIndex: 2, - }) - - err := ifHandler.DeleteIPSecTunnelInterface(ctx.Context, "if1", 2, &ifs.IPSecLink{ - Esn: true, - LocalIp: "10.10.0.1", - RemoteIp: "10.10.0.2", - LocalCryptoKey: "4a506a794f574265564551694d653768", - RemoteCryptoKey: "9a506a794f574265564551694d653456", - }) - - Expect(err).To(BeNil()) -} - -func TestDeleteIPSecTunnelInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecTunnelIfAddDelReply{ - SwIfIndex: 2, - Retval: 9, - }) - - err := ifHandler.DeleteIPSecTunnelInterface(ctx.Context, "if1", 2, &ifs.IPSecLink{ - Esn: true, - LocalIp: "10.10.0.1", - LocalCryptoKey: "4a506a794f574265564551694d653768", - }) - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/l2_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/l2_vppcalls.go deleted file mode 100644 index df2f77e644..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/l2_vppcalls.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -// TODO: more suitable for the l2 plugin, but the tag-rewrite retrieve is a part of the vpp interface api - -// SetVLanTagRewrite sets an interface tag rewrite -func (h *InterfaceVppHandler) SetVLanTagRewrite(ifIdx uint32, subIf *ifs.SubInterface) error { - req := &vpp_l2.L2InterfaceVlanTagRewrite{ - SwIfIndex: ifIdx, - VtrOp: getTagRewriteOption(subIf.TagRwOption), - PushDot1q: uint32(boolToUint(subIf.PushDot1Q)), - Tag1: subIf.Tag1, - Tag2: subIf.Tag2, - } - reply := &vpp_l2.L2InterfaceVlanTagRewriteReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("%s returned error: %v", reply.GetMessageName(), err) - } - - return nil -} - -func getTagRewriteOption(op ifs.SubInterface_TagRewriteOptions) uint32 { - switch op { - case ifs.SubInterface_PUSH1: - return 1 - case ifs.SubInterface_PUSH2: - return 2 - case ifs.SubInterface_POP1: - return 3 - case ifs.SubInterface_POP2: - return 4 - case ifs.SubInterface_TRANSLATE11: - return 5 - case ifs.SubInterface_TRANSLATE12: - return 6 - case ifs.SubInterface_TRANSLATE21: - return 7 - case ifs.SubInterface_TRANSLATE22: - return 8 - default: // disabled - return 0 - } -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/loopback_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/loopback_vppcalls.go deleted file mode 100644 index f810a3d559..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/loopback_vppcalls.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func (h *InterfaceVppHandler) AddLoopbackInterface(ifName string) (swIndex uint32, err error) { - req := &vpp_ifs.CreateLoopback{} - reply := &vpp_ifs.CreateLoopbackReply{} - - if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - - return uint32(reply.SwIfIndex), h.SetInterfaceTag(ifName, uint32(reply.SwIfIndex)) -} - -func (h *InterfaceVppHandler) DeleteLoopbackInterface(ifName string, idx uint32) error { - // Prepare the message. - req := &vpp_ifs.DeleteLoopback{ - SwIfIndex: vpp_ifs.InterfaceIndex(idx), - } - reply := &vpp_ifs.DeleteLoopbackReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return h.RemoveInterfaceTag(ifName, idx) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/loopback_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/loopback_vppcalls_test.go deleted file mode 100644 index 5adfad3029..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/loopback_vppcalls_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func TestAddLoopbackInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.CreateLoopbackReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddLoopbackInterface("loopback") - - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) -} - -func TestAddLoopbackInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.CreateLoopback{}) - - swIfIdx, err := ifHandler.AddLoopbackInterface("loopback") - - Expect(err).ToNot(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(0)) -} - -func TestAddLoopbackInterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.CreateLoopbackReply{ - Retval: 1, - }) - - swIfIdx, err := ifHandler.AddLoopbackInterface("loopback") - - Expect(err).ToNot(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(0)) -} - -func TestDeleteLoopbackInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.DeleteLoopbackReply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteLoopbackInterface("loopback", 1) - - Expect(err).To(BeNil()) -} - -func TestDeleteLoopbackInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.DeleteLoopback{}) - - err := ifHandler.DeleteLoopbackInterface("loopback", 1) - - Expect(err).ToNot(BeNil()) -} - -func TestDeleteLoopbackInterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.DeleteLoopbackReply{ - Retval: 1, - }) - - err := ifHandler.DeleteLoopbackInterface("loopback", 1) - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/mac_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/mac_vppcalls.go deleted file mode 100644 index f18e637167..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/mac_vppcalls.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - "github.com/go-errors/errors" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func (h *InterfaceVppHandler) SetInterfaceMac(ifIdx uint32, macAddress string) error { - mac, err := ParseMAC(macAddress) - if err != nil { - return err - } - req := &vpp_ifs.SwInterfaceSetMacAddress{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - MacAddress: mac, - } - reply := &vpp_ifs.SwInterfaceSetMacAddressReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// parse mac string to uint8 array with len=6 -func ParseMAC(mac string) (parsedMac [6]uint8, err error) { - var hw net.HardwareAddr - if hw, err = net.ParseMAC(mac); err != nil { - err = errors.Errorf("invalid mac address %s: %v", mac, err) - return - } - copy(parsedMac[:], hw[:]) - return -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/mac_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/mac_vppcalls_test.go deleted file mode 100644 index edba59359d..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/mac_vppcalls_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2001" -) - -func TestSetInterfaceMac(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetMacAddressReply{}) - - mac, err := vpp2001.ParseMAC("65:77:BF:72:C9:8D") - Expect(err).To(BeNil()) - err = ifHandler.SetInterfaceMac(1, "65:77:BF:72:C9:8D") - Expect(err).To(BeNil()) - - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetMacAddress) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.MacAddress).To(BeEquivalentTo(mac)) -} - -func TestSetInterfaceInvalidMac(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetMacAddress{}) - - err := ifHandler.SetInterfaceMac(1, "invalid-mac") - - Expect(err).ToNot(BeNil()) -} - -func TestSetInterfaceMacError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetMacAddress{}) - - err := ifHandler.SetInterfaceMac(1, "65:77:BF:72:C9:8D") - - Expect(err).ToNot(BeNil()) -} - -func TestSetInterfaceMacRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetMacAddressReply{ - Retval: 1, - }) - - err := ifHandler.SetInterfaceMac(1, "65:77:BF:72:C9:8D") - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/memif_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/memif_vppcalls.go deleted file mode 100644 index c13685a6c1..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/memif_vppcalls.go +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "fmt" - "io" - "strings" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - vpp_memif "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memif" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) AddMemifInterface(ctx context.Context, ifName string, memIface *ifs.MemifLink, socketID uint32) (swIdx uint32, err error) { - if h.memif == nil { - return 0, errors.WithMessage(vpp.ErrPluginDisabled, "memif") - } - - req := &vpp_memif.MemifCreate{ - ID: memIface.Id, - Mode: memifMode(memIface.Mode), - Secret: memIface.Secret, - SocketID: socketID, - BufferSize: uint16(memIface.BufferSize), - RingSize: memIface.RingSize, - RxQueues: uint8(memIface.RxQueues), - TxQueues: uint8(memIface.TxQueues), - } - if memIface.Master { - req.Role = 0 - } else { - req.Role = 1 - } - // TODO: temporary fix, waiting for https://gerrit.fd.io/r/#/c/7266/ - if req.RxQueues == 0 { - req.RxQueues = 1 - } - if req.TxQueues == 0 { - req.TxQueues = 1 - } - - reply, err := h.memif.MemifCreate(ctx, req) - if err != nil { - return 0, err - } - swIdx = uint32(reply.SwIfIndex) - - return swIdx, h.SetInterfaceTag(ifName, swIdx) -} - -func (h *InterfaceVppHandler) DeleteMemifInterface(ctx context.Context, ifName string, idx uint32) error { - if h.memif == nil { - return errors.WithMessage(vpp.ErrPluginDisabled, "memif") - } - - req := &vpp_memif.MemifDelete{ - SwIfIndex: vpp_memif.InterfaceIndex(idx), - } - if _, err := h.memif.MemifDelete(ctx, req); err != nil { - return err - } - - return h.RemoveInterfaceTag(ifName, idx) -} - -func (h *InterfaceVppHandler) RegisterMemifSocketFilename(ctx context.Context, filename string, id uint32) error { - if h.memif == nil { - return errors.WithMessage(vpp.ErrPluginDisabled, "memif") - } - - req := &vpp_memif.MemifSocketFilenameAddDel{ - SocketFilename: filename, - SocketID: id, - IsAdd: true, // sockets can be added only - } - if _, err := h.memif.MemifSocketFilenameAddDel(ctx, req); err != nil { - return err - } - return nil -} - -func memifMode(mode ifs.MemifLink_MemifMode) vpp_memif.MemifMode { - switch mode { - case ifs.MemifLink_IP: - return vpp_memif.MEMIF_MODE_API_IP - case ifs.MemifLink_PUNT_INJECT: - return vpp_memif.MEMIF_MODE_API_PUNT_INJECT - default: - return vpp_memif.MEMIF_MODE_API_ETHERNET - } -} - -func (h *InterfaceVppHandler) DumpMemifSocketDetails(ctx context.Context) (map[string]uint32, error) { - if h.memif == nil { - return nil, errors.WithMessage(vpp.ErrPluginDisabled, "memif") - } - - dump, err := h.memif.DumpMemifSocketFilename(ctx, &vpp_memif.MemifSocketFilenameDump{}) - if err != nil { - return nil, err - } - memifSocketMap := make(map[string]uint32) - for { - socketDetails, err := dump.Recv() - if err == io.EOF { - break - } - if err != nil { - return nil, err - } - - filename := strings.SplitN(socketDetails.SocketFilename, "\x00", 2)[0] - memifSocketMap[filename] = socketDetails.SocketID - } - - h.log.Debugf("Memif socket dump completed, found %d entries: %v", len(memifSocketMap), memifSocketMap) - - return memifSocketMap, nil -} - -// dumpMemifDetails dumps memif interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpMemifDetails(ctx context.Context, interfaces map[uint32]*vppcalls.InterfaceDetails) error { - if h.memif == nil { - // no-op when disabled - return nil - } - - memifSocketMap, err := h.DumpMemifSocketDetails(ctx) - if err != nil { - return fmt.Errorf("dumping memif socket details failed: %v", err) - } - - dump, err := h.memif.DumpMemif(ctx, &vpp_memif.MemifDump{}) - if err != nil { - return err - } - for { - memifDetails, err := dump.Recv() - if err == io.EOF { - break - } - if err != nil { - return err - } - - _, ifIdxExists := interfaces[uint32(memifDetails.SwIfIndex)] - if !ifIdxExists { - continue - } - interfaces[uint32(memifDetails.SwIfIndex)].Interface.Link = &ifs.Interface_Memif{ - Memif: &ifs.MemifLink{ - Master: memifDetails.Role == 0, - Mode: memifModetoNB(memifDetails.Mode), - Id: memifDetails.ID, - //Secret: // TODO: Secret - not available in the binary API - SocketFilename: func(socketMap map[string]uint32) (filename string) { - for filename, id := range socketMap { - if memifDetails.SocketID == id { - return filename - } - } - // Socket for configured memif should exist - h.log.Warnf("Socket ID not found for memif %v", memifDetails.SwIfIndex) - return - }(memifSocketMap), - RingSize: memifDetails.RingSize, - BufferSize: uint32(memifDetails.BufferSize), - // TODO: RxQueues, TxQueues - not available in the binary API - //RxQueues: - //TxQueues: - }, - } - interfaces[uint32(memifDetails.SwIfIndex)].Interface.Type = ifs.Interface_MEMIF - } - - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/memif_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/memif_vppcalls_test.go deleted file mode 100644 index dffe7517be..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/memif_vppcalls_test.go +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_memif "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memif" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddMasterMemifInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifCreateReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddMemifInterface(ctx.Context, "memif", &ifs.MemifLink{ - Id: 1, - Mode: ifs.MemifLink_IP, - Secret: "secret", - Master: true, - }, 5) - - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_memif.MemifCreate) - if ok { - Expect(vppMsg.ID).To(BeEquivalentTo(1)) - Expect(vppMsg.Mode).To(BeEquivalentTo(1)) - Expect(vppMsg.Role).To(BeEquivalentTo(0)) - Expect(vppMsg.SocketID).To(BeEquivalentTo(5)) - Expect(vppMsg.RxQueues).To(BeEquivalentTo(1)) - Expect(vppMsg.TxQueues).To(BeEquivalentTo(1)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddMasterMemifInterfaceAsSlave(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifCreateReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddMemifInterface(ctx.Context, "memif", &ifs.MemifLink{ - Id: 1, - Mode: ifs.MemifLink_IP, - Secret: "secret", - Master: false, - }, 5) - - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_memif.MemifCreate) - if ok { - Expect(vppMsg.Role).To(BeEquivalentTo(1)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddMasterMemifInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifCreate{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddMemifInterface(ctx.Context, "memif", &ifs.MemifLink{ - Id: 1, - Mode: ifs.MemifLink_IP, - Secret: "secret", - Master: false, - }, 5) - - Expect(err).ToNot(BeNil()) -} - -func TestAddMasterMemifInterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifCreateReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddMemifInterface(ctx.Context, "memif", &ifs.MemifLink{ - Id: 1, - Mode: ifs.MemifLink_IP, - Secret: "secret", - Master: false, - }, 5) - - Expect(err).ToNot(BeNil()) -} - -func TestDeleteMemifInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifDeleteReply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteMemifInterface(ctx.Context, "memif", 1) - - Expect(err).To(BeNil()) -} - -func TestDeleteMemifInterfaceError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifDelete{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteMemifInterface(ctx.Context, "memif", 1) - - Expect(err).ToNot(BeNil()) -} - -func TestDeleteMemifInterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifDeleteReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteMemifInterface(ctx.Context, "memif", 1) - - Expect(err).ToNot(BeNil()) -} - -func TestRegisterMemifSocketFilename(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifSocketFilenameAddDelReply{}) - - err := ifHandler.RegisterMemifSocketFilename(ctx.Context, "filename", 1) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_memif.MemifSocketFilenameAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeTrue()) - Expect(vppMsg.SocketID).To(BeEquivalentTo(1)) - Expect(vppMsg.SocketFilename).To(BeEquivalentTo([]byte("filename"))) -} - -func TestRegisterMemifSocketFilenameError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifSocketFilenameAddDel{}) - - err := ifHandler.RegisterMemifSocketFilename(ctx.Context, "filename", 1) - - Expect(err).ToNot(BeNil()) -} - -func TestRegisterMemifSocketFilenameRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_memif.MemifSocketFilenameAddDelReply{ - Retval: 1, - }) - - err := ifHandler.RegisterMemifSocketFilename(ctx.Context, "filename", 1) - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/mtu_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/mtu_vppcalls.go deleted file mode 100644 index b33e2b80b4..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/mtu_vppcalls.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func (h *InterfaceVppHandler) SetInterfaceMtu(ifIdx uint32, mtu uint32) error { - req := &vpp_ifs.HwInterfaceSetMtu{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - Mtu: uint16(mtu), - } - reply := &vpp_ifs.HwInterfaceSetMtuReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/mtu_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/mtu_vppcalls_test.go deleted file mode 100644 index e85fc51dad..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/mtu_vppcalls_test.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func TestSetInterfaceMtu(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{}) - - err := ifHandler.SetInterfaceMtu(1, 1500) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.HwInterfaceSetMtu) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Mtu).To(BeEquivalentTo(1500)) -} - -func TestSetInterfaceMtuError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtu{}) - - err := ifHandler.SetInterfaceMtu(1, 1500) - - Expect(err).ToNot(BeNil()) -} - -func TestSetInterfaceMtuRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{ - Retval: 1, - }) - - err := ifHandler.SetInterfaceMtu(1, 1500) - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/rdma_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/rdma_vppcalls.go deleted file mode 100644 index a6d9f37d0a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/rdma_vppcalls.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 2020 Pantheon.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "git.fd.io/govpp.git/api" - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/rdma" -) - -// AddRdmaInterface adds new interface with RDMA driver. -func (h *InterfaceVppHandler) AddRdmaInterface(ctx context.Context, ifName string, rdmaLink *interfaces.RDMALink) (swIdx uint32, err error) { - if h.rdma == nil { - return 0, errors.WithMessage(vpp.ErrPluginDisabled, "rdma") - } - - req := &rdma.RdmaCreate{ - HostIf: rdmaLink.GetHostIfName(), - Name: ifName, - RxqNum: uint16(rdmaLink.GetRxqNum()), - RxqSize: uint16(rdmaLink.GetRxqSize()), - TxqSize: uint16(rdmaLink.GetTxqSize()), - Mode: rdmaMode(rdmaLink.GetMode()), - } - - reply, err := h.rdma.RdmaCreate(ctx, req) - if err != nil { - return 0, err - } else if err = api.RetvalToVPPApiError(reply.Retval); err != nil { - return 0, err - } - swIdx = uint32(reply.SwIfIndex) - - return swIdx, h.SetInterfaceTag(ifName, swIdx) -} - -// DeleteRdmaInterface removes interface with RDMA driver. -func (h *InterfaceVppHandler) DeleteRdmaInterface(ctx context.Context, ifName string, ifIdx uint32) error { - if h.rdma == nil { - return errors.WithMessage(vpp.ErrPluginDisabled, "rdma") - } - - req := &rdma.RdmaDelete{ - SwIfIndex: interface_types.InterfaceIndex(ifIdx), - } - if reply, err := h.rdma.RdmaDelete(ctx, req); err != nil { - return err - } else if err = api.RetvalToVPPApiError(reply.Retval); err != nil { - return err - } - - return h.RemoveInterfaceTag(ifName, ifIdx) -} - -func rdmaMode(mode interfaces.RDMALink_Mode) rdma.RdmaMode { - switch mode { - case interfaces.RDMALink_DV: - return rdma.RDMA_API_MODE_DV - case interfaces.RDMALink_IBV: - return rdma.RDMA_API_MODE_IBV - default: - return rdma.RDMA_API_MODE_AUTO - } -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/rdma_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/rdma_vppcalls_test.go deleted file mode 100644 index a41fc31876..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/rdma_vppcalls_test.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2020 Pantheon.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_rdma "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/rdma" - - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddRdmaInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_rdma.RdmaCreateReply{ - SwIfIndex: 2, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - const qSize = 4096 - const qNum = 4 - rdmaLink := &ifs.RDMALink{ - HostIfName: "ens4", - Mode: ifs.RDMALink_DV, - RxqNum: qNum, - RxqSize: qSize, - TxqSize: qSize, - } - - index, err := ifHandler.AddRdmaInterface(ctx.Context, "rdma1", rdmaLink) - Expect(err).To(BeNil()) - Expect(index).To(Equal(uint32(2))) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_rdma.RdmaCreate) - if ok { - Expect(vppMsg.HostIf).To(BeEquivalentTo("ens4")) - Expect(vppMsg.Name).To(BeEquivalentTo("rdma1")) - Expect(vppMsg.Mode).To(BeEquivalentTo(vpp_rdma.RDMA_API_MODE_DV)) - Expect(vppMsg.RxqNum).To(BeEquivalentTo(qNum)) - Expect(vppMsg.RxqSize).To(BeEquivalentTo(qSize)) - Expect(vppMsg.TxqSize).To(BeEquivalentTo(qSize)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestDeleteRdmaInterface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_rdma.RdmaDeleteReply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteRdmaInterface(ctx.Context, "rdma1", 2) - Expect(err).To(BeNil()) - - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_rdma.RdmaDelete) - if ok { - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(2)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_mode_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_mode_vppcalls.go deleted file mode 100644 index 6301992f62..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_mode_vppcalls.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) SetRxMode(ifIdx uint32, rxMode *ifs.Interface_RxMode) error { - - req := &vpp_ifs.SwInterfaceSetRxMode{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - Mode: setRxMode(rxMode.Mode), - QueueID: rxMode.Queue, - QueueIDValid: !rxMode.DefaultMode, - } - reply := &vpp_ifs.SwInterfaceSetRxModeReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func setRxMode(mode ifs.Interface_RxMode_Type) vpp_ifs.RxMode { - switch mode { - case ifs.Interface_RxMode_POLLING: - return interface_types.RX_MODE_API_POLLING - case ifs.Interface_RxMode_INTERRUPT: - return interface_types.RX_MODE_API_INTERRUPT - case ifs.Interface_RxMode_ADAPTIVE: - return interface_types.RX_MODE_API_ADAPTIVE - case ifs.Interface_RxMode_DEFAULT: - return interface_types.RX_MODE_API_DEFAULT - default: - return interface_types.RX_MODE_API_UNKNOWN - } -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_mode_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_mode_vppcalls_test.go deleted file mode 100644 index afec8efb9c..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_mode_vppcalls_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestSetRxMode(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxModeReply{}) - - err := ifHandler.SetRxMode(1, &ifs.Interface_RxMode{ - Mode: ifs.Interface_RxMode_DEFAULT, - Queue: 1, - DefaultMode: false, - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetRxMode) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Mode).To(BeEquivalentTo(4)) - Expect(vppMsg.QueueID).To(BeEquivalentTo(1)) - Expect(vppMsg.QueueIDValid).To(BeTrue()) -} - -func TestSetRxModeError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxMode{}) - - err := ifHandler.SetRxMode(1, &ifs.Interface_RxMode{ - Mode: ifs.Interface_RxMode_DEFAULT, - Queue: 1, - DefaultMode: false, - }) - - Expect(err).ToNot(BeNil()) -} - -func TestSetRxModeRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxModeReply{ - Retval: 1, - }) - - err := ifHandler.SetRxMode(1, &ifs.Interface_RxMode{ - Mode: ifs.Interface_RxMode_DEFAULT, - Queue: 1, - DefaultMode: false, - }) - - Expect(err).ToNot(BeNil()) -} - -func TestSetDefaultRxMode(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxModeReply{}) - - err := ifHandler.SetRxMode(5, &ifs.Interface_RxMode{ - Mode: ifs.Interface_RxMode_POLLING, - Queue: 10, // ignored on the VPP side - DefaultMode: true, - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetRxMode) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(5)) - Expect(vppMsg.Mode).To(BeEquivalentTo(1)) - Expect(vppMsg.QueueID).To(BeEquivalentTo(10)) - Expect(vppMsg.QueueIDValid).To(BeFalse()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_placement_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_placement_vppcalls.go deleted file mode 100644 index ba0ee254e1..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_placement_vppcalls.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) SetRxPlacement(ifIdx uint32, rxPlacement *ifs.Interface_RxPlacement) error { - req := &vpp_ifs.SwInterfaceSetRxPlacement{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - QueueID: rxPlacement.Queue, - WorkerID: rxPlacement.Worker, - IsMain: rxPlacement.MainThread, - } - reply := &vpp_ifs.SwInterfaceSetRxPlacementReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_placement_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_placement_vppcalls_test.go deleted file mode 100644 index 604b41b822..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/rx_placement_vppcalls_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestSetRxPlacementForWorker(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxPlacementReply{}) - - err := ifHandler.SetRxPlacement(1, &ifs.Interface_RxPlacement{ - Queue: 1, - Worker: 2, - MainThread: false, - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetRxPlacement) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.QueueID).To(BeEquivalentTo(1)) - Expect(vppMsg.WorkerID).To(BeEquivalentTo(uint32(2))) - Expect(vppMsg.IsMain).To(BeFalse()) -} - -func TestSetRxPlacementForMainThread(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxPlacementReply{}) - - err := ifHandler.SetRxPlacement(3, &ifs.Interface_RxPlacement{ - Queue: 6, - Worker: 2, // ignored on the VPP side - MainThread: true, - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetRxPlacement) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(3)) - Expect(vppMsg.QueueID).To(BeEquivalentTo(6)) - Expect(vppMsg.WorkerID).To(BeEquivalentTo(uint32(2))) - Expect(vppMsg.IsMain).To(BeTrue()) -} - -func TestSetRxPlacementRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxPlacementReply{ - Retval: 1, - }) - - err := ifHandler.SetRxPlacement(1, &ifs.Interface_RxPlacement{ - Queue: 1, - Worker: 2, - MainThread: false, - }) - - Expect(err).ToNot(BeNil()) -} - -func TestSetRxPlacementError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetRxPlacement{}) - - err := ifHandler.SetRxPlacement(1, &ifs.Interface_RxPlacement{ - Queue: 1, - Worker: 2, - MainThread: false, - }) - - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/span_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/span_vppcalls.go deleted file mode 100644 index b06d1b9c71..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/span_vppcalls.go +++ /dev/null @@ -1,80 +0,0 @@ -package vpp2001 - -import ( - "fmt" - - vpp_span "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/span" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" -) - -// SetSpan enables or disables SPAN on interface -func (h *InterfaceVppHandler) setSpan(ifIdxFrom, ifIdxTo uint32, state uint8, isL2 bool) error { - req := &vpp_span.SwInterfaceSpanEnableDisable{ - SwIfIndexFrom: ifIdxFrom, - SwIfIndexTo: ifIdxTo, - State: state, - IsL2: boolToUint(isL2), - } - reply := &vpp_span.SwInterfaceSpanEnableDisableReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// AddSpan enables SPAN on interface -func (h *InterfaceVppHandler) AddSpan(ifIdxFrom, ifIdxTo uint32, direction uint8, isL2 bool) error { - return h.setSpan(ifIdxFrom, ifIdxTo, direction, isL2) -} - -// DelSpan disables SPAN on interface -func (h *InterfaceVppHandler) DelSpan(ifIdxFrom, ifIdxTo uint32, isL2 bool) error { - return h.setSpan(ifIdxFrom, ifIdxTo, 0, isL2) -} - -// DumpSpan dumps all SPAN table -func (h *InterfaceVppHandler) DumpSpan() ([]*vppcalls.InterfaceSpanDetails, error) { - var spans []*vppcalls.InterfaceSpanDetails - - isL2Spans, err := h.dumpSpan(&vpp_span.SwInterfaceSpanDump{IsL2: 1}) - if err != nil { - return nil, err - } - spans = append(spans, isL2Spans...) - - isNotL2Spans, err := h.dumpSpan(&vpp_span.SwInterfaceSpanDump{IsL2: 0}) - if err != nil { - return nil, err - } - spans = append(spans, isNotL2Spans...) - - return spans, nil -} - -// dumpIsL2Span returns only SPANs with or without L2 set -func (h *InterfaceVppHandler) dumpSpan(msg *vpp_span.SwInterfaceSpanDump) ([]*vppcalls.InterfaceSpanDetails, error) { - var spans []*vppcalls.InterfaceSpanDetails - - reqCtx := h.callsChannel.SendMultiRequest(msg) - for { - spanDetails := &vpp_span.SwInterfaceSpanDetails{} - stop, err := reqCtx.ReceiveReply(spanDetails) - if stop { - break - } - if err != nil { - return nil, fmt.Errorf("failed to dump span: %v", err) - } - - spanData := &vppcalls.InterfaceSpanDetails{ - SwIfIndexFrom: spanDetails.SwIfIndexFrom, - SwIfIndexTo: spanDetails.SwIfIndexTo, - Direction: spanDetails.State, - IsL2: spanDetails.IsL2 > 0, - } - spans = append(spans, spanData) - } - return spans, nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/subif_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/subif_vppcalls.go deleted file mode 100644 index 3e89e2892a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/subif_vppcalls.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -// CreateSubif creates sub interface. -func (h *InterfaceVppHandler) CreateSubif(ifIdx, vlanID uint32) (uint32, error) { - req := &vpp_ifs.CreateVlanSubif{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - VlanID: vlanID, - } - - reply := &vpp_ifs.CreateVlanSubifReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - - return uint32(reply.SwIfIndex), nil -} - -// DeleteSubif deletes sub interface. -func (h *InterfaceVppHandler) DeleteSubif(ifIdx uint32) error { - req := &vpp_ifs.DeleteSubif{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - } - - reply := &vpp_ifs.DeleteSubifReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/subif_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/subif_vppcalls_test.go deleted file mode 100644 index 78cd6a231a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/subif_vppcalls_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func TestCreateSubif(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ifs.CreateVlanSubifReply{ - SwIfIndex: 2, - }) - swifindex, err := ifHandler.CreateSubif(5, 32) - Expect(err).To(BeNil()) - Expect(swifindex).To(Equal(uint32(2))) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.CreateVlanSubif) - Expect(ok).To(BeTrue()) - Expect(vppMsg).ToNot(BeNil()) - Expect(vppMsg.SwIfIndex).To(Equal(vpp_ifs.InterfaceIndex(5))) - Expect(vppMsg.VlanID).To(Equal(uint32(32))) -} - -func TestCreateSubifError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ifs.CreateVlanSubifReply{ - SwIfIndex: 2, - Retval: 9, - }) - swifindex, err := ifHandler.CreateSubif(5, 32) - Expect(err).ToNot(BeNil()) - Expect(swifindex).To(Equal(uint32(0))) -} - -func TestDeleteSubif(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ifs.DeleteSubifReply{ - Retval: 2, - }) - err := ifHandler.DeleteSubif(5) - Expect(err).ToNot(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.DeleteSubif) - Expect(ok).To(BeTrue()) - Expect(vppMsg).ToNot(BeNil()) - Expect(vppMsg.SwIfIndex).To(Equal(vpp_ifs.InterfaceIndex(5))) -} - -func TestDeleteSubifError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&vpp_ifs.DeleteSubifReply{ - Retval: 2, - }) - err := ifHandler.DeleteSubif(5) - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/tap_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/tap_vppcalls.go deleted file mode 100644 index e94cb6f663..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/tap_vppcalls.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "errors" - "fmt" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_tapv2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/tapv2" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -// TapFlags definitions from https://github.com/FDio/vpp/blob/stable/2001/src/vnet/devices/tap/tap.h#L33 -const ( - TapFlagGSO uint32 = 1 << iota -) - -func (h *InterfaceVppHandler) AddTapInterface(ifName string, tapIf *ifs.TapLink) (swIfIdx uint32, err error) { - if tapIf == nil || tapIf.HostIfName == "" { - return 0, errors.New("host interface name was not provided for the TAP interface") - } - - if tapIf.Version == 1 { - return 0, errors.New("tap version 1 has been deprecated") - } else if tapIf.Version == 2 { - var flags vpp_tapv2.TapFlags - if tapIf.EnableGso { - flags |= vpp_tapv2.TAP_FLAG_GSO - } - if tapIf.EnableTunnel { - h.log.Warnf("tunnel mode not supported for VPP 20.01") - } - - // Configure fast virtio-based TAP interface - req := &vpp_tapv2.TapCreateV2{ - ID: ^uint32(0), - NumRxQueues: 1, - HostIfName: tapIf.HostIfName, - HostIfNameSet: true, - UseRandomMac: true, - RxRingSz: uint16(tapIf.RxRingSize), - TxRingSz: uint16(tapIf.TxRingSize), - TapFlags: flags, - } - - reply := &vpp_tapv2.TapCreateV2Reply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - swIfIdx = uint32(reply.SwIfIndex) - } else { - return 0, fmt.Errorf("invalid tap version (%v)", tapIf.Version) - } - - return swIfIdx, h.SetInterfaceTag(ifName, swIfIdx) -} - -func (h *InterfaceVppHandler) DeleteTapInterface(ifName string, idx uint32, version uint32) error { - if version == 1 { - return errors.New("tap version 1 has been deprecated") - } else if version == 2 { - req := &vpp_tapv2.TapDeleteV2{ - SwIfIndex: interface_types.InterfaceIndex(idx), - } - - reply := &vpp_tapv2.TapDeleteV2Reply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - } else { - return fmt.Errorf("invalid tap version (%v)", version) - } - - return h.RemoveInterfaceTag(ifName, idx) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/tap_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/tap_vppcalls_test.go deleted file mode 100644 index 7fce3ad3aa..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/tap_vppcalls_test.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_tapv2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/tapv2" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddTapInterfaceV2(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_tapv2.TapCreateV2Reply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddTapInterface("tapIf", &ifs.TapLink{ - Version: 2, - HostIfName: "hostIf", - RxRingSize: 1, - TxRingSize: 1, - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_tapv2.TapCreateV2) - if ok { - Expect(vppMsg.UseRandomMac).To(BeTrue()) - Expect(vppMsg.HostIfName).To(BeEquivalentTo([]byte("hostIf"))) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestDeleteTapInterfaceV2(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_tapv2.TapDeleteV2Reply{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteTapInterface("tapIf", 1, 2) - Expect(err).To(BeNil()) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_tapv2.TapDeleteV2) - if ok { - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vmxnet3_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vmxnet3_vppcalls.go deleted file mode 100644 index 2868ded3af..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vmxnet3_vppcalls.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_vmxnet3 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vmxnet3" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) AddVmxNet3(ifName string, vmxNet3 *ifs.VmxNet3Link) (swIdx uint32, err error) { - if h.vmxnet3 == nil { - return 0, errors.WithMessage(vpp.ErrPluginDisabled, "wmxnet") - } - - var pci uint32 - pci, err = derivePCI(ifName) - if err != nil { - return 0, err - } - - req := &vpp_vmxnet3.Vmxnet3Create{ - PciAddr: pci, - } - // Optional arguments - if vmxNet3 != nil { - req.EnableElog = int32(boolToUint(vmxNet3.EnableElog)) - req.RxqSize = uint16(vmxNet3.RxqSize) - req.TxqSize = uint16(vmxNet3.TxqSize) - } - - reply := &vpp_vmxnet3.Vmxnet3CreateReply{} - if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, errors.Errorf(err.Error()) - } - - return uint32(reply.SwIfIndex), h.SetInterfaceTag(ifName, uint32(reply.SwIfIndex)) -} - -func (h *InterfaceVppHandler) DeleteVmxNet3(ifName string, ifIdx uint32) error { - if h.vmxnet3 == nil { - return errors.WithMessage(vpp.ErrPluginDisabled, "wmxnet") - } - - req := &vpp_vmxnet3.Vmxnet3Delete{ - SwIfIndex: interface_types.InterfaceIndex(ifIdx), - } - reply := &vpp_vmxnet3.Vmxnet3DeleteReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return errors.Errorf(err.Error()) - } - - return h.RemoveInterfaceTag(ifName, ifIdx) -} - -func derivePCI(ifName string) (uint32, error) { - var function, slot, bus, domain, pci uint32 - - numLen, err := fmt.Sscanf(ifName, "vmxnet3-%x/%x/%x/%x", &domain, &bus, &slot, &function) - if err != nil { - err = errors.Errorf("cannot parse PCI address from the vmxnet3 interface name %s: %v", ifName, err) - return 0, err - } - if numLen != 4 { - err = errors.Errorf("cannot parse PCI address from the interface name %s: expected 4 address elements, received %d", - ifName, numLen) - return 0, err - } - - pci |= function << 29 - pci |= slot << 24 - pci |= bus << 16 - pci |= domain - - return pci, nil -} - -// dumpVmxNet3Details dumps VmxNet3 interface details from VPP and fills them into the provided interface map. -func (h *InterfaceVppHandler) dumpVmxNet3Details(interfaces map[uint32]*vppcalls.InterfaceDetails) error { - if h.vmxnet3 == nil { - // no-op when disabled - return nil - } - - reqCtx := h.callsChannel.SendMultiRequest(&vpp_vmxnet3.Vmxnet3Dump{}) - for { - vmxnet3Details := &vpp_vmxnet3.Vmxnet3Details{} - stop, err := reqCtx.ReceiveReply(vmxnet3Details) - if stop { - break // Break from the loop. - } - if err != nil { - return fmt.Errorf("failed to dump VmxNet3 tunnel interface details: %v", err) - } - _, ifIdxExists := interfaces[uint32(vmxnet3Details.SwIfIndex)] - if !ifIdxExists { - continue - } - interfaces[uint32(vmxnet3Details.SwIfIndex)].Interface.Link = &ifs.Interface_VmxNet3{ - VmxNet3: &ifs.VmxNet3Link{ - RxqSize: uint32(vmxnet3Details.RxCount), - TxqSize: uint32(vmxnet3Details.TxCount), - }, - } - interfaces[uint32(vmxnet3Details.SwIfIndex)].Interface.Type = ifs.Interface_VMXNET3_INTERFACE - interfaces[uint32(vmxnet3Details.SwIfIndex)].Meta.Pci = vmxnet3Details.PciAddr - } - return nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vmxnet3_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vmxnet3_vppcalls_test.go deleted file mode 100644 index 17a6e99a0a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vmxnet3_vppcalls_test.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_vmxnet3 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vmxnet3" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddVmxNet3Interface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vmxnet3.Vmxnet3CreateReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddVmxNet3("vmxnet3-face/be/1c/4", &ifs.VmxNet3Link{ - EnableElog: true, - RxqSize: 2048, - TxqSize: 512, - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_vmxnet3.Vmxnet3Create) - if ok { - Expect(vppMsg.PciAddr).To(BeEquivalentTo(2629761742)) - Expect(vppMsg.EnableElog).To(BeEquivalentTo(1)) - Expect(vppMsg.RxqSize).To(BeEquivalentTo(2048)) - Expect(vppMsg.TxqSize).To(BeEquivalentTo(512)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddVmxNet3InterfacePCIErr(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vmxnet3.Vmxnet3CreateReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - // Name in incorrect format - _, err := ifHandler.AddVmxNet3("vmxnet3-a/14/19", nil) - Expect(err).ToNot(BeNil()) -} - -func TestAddVmxNet3InterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vmxnet3.Vmxnet3CreateReply{ - Retval: 1, - }) - - _, err := ifHandler.AddVmxNet3("vmxnet3-a/14/19/1e", nil) - Expect(err).ToNot(BeNil()) -} - -func TestDelVmxNet3Interface(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vmxnet3.Vmxnet3DeleteReply{ - Retval: 0, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteVmxNet3("vmxnet3-a/14/19/1e", 1) - Expect(err).To(BeNil()) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_vmxnet3.Vmxnet3Delete) - if ok { - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestDelVmxNet3InterfaceRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vmxnet3.Vmxnet3DeleteReply{ - Retval: 1, - }) - - err := ifHandler.DeleteVmxNet3("vmxnet3-a/14/19/1e", 1) - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vppcalls_handler.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 64fb522134..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/af_packet" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/bond" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gre" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/gtpu" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip6_nd" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/memif" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/rd_cp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/rdma" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/span" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/tapv2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vmxnet3" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" -) - -var HandlerVersion = vpp.HandlerVersion{ - Version: vpp2001.Version, - Check: func(c vpp.Client) error { - msgs := vpp.Messages( - af_packet.AllMessages, - bond.AllMessages, - dhcp.AllMessages, - interfaces.AllMessages, - ip.AllMessages, - ipsec.AllMessages, - gre.AllMessages, - l2.AllMessages, - span.AllMessages, - tapv2.AllMessages, - vxlan.AllMessages, - ) - if c.IsPluginLoaded(gtpu.ModuleName) { - msgs.Add(gtpu.AllMessages) - } - if c.IsPluginLoaded(memif.ModuleName) { - msgs.Add(memif.AllMessages) - } - if c.IsPluginLoaded(vmxnet3.ModuleName) { - msgs.Add(vmxnet3.AllMessages) - } - if c.IsPluginLoaded(rdma.ModuleName) { - msgs.Add(rdma.AllMessages) - } - return c.CheckCompatiblity(msgs.AllMessages()...) - }, - NewHandler: func(c vpp.Client, a ...interface{}) vpp.HandlerAPI { - return NewInterfaceVppHandler(c, a[0].(logging.Logger)) - }, -} - -func init() { - vppcalls.Handler.AddVersion(HandlerVersion) -} - -// InterfaceVppHandler is accessor for interface-related vppcalls methods -type InterfaceVppHandler struct { - callsChannel govppapi.Channel - interfaces interfaces.RPCService - ipsec ipsec.RPCService - gtpu gtpu.RPCService - memif memif.RPCService - vmxnet3 vmxnet3.RPCService - rdma rdma.RPCService - rpcIP6nd ip6_nd.RPCService - rpcRdCp rd_cp.RPCService - log logging.Logger -} - -// NewInterfaceVppHandler returns new InterfaceVppHandler. -func NewInterfaceVppHandler(c vpp.Client, log logging.Logger) vppcalls.InterfaceVppAPI { - ch, err := c.NewAPIChannel() - if err != nil { - return nil - } - h := &InterfaceVppHandler{ - callsChannel: ch, - interfaces: interfaces.NewServiceClient(ch), - ipsec: ipsec.NewServiceClient(ch), - rpcIP6nd: ip6_nd.NewServiceClient(ch), - rpcRdCp: rd_cp.NewServiceClient(ch), - log: log, - } - if c.IsPluginLoaded(gtpu.ModuleName) { - h.gtpu = gtpu.NewServiceClient(ch) - } - if c.IsPluginLoaded(memif.ModuleName) { - h.memif = memif.NewServiceClient(ch) - } - if c.IsPluginLoaded(vmxnet3.ModuleName) { - h.vmxnet3 = vmxnet3.NewServiceClient(ch) - } - if c.IsPluginLoaded(rdma.ModuleName) { - h.rdma = rdma.NewServiceClient(ch) - } - return h -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vrf_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vrf_vppcalls.go deleted file mode 100644 index be1ac98a1a..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vrf_vppcalls.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func (h *InterfaceVppHandler) SetInterfaceVrf(ifIdx, vrfID uint32) error { - return h.setInterfaceVrf(ifIdx, vrfID, false) -} - -func (h *InterfaceVppHandler) SetInterfaceVrfIPv6(ifIdx, vrfID uint32) error { - return h.setInterfaceVrf(ifIdx, vrfID, true) -} - -func (h *InterfaceVppHandler) GetInterfaceVrf(ifIdx uint32) (vrfID uint32, err error) { - return h.getInterfaceVrf(ifIdx, false) -} - -func (h *InterfaceVppHandler) GetInterfaceVrfIPv6(ifIdx uint32) (vrfID uint32, err error) { - return h.getInterfaceVrf(ifIdx, true) -} - -// Interface is set to VRF table. Table IP version has to be defined. -func (h *InterfaceVppHandler) setInterfaceVrf(ifIdx, vrfID uint32, isIPv6 bool) error { - req := &vpp_ifs.SwInterfaceSetTable{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - VrfID: vrfID, - IsIPv6: isIPv6, - } - reply := &vpp_ifs.SwInterfaceSetTableReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - h.log.Debugf("Interface %d set to VRF %d", ifIdx, vrfID) - - return nil -} - -// Returns VRF ID for provided interface. -func (h *InterfaceVppHandler) getInterfaceVrf(ifIdx uint32, isIPv6 bool) (vrfID uint32, err error) { - req := &vpp_ifs.SwInterfaceGetTable{ - SwIfIndex: vpp_ifs.InterfaceIndex(ifIdx), - IsIPv6: isIPv6, - } - reply := &vpp_ifs.SwInterfaceGetTableReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - - return reply.VrfID, nil -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vrf_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vrf_vppcalls_test.go deleted file mode 100644 index 3e10918880..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vrf_vppcalls_test.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" -) - -func TestGetInterfaceVRF(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceGetTableReply{ - VrfID: 1, - }) - - vrfID, err := ifHandler.GetInterfaceVrf(1) - Expect(err).To(BeNil()) - Expect(vrfID).To(BeEquivalentTo(1)) -} - -func TestGetInterfaceIPv6VRF(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceGetTableReply{ - VrfID: 1, - }) - - vrfID, err := ifHandler.GetInterfaceVrfIPv6(1) - Expect(err).To(BeNil()) - Expect(vrfID).To(BeEquivalentTo(1)) -} - -func TestGetInterfaceVRFError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceGetTable{}) - - _, err := ifHandler.GetInterfaceVrf(1) - Expect(err).ToNot(BeNil()) -} - -func TestGetInterfaceVRFRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceGetTableReply{ - Retval: 1, - }) - - _, err := ifHandler.GetInterfaceVrf(1) - Expect(err).ToNot(BeNil()) -} - -func TestSetInterfaceVRF(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetTableReply{}) - - err := ifHandler.SetInterfaceVrf(1, 2) - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetTable) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.VrfID).To(BeEquivalentTo(2)) -} - -func TestSetInterfaceIPv6VRF(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetTableReply{}) - - err := ifHandler.SetInterfaceVrfIPv6(1, 2) - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.SwInterfaceSetTable) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.VrfID).To(BeEquivalentTo(2)) - Expect(vppMsg.IsIPv6).To(BeTrue()) -} - -func TestSetInterfaceVRFError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetTable{}) - - err := ifHandler.SetInterfaceVrf(1, 2) - Expect(err).To(HaveOccurred()) -} - -func TestSetInterfaceVRFRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceSetTableReply{ - Retval: 1, - }) - - err := ifHandler.SetInterfaceVrf(1, 2) - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_gpe_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_gpe_vppcalls.go deleted file mode 100644 index 56abdc1a1c..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_gpe_vppcalls.go +++ /dev/null @@ -1,64 +0,0 @@ -package vpp2001 - -import ( - "fmt" - "net" - - vpp_gpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan_gpe" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) vxLanGpeAddDelTunnel(isAdd uint8, vxLan *ifs.VxlanLink, vrf, multicastIf uint32) (uint32, error) { - req := &vpp_gpe.VxlanGpeAddDelTunnel{ - McastSwIfIndex: multicastIf, - EncapVrfID: vrf, - DecapVrfID: vxLan.Gpe.DecapVrfId, - Protocol: uint8(vxLan.Gpe.Protocol), - Vni: vxLan.Vni, - IsAdd: isAdd, - } - - if vxLan.SrcAddress == vxLan.DstAddress { - return 0, fmt.Errorf("source and destination addresses must not be the same") - } - srcAddr := net.ParseIP(vxLan.SrcAddress).To4() - dstAddr := net.ParseIP(vxLan.DstAddress).To4() - if srcAddr == nil && dstAddr == nil { - srcAddr = net.ParseIP(vxLan.SrcAddress).To16() - dstAddr = net.ParseIP(vxLan.DstAddress).To16() - req.IsIPv6 = 1 - if srcAddr == nil || dstAddr == nil { - return 0, fmt.Errorf("invalid VXLAN address, src: %s, dst: %s", srcAddr, dstAddr) - } - } else if srcAddr == nil && dstAddr != nil || srcAddr != nil && dstAddr == nil { - return 0, fmt.Errorf("IP version mismatch for VXLAN destination and source IP addresses") - } - - req.Local = []byte(srcAddr) - req.Remote = []byte(dstAddr) - - reply := &vpp_gpe.VxlanGpeAddDelTunnelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - return reply.SwIfIndex, nil -} - -// AddVxLanGpeTunnel adds new VxLAN-GPE interface. -func (h *InterfaceVppHandler) AddVxLanGpeTunnel(ifName string, vrf, multicastIf uint32, vxLan *ifs.VxlanLink) (uint32, error) { - swIfIndex, err := h.vxLanGpeAddDelTunnel(1, vxLan, vrf, multicastIf) - if err != nil { - return 0, err - } - return swIfIndex, h.SetInterfaceTag(ifName, swIfIndex) -} - -// DeleteVxLanGpeTunnel removes VxLAN-GPE interface. -func (h *InterfaceVppHandler) DeleteVxLanGpeTunnel(ifName string, vxLan *ifs.VxlanLink) error { - swIfIndex, err := h.vxLanGpeAddDelTunnel(0, vxLan, 0, 0) - if err != nil { - return err - } - return h.RemoveInterfaceTag(ifName, swIfIndex) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_vppcalls.go deleted file mode 100644 index e8e9d602c9..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_vppcalls.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - vpp_vxlan "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) addDelVxLanTunnel(vxLan *ifs.VxlanLink, vrf, multicastIf uint32, isAdd bool) (swIdx uint32, err error) { - req := &vpp_vxlan.VxlanAddDelTunnel{ - IsAdd: boolToUint(isAdd), - Vni: vxLan.Vni, - DecapNextIndex: 0xFFFFFFFF, - Instance: ^uint32(0), - EncapVrfID: vrf, - McastSwIfIndex: multicastIf, - } - - srcAddr := net.ParseIP(vxLan.SrcAddress).To4() - dstAddr := net.ParseIP(vxLan.DstAddress).To4() - if srcAddr == nil && dstAddr == nil { - srcAddr = net.ParseIP(vxLan.SrcAddress).To16() - dstAddr = net.ParseIP(vxLan.DstAddress).To16() - req.IsIPv6 = 1 - if srcAddr == nil || dstAddr == nil { - return 0, fmt.Errorf("invalid VXLAN address, src: %s, dst: %s", srcAddr, dstAddr) - } - } else if srcAddr == nil && dstAddr != nil || srcAddr != nil && dstAddr == nil { - return 0, fmt.Errorf("IP version mismatch for VXLAN destination and source IP addresses") - } - - req.SrcAddress = []byte(srcAddr) - req.DstAddress = []byte(dstAddr) - - reply := &vpp_vxlan.VxlanAddDelTunnelReply{} - if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return 0, err - } - - return reply.SwIfIndex, nil -} - -// AddVxLanTunnel implements VxLan handler. -func (h *InterfaceVppHandler) AddVxLanTunnel(ifName string, vrf, multicastIf uint32, vxLan *ifs.VxlanLink) (swIndex uint32, err error) { - swIfIdx, err := h.addDelVxLanTunnel(vxLan, vrf, multicastIf, true) - if err != nil { - return 0, err - } - return swIfIdx, h.SetInterfaceTag(ifName, swIfIdx) -} - -// DeleteVxLanTunnel implements VxLan handler. -func (h *InterfaceVppHandler) DeleteVxLanTunnel(ifName string, idx, vrf uint32, vxLan *ifs.VxlanLink) error { - // Multicast does not need to be set - if _, err := h.addDelVxLanTunnel(vxLan, vrf, 0, false); err != nil { - return err - } - return h.RemoveInterfaceTag(ifName, idx) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_vppcalls_test.go deleted file mode 100644 index f0587c2376..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/vxlan_vppcalls_test.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "net" - "testing" - - . "github.com/onsi/gomega" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_vxlan "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vxlan" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func TestAddVxlanTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddVxLanTunnel("ifName", 0, 2, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "20.0.0.1", - Vni: 1, - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_vxlan.VxlanAddDelTunnel) - if ok { - Expect(vppMsg.SrcAddress).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) - Expect(vppMsg.DstAddress).To(BeEquivalentTo(net.ParseIP("20.0.0.1").To4())) - Expect(vppMsg.IsAdd).To(BeEquivalentTo(1)) - Expect(vppMsg.EncapVrfID).To(BeEquivalentTo(0)) - Expect(vppMsg.McastSwIfIndex).To(BeEquivalentTo(2)) - Expect(vppMsg.Vni).To(BeEquivalentTo(1)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(0)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddVxlanTunnelWithVrf(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - // VxLAN resolution - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddVxLanTunnel("ifName", 1, 1, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "20.0.0.1", - Vni: 1, - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_vxlan.VxlanAddDelTunnel) - if ok { - Expect(vppMsg.SrcAddress).To(BeEquivalentTo(net.ParseIP("10.0.0.1").To4())) - Expect(vppMsg.DstAddress).To(BeEquivalentTo(net.ParseIP("20.0.0.1").To4())) - Expect(vppMsg.IsAdd).To(BeEquivalentTo(1)) - Expect(vppMsg.EncapVrfID).To(BeEquivalentTo(1)) - Expect(vppMsg.McastSwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.Vni).To(BeEquivalentTo(1)) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(0)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddVxlanTunnelIPv6(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - swIfIdx, err := ifHandler.AddVxLanTunnel("ifName", 0, 0, &ifs.VxlanLink{ - SrcAddress: "2001:db8:0:1:1:1:1:1", - DstAddress: "2002:db8:0:1:1:1:1:1", - Vni: 1, - }) - Expect(err).To(BeNil()) - Expect(swIfIdx).To(BeEquivalentTo(1)) - var msgCheck bool - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_vxlan.VxlanAddDelTunnel) - if ok { - Expect(vppMsg.SrcAddress).To(BeEquivalentTo(net.ParseIP("2001:db8:0:1:1:1:1:1").To16())) - Expect(vppMsg.DstAddress).To(BeEquivalentTo(net.ParseIP("2002:db8:0:1:1:1:1:1").To16())) - Expect(vppMsg.IsIPv6).To(BeEquivalentTo(1)) - msgCheck = true - } - } - Expect(msgCheck).To(BeTrue()) -} - -func TestAddVxlanTunnelIPMismatch(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddVxLanTunnel("ifName", 0, 0, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "2001:db8:0:1:1:1:1:1", - Vni: 1, - }) - Expect(err).ToNot(BeNil()) -} - -func TestAddVxlanTunnelInvalidIP(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddVxLanTunnel("ifName", 0, 0, &ifs.VxlanLink{ - SrcAddress: "invalid-ip", - DstAddress: "2001:db8:0:1:1:1:1:1", - Vni: 1, - }) - Expect(err).ToNot(BeNil()) -} - -func TestAddVxlanTunnelError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnel{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddVxLanTunnel("ifName", 0, 0, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "20.0.0.2", - Vni: 1, - }) - Expect(err).ToNot(BeNil()) -} - -func TestAddVxlanTunnelRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - _, err := ifHandler.AddVxLanTunnel("ifName", 0, 0, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "20.0.0.2", - Vni: 1, - }) - Expect(err).ToNot(BeNil()) -} - -func TestDeleteVxlanTunnel(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - SwIfIndex: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteVxLanTunnel("ifName", 1, 0, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "20.0.0.1", - Vni: 1, - }) - Expect(err).To(BeNil()) -} - -func TestDeleteVxlanTunnelError(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnel{}) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteVxLanTunnel("ifName", 1, 0, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "20.0.0.1", - Vni: 1, - }) - Expect(err).ToNot(BeNil()) -} - -func TestDeleteVxlanTunnelRetval(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vxlan.VxlanAddDelTunnelReply{ - Retval: 1, - }) - ctx.MockVpp.MockReply(&vpp_ifs.SwInterfaceTagAddDelReply{}) - - err := ifHandler.DeleteVxLanTunnel("ifName", 1, 0, &ifs.VxlanLink{ - SrcAddress: "10.0.0.1", - DstAddress: "20.0.0.1", - Vni: 1, - }) - Expect(err).ToNot(BeNil()) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls.go deleted file mode 100644 index 24c0f19118..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls.go +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "net" - "os" - "strings" - "time" - - govppapi "git.fd.io/govpp.git/api" - "github.com/pkg/errors" - - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" -) - -var ( - // EventDeliverTimeout defines maximum time to deliver event upstream. - EventDeliverTimeout = time.Second - // NotifChanBufferSize defines size of notification channel buffer. - NotifChanBufferSize = 10 -) - -func (h *InterfaceVppHandler) WatchInterfaceEvents(ctx context.Context, eventsCh chan<- *vppcalls.InterfaceEvent) error { - notifChan := make(chan govppapi.Message, NotifChanBufferSize) - - // subscribe to SwInterfaceEvent notifications - sub, err := h.callsChannel.SubscribeNotification(notifChan, &vpp_ifs.SwInterfaceEvent{}) - if err != nil { - return errors.Errorf("subscribing to VPP notification (sw_interface_event) failed: %v", err) - } - unsub := func() { - if err := sub.Unsubscribe(); err != nil { - h.log.Warnf("unsubscribing VPP notification (sw_interface_event) failed: %v", err) - } - } - - go func() { - h.log.Debugf("start watching interface events") - defer h.log.Debugf("done watching interface events (%v)", ctx.Err()) - - for { - select { - case e, open := <-notifChan: - if !open { - h.log.Debugf("interface events channel was closed") - unsub() - return - } - - ifEvent, ok := e.(*vpp_ifs.SwInterfaceEvent) - if !ok { - h.log.Debugf("unexpected notification type: %#v", ifEvent) - continue - } - - // try to send event - select { - case eventsCh <- toInterfaceEvent(ifEvent): - // sent ok - case <-ctx.Done(): - unsub() - return - default: - // channel full send event in goroutine for later processing - go func() { - select { - case eventsCh <- toInterfaceEvent(ifEvent): - // sent ok - case <-time.After(EventDeliverTimeout): - h.log.Warnf("unable to deliver interface event, dropping it: %+v", ifEvent) - } - }() - } - case <-ctx.Done(): - unsub() - return - } - } - }() - - // enable interface events from VPP - if _, err := h.interfaces.WantInterfaceEvents(ctx, &vpp_ifs.WantInterfaceEvents{ - PID: uint32(os.Getpid()), - EnableDisable: 1, - }); err != nil { - if errors.Is(err, govppapi.VPPApiError(govppapi.INVALID_REGISTRATION)) { - h.log.Warnf("already subscribed to interface events: %v", err) - return nil - } - return errors.Errorf("failed to watch interface events: %v", err) - } - - return nil -} - -func (h *InterfaceVppHandler) WatchDHCPLeases(ctx context.Context, leasesCh chan<- *vppcalls.Lease) error { - notifChan := make(chan govppapi.Message, NotifChanBufferSize) - - // subscribe for receiving DHCPComplEvent notifications - sub, err := h.callsChannel.SubscribeNotification(notifChan, &vpp_dhcp.DHCPComplEvent{}) - if err != nil { - return errors.Errorf("subscribing to VPP notification (dhcp_compl_event) failed: %v", err) - } - unsub := func() { - if err := sub.Unsubscribe(); err != nil { - h.log.Warnf("unsubscribing VPP notification (dhcp_compl_event) failed: %v", err) - } - } - - go func() { - h.log.Debugf("start watching DHCP leases") - defer h.log.Debugf("done watching DHCP lease (%v)", ctx.Err()) - - for { - select { - case e, open := <-notifChan: - if !open { - h.log.Debugf("interface notification channel was closed") - unsub() - return - } - - dhcpEvent, ok := e.(*vpp_dhcp.DHCPComplEvent) - if !ok { - h.log.Debugf("unexpected notification type: %#v", dhcpEvent) - continue - } - - // try to send event - select { - case leasesCh <- toDHCPLease(dhcpEvent): - // sent ok - case <-ctx.Done(): - unsub() - return - default: - // channel full send event in goroutine for later processing - go func() { - select { - case leasesCh <- toDHCPLease(dhcpEvent): - // sent ok - case <-time.After(EventDeliverTimeout): - h.log.Warnf("unable to deliver DHCP lease event, dropping it: %+v", dhcpEvent) - } - }() - } - case <-ctx.Done(): - unsub() - return - } - } - }() - - return nil -} - -func toInterfaceEvent(ifEvent *vpp_ifs.SwInterfaceEvent) *vppcalls.InterfaceEvent { - event := &vppcalls.InterfaceEvent{ - SwIfIndex: uint32(ifEvent.SwIfIndex), - Deleted: ifEvent.Deleted, - } - if ifEvent.Flags&interface_types.IF_STATUS_API_FLAG_ADMIN_UP == interface_types.IF_STATUS_API_FLAG_ADMIN_UP { - event.AdminState = 1 - } - if ifEvent.Flags&interface_types.IF_STATUS_API_FLAG_LINK_UP == interface_types.IF_STATUS_API_FLAG_LINK_UP { - event.LinkState = 1 - } - return event -} - -func toDHCPLease(dhcpEvent *vpp_dhcp.DHCPComplEvent) *vppcalls.Lease { - lease := dhcpEvent.Lease - return &vppcalls.Lease{ - SwIfIndex: uint32(lease.SwIfIndex), - State: uint8(lease.State), - Hostname: strings.TrimRight(lease.Hostname, "\x00"), - IsIPv6: lease.IsIPv6, - HostAddress: dhcpAddressToString(lease.HostAddress, uint32(lease.MaskWidth), lease.IsIPv6), - RouterAddress: dhcpAddressToString(lease.RouterAddress, uint32(lease.MaskWidth), lease.IsIPv6), - HostMac: net.HardwareAddr(lease.HostMac[:]).String(), - } -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls_test.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls_test.go deleted file mode 100644 index 40e707446e..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/watch_vppcalls_test.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "net" - "testing" - - . "github.com/onsi/gomega" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" -) - -func TestWatchInterfaceEvents(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - ctx.MockVpp.MockReply(&interfaces.WantInterfaceEventsReply{}) - eventsChan := make(chan *vppcalls.InterfaceEvent) - err := ifHandler.WatchInterfaceEvents(ctx.Context, eventsChan) - notifChan := ctx.MockChannel.GetChannel() - Expect(notifChan).ToNot(BeNil()) - Expect(err).To(BeNil()) - - notifChan <- &interfaces.SwInterfaceEvent{ - SwIfIndex: 1, - Flags: 3, - Deleted: true, - } - var result *vppcalls.InterfaceEvent - Eventually(eventsChan, 2).Should(Receive(&result)) - Expect(result).To(Equal(&vppcalls.InterfaceEvent{ - SwIfIndex: 1, - AdminState: 1, - LinkState: 1, - Deleted: true, - })) - - notifChan <- &interfaces.SwInterfaceEvent{ - SwIfIndex: 2, - Flags: 1, - Deleted: true, - } - result = &vppcalls.InterfaceEvent{} - Eventually(eventsChan, 2).Should(Receive(&result)) - Expect(result).To(Equal(&vppcalls.InterfaceEvent{SwIfIndex: 2, AdminState: 1, LinkState: 0, Deleted: true})) - - notifChan <- &interfaces.SwInterfaceEvent{ - SwIfIndex: 3, - Flags: 3, - Deleted: false, - } - result = &vppcalls.InterfaceEvent{} - Eventually(eventsChan, 2).Should(Receive(&result)) - Expect(result).To(Equal(&vppcalls.InterfaceEvent{ - SwIfIndex: 3, - AdminState: 1, - LinkState: 1, - Deleted: false, - })) - - close(notifChan) -} - -func TestWatchDHCPLeases(t *testing.T) { - ctx, ifHandler := ifTestSetup(t) - defer ctx.TeardownTestCtx() - leasesChChan := make(chan *vppcalls.Lease) - err := ifHandler.WatchDHCPLeases(ctx.Context, leasesChChan) - notifChan := ctx.MockChannel.GetChannel() - Expect(notifChan).ToNot(BeNil()) - Expect(err).To(BeNil()) - - var hostAddr, routerAddr [16]byte - copy(hostAddr[:], net.ParseIP("10.10.10.5").To4()) - copy(routerAddr[:], net.ParseIP("10.10.10.1").To4()) - - notifChan <- &dhcp.DHCPComplEvent{ - PID: 50, - Lease: dhcp.DHCPLease{ - SwIfIndex: 1, - State: 1, - Hostname: "host1", - IsIPv6: false, - MaskWidth: 24, - HostAddress: dhcp.Address{Un: dhcp.AddressUnion{XXX_UnionData: hostAddr}}, - RouterAddress: dhcp.Address{Un: dhcp.AddressUnion{XXX_UnionData: routerAddr}}, - HostMac: [6]byte{16, 16, 32, 32, 48, 48}, - }, - } - var result *vppcalls.Lease - Eventually(leasesChChan, 50).Should(Receive(&result)) - Expect(result).To(Equal(&vppcalls.Lease{ - SwIfIndex: 1, - State: 1, - Hostname: "host1", - HostAddress: "10.10.10.5/24", - RouterAddress: "10.10.10.1/24", - HostMac: "10:10:20:20:30:30", - })) - - copy(hostAddr[:], net.ParseIP("1234::").To16()) - copy(routerAddr[:], net.ParseIP("abcd::").To16()) - - notifChan <- &dhcp.DHCPComplEvent{ - PID: 50, - Lease: dhcp.DHCPLease{ - SwIfIndex: 2, - State: 0, - Hostname: "host2", - IsIPv6: true, - MaskWidth: 64, - HostAddress: dhcp.Address{Un: dhcp.AddressUnion{XXX_UnionData: hostAddr}}, - RouterAddress: dhcp.Address{Un: dhcp.AddressUnion{XXX_UnionData: routerAddr}}, - HostMac: [6]byte{16, 16, 32, 32, 64, 64}, - }, - } - Eventually(leasesChChan, 2).Should(Receive(&result)) - Expect(result).To(Equal(&vppcalls.Lease{ - SwIfIndex: 2, - Hostname: "host2", - IsIPv6: true, - HostAddress: "1234::/64", - RouterAddress: "abcd::/64", - HostMac: "10:10:20:20:40:40", - })) - - close(leasesChChan) -} diff --git a/plugins/vpp/ifplugin/vppcalls/vpp2001/wireguard_vppcalls.go b/plugins/vpp/ifplugin/vppcalls/vpp2001/wireguard_vppcalls.go deleted file mode 100644 index 632e158c9e..0000000000 --- a/plugins/vpp/ifplugin/vppcalls/vpp2001/wireguard_vppcalls.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2020 Doc.ai and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - interfaces "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" -) - -func (h *InterfaceVppHandler) AddWireguardTunnel(ifName string, wireguardLink *interfaces.WireguardLink) (uint32, error) { - return 0, fmt.Errorf("%w in VPP 20.01", vppcalls.ErrWireguardUnsupported) -} - -func (h *InterfaceVppHandler) DeleteWireguardTunnel(ifName string, ifIdx uint32) error { - return fmt.Errorf("%w in VPP 20.01", vppcalls.ErrWireguardUnsupported) -} - diff --git a/plugins/vpp/ipfixplugin/ipfixplugin.go b/plugins/vpp/ipfixplugin/ipfixplugin.go index c78cf873ba..5018d98d4f 100644 --- a/plugins/vpp/ipfixplugin/ipfixplugin.go +++ b/plugins/vpp/ipfixplugin/ipfixplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/descriptor" "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/vppcalls" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/dump_vppcalls.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2001/dump_vppcalls.go deleted file mode 100644 index fb0f103252..0000000000 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/dump_vppcalls.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - vpp_ipfix "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipfix_export" - ipfix "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipfix" -) - -// DumpExporters returns configured IPFIX. -// Since it always only one IPFIX configuration, this method signature -// defined as it is to keep consistensy between different vppcalls packages. -// -// Caution: VPP 20.01 does not support IPv6 addresses for IPFIX configuration, -// but this may change in future versions. Be careful porting this method to -// another version of VPP. -// -func (h *IpfixVppHandler) DumpExporters() ([]*ipfix.IPFIX, error) { - var ipfixes []*ipfix.IPFIX - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ipfix.IpfixExporterDump{}) - for { - details := &vpp_ipfix.IpfixExporterDetails{} - stop, err := reqCtx.ReceiveReply(details) - if stop { - break - } - if err != nil { - return nil, fmt.Errorf("failed to dump IPFIX: %v", err) - } - - collectorIPAddr := details.CollectorAddress.Un.GetIP4() - sourceIPAddr := details.SrcAddress.Un.GetIP4() - - ipfixes = append(ipfixes, - &ipfix.IPFIX{ - Collector: &ipfix.IPFIX_Collector{ - Address: net.IP(collectorIPAddr[:]).To4().String(), - Port: uint32(details.CollectorPort), - }, - SourceAddress: net.IP(sourceIPAddr[:]).To4().String(), - VrfId: details.VrfID, - PathMtu: details.PathMtu, - TemplateInterval: details.TemplateInterval, - }, - ) - - } - - return ipfixes, nil -} diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/flowprobe_vppcalls.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2001/flowprobe_vppcalls.go deleted file mode 100644 index e732ee4c88..0000000000 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/flowprobe_vppcalls.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "github.com/pkg/errors" - - vpp_flowprobe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/flowprobe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - ipfix "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipfix" -) - -// SetFPParams sends message with configuration for Flowprobe. -func (h *IpfixVppHandler) SetFPParams(conf *ipfix.FlowProbeParams) error { - var flags vpp_flowprobe.FlowprobeRecordFlags - - if conf.GetRecordL2() { - flags |= vpp_flowprobe.FLOWPROBE_RECORD_FLAG_L2 - } - - if conf.GetRecordL3() { - flags |= vpp_flowprobe.FLOWPROBE_RECORD_FLAG_L3 - } - - if conf.GetRecordL4() { - flags |= vpp_flowprobe.FLOWPROBE_RECORD_FLAG_L4 - } - - if flags == 0 { - err := errors.New("one of the record fields (l2, l3 or l4) must be enabled") - return err - } - - req := &vpp_flowprobe.FlowprobeParams{ - RecordFlags: flags, - ActiveTimer: conf.GetActiveTimer(), - PassiveTimer: conf.GetPassiveTimer(), - } - reply := &vpp_flowprobe.FlowprobeParamsReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *IpfixVppHandler) sendFPFeature(isAdd bool, conf *ipfix.FlowProbeFeature) error { - meta, found := h.ifIndexes.LookupByName(conf.Interface) - if !found { - return errors.Errorf("interface %s not found", conf.Interface) - } - - var flags vpp_flowprobe.FlowprobeWhichFlags - - if conf.GetL2() { - flags |= vpp_flowprobe.FLOWPROBE_WHICH_FLAG_L2 - } - - if conf.GetIp4() { - flags |= vpp_flowprobe.FLOWPROBE_WHICH_FLAG_IP4 - } - - if conf.GetIp6() { - flags |= vpp_flowprobe.FLOWPROBE_WHICH_FLAG_IP6 - } - - req := &vpp_flowprobe.FlowprobeTxInterfaceAddDel{ - IsAdd: isAdd, - Which: flags, - SwIfIndex: interface_types.InterfaceIndex(meta.SwIfIndex), - } - reply := &vpp_flowprobe.FlowprobeTxInterfaceAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// AddFPFeature sends message to enable Flowprobe on interface. -func (h *IpfixVppHandler) AddFPFeature(conf *ipfix.FlowProbeFeature) error { - return h.sendFPFeature(true, conf) -} - -// DelFPFeature sends message to disable Flowprobe on interface. -func (h *IpfixVppHandler) DelFPFeature(conf *ipfix.FlowProbeFeature) error { - return h.sendFPFeature(false, conf) -} diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/ipfix_vppcalls.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2001/ipfix_vppcalls.go deleted file mode 100644 index 3162c938a9..0000000000 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/ipfix_vppcalls.go +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "bytes" - "errors" - "fmt" - "net" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipfix "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipfix_export" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/vppcalls" - ipfix "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipfix" -) - -// SetExporter configures IP Flow Information eXport (IPFIX). -func (h *IpfixVppHandler) SetExporter(conf *ipfix.IPFIX) error { - collectorAddr, err := prepareAddress(conf.GetCollector().GetAddress()) - if err != nil { - return fmt.Errorf("bad collector address: %v", err) - } - - sourceAddr, err := prepareAddress(conf.GetSourceAddress()) - if err != nil { - return fmt.Errorf("bad source address: %v", err) - } - - collectorPort := uint16(conf.GetCollector().GetPort()) - if collectorPort == 0 { - // Will be set by VPP to the default value: 4739. - collectorPort = ^uint16(0) - } - - mtu := conf.GetPathMtu() - if mtu == 0 { - // Will be set by VPP to the default value: 512 bytes. - mtu = ^uint32(0) - } else if mtu < vppcalls.MinPathMTU || mtu > vppcalls.MaxPathMTU { - err := errors.New("path MTU is not in allowed range") - return err - } - - tmplInterval := conf.GetTemplateInterval() - if tmplInterval == 0 { - // Will be set by VPP to the default value: 20 sec. - tmplInterval = ^uint32(0) - } - - req := &vpp_ipfix.SetIpfixExporter{ - CollectorAddress: collectorAddr, - CollectorPort: collectorPort, - SrcAddress: sourceAddr, - VrfID: conf.GetVrfId(), - PathMtu: mtu, - TemplateInterval: tmplInterval, - } - reply := &vpp_ipfix.SetIpfixExporterReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// prepareAddress validates and converts IP address, defined as a string, -// to the type which represents address in VPP binary API. -func prepareAddress(addrStr string) (ip_types.Address, error) { - var a ip_types.Address - - addr := net.ParseIP(addrStr) - if addr == nil { - err := errors.New("can not parse address") - return a, err - } - if addr.To4() == nil { - err := errors.New("IPv6 is not supported") - return a, err - } - - var addrBytes [4]byte - copy(addrBytes[:], addr.To4()) - if bytes.Equal(addrBytes[:], []byte{0, 0, 0, 0}) { - err := errors.New("address must not be all zeros") - return a, err - } - - a = ip_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4(addrBytes), - } - - return a, nil -} diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/vppcalls_handlers.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2001/vppcalls_handlers.go deleted file mode 100644 index af51afa373..0000000000 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2001/vppcalls_handlers.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - vpp_fp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/flowprobe" - vpp_ipfix "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipfix_export" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ipfixplugin/vppcalls" -) - -func init() { - var msgs []govppapi.Message - msgs = append(msgs, vpp_ipfix.AllMessages()...) - msgs = append(msgs, vpp_fp.AllMessages()...) - - vppcalls.AddIpfixHandlerVersion(vpp2001.Version, msgs, NewIpfixVppHandler) -} - -// IpfixVppHandler is accessor for IPFIX-related vppcalls methods. -type IpfixVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// NewIpfixVppHandler creates new instance of IPFIX vppcalls handler. -func NewIpfixVppHandler(callsChan govppapi.Channel, - ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger, -) vppcalls.IpfixVppAPI { - return &IpfixVppHandler{ - callsChannel: callsChan, - ifIndexes: ifIndexes, - log: log, - } -} diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2005/dump_vppcalls.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2005/dump_vppcalls.go index 4d1141b084..9eb07ca552 100644 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2005/dump_vppcalls.go +++ b/plugins/vpp/ipfixplugin/vppcalls/vpp2005/dump_vppcalls.go @@ -26,7 +26,7 @@ import ( // Since it always only one IPFIX configuration, this method signature // defined as it is to keep consistensy between different vppcalls packages. // -// Caution: VPP 20.01 does not support IPv6 addresses for IPFIX configuration, +// Caution: VPP 20.05 does not support IPv6 addresses for IPFIX configuration, // but this may change in future versions. Be careful porting this method to // another version of VPP. // diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2009/dump_vppcalls.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2009/dump_vppcalls.go index 9c7300d0f0..9307016ba6 100644 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2009/dump_vppcalls.go +++ b/plugins/vpp/ipfixplugin/vppcalls/vpp2009/dump_vppcalls.go @@ -26,7 +26,7 @@ import ( // Since it always only one IPFIX configuration, this method signature // defined as it is to keep consistensy between different vppcalls packages. // -// Caution: VPP 20.01 does not support IPv6 addresses for IPFIX configuration, +// Caution: VPP 20.09 does not support IPv6 addresses for IPFIX configuration, // but this may change in future versions. Be careful porting this method to // another version of VPP. // diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2101/dump_vppcalls.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2101/dump_vppcalls.go index af8ee7e811..3b391e1d10 100644 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2101/dump_vppcalls.go +++ b/plugins/vpp/ipfixplugin/vppcalls/vpp2101/dump_vppcalls.go @@ -26,7 +26,7 @@ import ( // Since it always only one IPFIX configuration, this method signature // defined as it is to keep consistensy between different vppcalls packages. // -// Caution: VPP 20.01 does not support IPv6 addresses for IPFIX configuration, +// Caution: VPP 21.01 does not support IPv6 addresses for IPFIX configuration, // but this may change in future versions. Be careful porting this method to // another version of VPP. // diff --git a/plugins/vpp/ipfixplugin/vppcalls/vpp2106/dump_vppcalls.go b/plugins/vpp/ipfixplugin/vppcalls/vpp2106/dump_vppcalls.go index 4a8c8b193f..f6141adf49 100644 --- a/plugins/vpp/ipfixplugin/vppcalls/vpp2106/dump_vppcalls.go +++ b/plugins/vpp/ipfixplugin/vppcalls/vpp2106/dump_vppcalls.go @@ -26,7 +26,7 @@ import ( // Since it always only one IPFIX configuration, this method signature // defined as it is to keep consistensy between different vppcalls packages. // -// Caution: VPP 20.01 does not support IPv6 addresses for IPFIX configuration, +// Caution: VPP 21.06 does not support IPv6 addresses for IPFIX configuration, // but this may change in future versions. Be careful porting this method to // another version of VPP. // diff --git a/plugins/vpp/ipsecplugin/ipsecplugin.go b/plugins/vpp/ipsecplugin/ipsecplugin.go index 31367c6e69..1e332d988f 100644 --- a/plugins/vpp/ipsecplugin/ipsecplugin.go +++ b/plugins/vpp/ipsecplugin/ipsecplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/descriptor/adapter" "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/dump_vppcalls.go b/plugins/vpp/ipsecplugin/vppcalls/vpp2001/dump_vppcalls.go deleted file mode 100644 index 8f28a0b61a..0000000000 --- a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/dump_vppcalls.go +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "encoding/hex" - "net" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipsec "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls" - ipsec "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipsec" -) - -// DumpIPSecSA implements IPSec handler. -func (h *IPSecVppHandler) DumpIPSecSA() (saList []*vppcalls.IPSecSaDetails, err error) { - return h.DumpIPSecSAWithIndex(^uint32(0)) // Get everything -} - -// DumpIPSecSAWithIndex implements IPSec handler. -func (h *IPSecVppHandler) DumpIPSecSAWithIndex(saID uint32) (saList []*vppcalls.IPSecSaDetails, err error) { - saDetails, err := h.dumpSecurityAssociations(saID) - if err != nil { - return nil, err - } - - for _, saData := range saDetails { - // Skip tunnel interfaces - if saData.SwIfIndex != ^uint32(0) { - continue - } - - var tunnelSrcAddr, tunnelDstAddr net.IP - if saData.Entry.TunnelDst.Af == ip_types.ADDRESS_IP6 { - src := saData.Entry.TunnelSrc.Un.GetIP6() - dst := saData.Entry.TunnelDst.Un.GetIP6() - tunnelSrcAddr, tunnelDstAddr = net.IP(src[:]), net.IP(dst[:]) - } else { - src := saData.Entry.TunnelSrc.Un.GetIP4() - dst := saData.Entry.TunnelDst.Un.GetIP4() - tunnelSrcAddr, tunnelDstAddr = net.IP(src[:]), net.IP(dst[:]) - } - - sa := &ipsec.SecurityAssociation{ - Index: saData.Entry.SadID, - Spi: saData.Entry.Spi, - Protocol: ipsec.SecurityAssociation_IPSecProtocol(saData.Entry.Protocol), - CryptoAlg: ipsec.CryptoAlg(saData.Entry.CryptoAlgorithm), - CryptoKey: hex.EncodeToString(saData.Entry.CryptoKey.Data[:saData.Entry.CryptoKey.Length]), - CryptoSalt: saData.Entry.Salt, - IntegAlg: ipsec.IntegAlg(saData.Entry.IntegrityAlgorithm), - IntegKey: hex.EncodeToString(saData.Entry.IntegrityKey.Data[:saData.Entry.IntegrityKey.Length]), - UseEsn: (saData.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_USE_ESN) != 0, - UseAntiReplay: (saData.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY) != 0, - EnableUdpEncap: (saData.Entry.Flags & ipsec_types.IPSEC_API_SAD_FLAG_UDP_ENCAP) != 0, - } - if !tunnelSrcAddr.IsUnspecified() { - sa.TunnelSrcAddr = tunnelSrcAddr.String() - } - if !tunnelDstAddr.IsUnspecified() { - sa.TunnelDstAddr = tunnelDstAddr.String() - } - meta := &vppcalls.IPSecSaMeta{ - SaID: saData.Entry.SadID, - IfIdx: saData.SwIfIndex, - Salt: saData.Salt, - SeqOutbound: saData.SeqOutbound, - LastSeqInbound: saData.LastSeqInbound, - ReplayWindow: saData.ReplayWindow, - TotalDataSize: saData.TotalDataSize, - } - saList = append(saList, &vppcalls.IPSecSaDetails{ - Sa: sa, - Meta: meta, - }) - } - - return saList, nil -} - -// DumpIPSecSPD returns a list of IPSec security policy databases -func (h *IPSecVppHandler) DumpIPSecSPD() (spdList []*ipsec.SecurityPolicyDatabase, err error) { - // Note: dump IPSec SPD interfaces is not available in this VPP version - - // Get all VPP SPD indexes - spdIndexes, err := h.dumpSpdIndexes() - if err != nil { - return nil, errors.Errorf("failed to dump SPD indexes: %v", err) - } - for spdIdx, _ := range spdIndexes { - spd := &ipsec.SecurityPolicyDatabase{ - Index: spdIdx, - } - spdList = append(spdList, spd) - } - - return spdList, nil -} - -// DumpIPSecSP returns a list of configured security policies -func (h *IPSecVppHandler) DumpIPSecSP() (spList []*ipsec.SecurityPolicy, err error) { - // Get all VPP SPD indexes - spdIndexes, err := h.dumpSpdIndexes() - if err != nil { - return nil, errors.Errorf("failed to dump SPD indexes: %v", err) - } - for spdIdx, _ := range spdIndexes { - req := &vpp_ipsec.IpsecSpdDump{ - SpdID: spdIdx, - SaID: ^uint32(0), - } - requestCtx := h.callsChannel.SendMultiRequest(req) - - for { - spdDetails := &vpp_ipsec.IpsecSpdDetails{} - stop, err := requestCtx.ReceiveReply(spdDetails) - if stop { - break - } - if err != nil { - return nil, err - } - - // Addresses - remoteStartAddr := ipsecAddrToIP(spdDetails.Entry.RemoteAddressStart) - remoteStopAddr := ipsecAddrToIP(spdDetails.Entry.RemoteAddressStop) - localStartAddr := ipsecAddrToIP(spdDetails.Entry.LocalAddressStart) - localStopAddr := ipsecAddrToIP(spdDetails.Entry.LocalAddressStop) - - // Prepare policy entry and put to the SPD - sp := &ipsec.SecurityPolicy{ - SpdIndex: spdIdx, - SaIndex: spdDetails.Entry.SaID, - Priority: spdDetails.Entry.Priority, - IsOutbound: uintToBool(spdDetails.Entry.IsOutbound), - RemoteAddrStart: remoteStartAddr.String(), - RemoteAddrStop: remoteStopAddr.String(), - LocalAddrStart: localStartAddr.String(), - LocalAddrStop: localStopAddr.String(), - Protocol: uint32(spdDetails.Entry.Protocol), - RemotePortStart: uint32(spdDetails.Entry.RemotePortStart), - RemotePortStop: resetPort(spdDetails.Entry.RemotePortStop), - LocalPortStart: uint32(spdDetails.Entry.LocalPortStart), - LocalPortStop: resetPort(spdDetails.Entry.LocalPortStop), - Action: ipsec.SecurityPolicy_Action(spdDetails.Entry.Policy), - } - spList = append(spList, sp) - } - } - return spList, nil -} - -// DumpTunnelProtections returns configured IPSec tunnel protections. -func (h *IPSecVppHandler) DumpTunnelProtections() (tpList []*ipsec.TunnelProtection, err error) { - req := &vpp_ipsec.IpsecTunnelProtectDump{ - SwIfIndex: vpp_ipsec.InterfaceIndex(^uint32(0)), - } - requestCtx := h.callsChannel.SendMultiRequest(req) - for { - tpDetails := &vpp_ipsec.IpsecTunnelProtectDetails{} - stop, err := requestCtx.ReceiveReply(tpDetails) - if stop { - break - } - if err != nil { - return nil, err - } - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(uint32(tpDetails.Tun.SwIfIndex)) - if !exists { - h.log.Warnf("Tunnel protection dump: interface name for index %d not found", tpDetails.Tun.SwIfIndex) - continue - } - tp := &ipsec.TunnelProtection{ - Interface: ifName, - SaOut: []uint32{tpDetails.Tun.SaOut}, - } - tp.SaIn = append(tp.SaIn, tpDetails.Tun.SaIn...) - tpList = append(tpList, tp) - } - return -} - -// Get all indexes of SPD configured on the VPP -func (h *IPSecVppHandler) dumpSpdIndexes() (map[uint32]uint32, error) { - // SPD index to number of policies - spdIndexes := make(map[uint32]uint32) - - req := &vpp_ipsec.IpsecSpdsDump{} - reqCtx := h.callsChannel.SendMultiRequest(req) - - for { - spdDetails := &vpp_ipsec.IpsecSpdsDetails{} - stop, err := reqCtx.ReceiveReply(spdDetails) - if stop { - break - } - if err != nil { - return nil, err - } - - spdIndexes[spdDetails.SpdID] = spdDetails.Npolicies - } - - return spdIndexes, nil -} - -// Get all security association (used also for tunnel interfaces) in binary api format -func (h *IPSecVppHandler) dumpSecurityAssociations(saID uint32) (saList []*vpp_ipsec.IpsecSaDetails, err error) { - req := &vpp_ipsec.IpsecSaDump{ - SaID: saID, - } - requestCtx := h.callsChannel.SendMultiRequest(req) - - for { - saDetails := &vpp_ipsec.IpsecSaDetails{} - stop, err := requestCtx.ReceiveReply(saDetails) - if stop { - break - } - if err != nil { - return nil, err - } - - saList = append(saList, saDetails) - } - - return saList, nil -} - -// ResetPort returns 0 if stop port has maximum value (default VPP value if stop port is not defined) -func resetPort(port uint16) uint32 { - if port == ^uint16(0) { - return 0 - } - return uint32(port) -} - -func uintToBool(input uint8) bool { - if input == 1 { - return true - } - return false -} diff --git a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/ipsec_vppcalls.go b/plugins/vpp/ipsecplugin/vppcalls/vpp2001/ipsec_vppcalls.go deleted file mode 100644 index 06a608ed84..0000000000 --- a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/ipsec_vppcalls.go +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "encoding/hex" - "github.com/pkg/errors" - "go.ligato.io/cn-infra/v2/utils/addrs" - - vpp_ipsec "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec_types" - ipsec "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipsec" -) - -// AddSPD implements IPSec handler. -func (h *IPSecVppHandler) AddSPD(spdID uint32) error { - return h.spdAddDel(spdID, true) -} - -// DeleteSPD implements IPSec handler. -func (h *IPSecVppHandler) DeleteSPD(spdID uint32) error { - return h.spdAddDel(spdID, false) -} - -// AddSP implements IPSec handler. -func (h *IPSecVppHandler) AddSP(sp *ipsec.SecurityPolicy) error { - return h.spdAddDelEntry(sp, true) -} - -// DeleteSP implements IPSec handler. -func (h *IPSecVppHandler) DeleteSP(sp *ipsec.SecurityPolicy) error { - return h.spdAddDelEntry(sp, false) -} - -// AddSPDInterface implements IPSec handler. -func (h *IPSecVppHandler) AddSPDInterface(spdID uint32, ifaceCfg *ipsec.SecurityPolicyDatabase_Interface) error { - ifaceMeta, found := h.ifIndexes.LookupByName(ifaceCfg.Name) - if !found { - return errors.New("failed to get interface metadata") - } - return h.interfaceAddDelSpd(spdID, ifaceMeta.SwIfIndex, true) -} - -// DeleteSPDInterface implements IPSec handler. -func (h *IPSecVppHandler) DeleteSPDInterface(spdID uint32, ifaceCfg *ipsec.SecurityPolicyDatabase_Interface) error { - ifaceMeta, found := h.ifIndexes.LookupByName(ifaceCfg.Name) - if !found { - return errors.New("failed to get interface metadata") - } - return h.interfaceAddDelSpd(spdID, ifaceMeta.SwIfIndex, false) -} - -// AddSA implements IPSec handler. -func (h *IPSecVppHandler) AddSA(sa *ipsec.SecurityAssociation) error { - return h.sadAddDelEntry(sa, true) -} - -// DeleteSA implements IPSec handler. -func (h *IPSecVppHandler) DeleteSA(sa *ipsec.SecurityAssociation) error { - return h.sadAddDelEntry(sa, false) -} - -// AddTunnelProtection implements IPSec handler for adding a tunnel protection. -func (h *IPSecVppHandler) AddTunnelProtection(tp *ipsec.TunnelProtection) error { - ifaceMeta, found := h.ifIndexes.LookupByName(tp.Interface) - if !found { - return errors.New("failed to get interface metadata") - } - return h.tunProtectAddUpdateEntry(tp, ifaceMeta.SwIfIndex) -} - -// UpdateTunnelProtection implements IPSec handler for updating a tunnel protection. -func (h *IPSecVppHandler) UpdateTunnelProtection(tp *ipsec.TunnelProtection) error { - ifaceMeta, found := h.ifIndexes.LookupByName(tp.Interface) - if !found { - return errors.New("failed to get interface metadata") - } - return h.tunProtectAddUpdateEntry(tp, ifaceMeta.SwIfIndex) -} - -// DeleteTunnelProtection implements IPSec handler for deleting a tunnel protection. -func (h *IPSecVppHandler) DeleteTunnelProtection(tp *ipsec.TunnelProtection) error { - ifaceMeta, found := h.ifIndexes.LookupByName(tp.Interface) - if !found { - return errors.New("failed to get interface metadata") - } - return h.tunProtectDelEntry(tp, ifaceMeta.SwIfIndex) -} - -func (h *IPSecVppHandler) spdAddDel(spdID uint32, isAdd bool) error { - req := &vpp_ipsec.IpsecSpdAddDel{ - IsAdd: boolToUint(isAdd), - SpdID: spdID, - } - reply := &vpp_ipsec.IpsecSpdAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *IPSecVppHandler) spdAddDelEntry(sp *ipsec.SecurityPolicy, isAdd bool) error { - req := &vpp_ipsec.IpsecSpdEntryAddDel{ - IsAdd: boolToUint(isAdd), - Entry: vpp_ipsec.IpsecSpdEntry{ - SpdID: sp.SpdIndex, - Priority: sp.Priority, - IsOutbound: boolToUint(sp.IsOutbound), - Protocol: uint8(sp.Protocol), - RemotePortStart: uint16(sp.RemotePortStart), - RemotePortStop: uint16(sp.RemotePortStop), - LocalPortStart: uint16(sp.LocalPortStart), - LocalPortStop: uint16(sp.LocalPortStop), - Policy: vpp_ipsec.IpsecSpdAction(sp.Action), - SaID: sp.SaIndex, - }, - } - if req.Entry.RemotePortStop == 0 { - req.Entry.RemotePortStop = ^req.Entry.RemotePortStop - } - if req.Entry.LocalPortStop == 0 { - req.Entry.LocalPortStop = ^req.Entry.LocalPortStop - } - - var err error - req.Entry.RemoteAddressStart, err = IPToAddress(ipOr(sp.RemoteAddrStart, "0.0.0.0")) - if err != nil { - return err - } - req.Entry.RemoteAddressStop, err = IPToAddress(ipOr(sp.RemoteAddrStop, "255.255.255.255")) - if err != nil { - return err - } - req.Entry.LocalAddressStart, err = IPToAddress(ipOr(sp.LocalAddrStart, "0.0.0.0")) - if err != nil { - return err - } - req.Entry.LocalAddressStop, err = IPToAddress(ipOr(sp.LocalAddrStop, "255.255.255.255")) - if err != nil { - return err - } - - reply := &vpp_ipsec.IpsecSpdEntryAddDelReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func ipOr(s, o string) string { - if s != "" { - return s - } - return o -} - -func (h *IPSecVppHandler) interfaceAddDelSpd(spdID, swIfIdx uint32, isAdd bool) error { - req := &vpp_ipsec.IpsecInterfaceAddDelSpd{ - IsAdd: boolToUint(isAdd), - SwIfIndex: swIfIdx, - SpdID: spdID, - } - reply := &vpp_ipsec.IpsecInterfaceAddDelSpdReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *IPSecVppHandler) sadAddDelEntry(sa *ipsec.SecurityAssociation, isAdd bool) error { - cryptoKey, err := hex.DecodeString(sa.CryptoKey) - if err != nil { - return err - } - integKey, err := hex.DecodeString(sa.IntegKey) - if err != nil { - return err - } - - var flags vpp_ipsec.IpsecSadFlags - if sa.UseEsn { - flags |= ipsec_types.IPSEC_API_SAD_FLAG_USE_ESN - } - if sa.UseAntiReplay { - flags |= ipsec_types.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY - } - if sa.EnableUdpEncap { - flags |= ipsec_types.IPSEC_API_SAD_FLAG_UDP_ENCAP - } - var tunnelSrc, tunnelDst ipsec_types.Address - if sa.TunnelSrcAddr != "" { - flags |= ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL - isIPv6, err := addrs.IsIPv6(sa.TunnelSrcAddr) - if err != nil { - return err - } - if isIPv6 { - flags |= ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6 - } - tunnelSrc, err = IPToAddress(sa.TunnelSrcAddr) - if err != nil { - return err - } - tunnelDst, err = IPToAddress(sa.TunnelDstAddr) - if err != nil { - return err - } - } - - req := &vpp_ipsec.IpsecSadEntryAddDel{ - IsAdd: boolToUint(isAdd), - Entry: vpp_ipsec.IpsecSadEntry{ - SadID: sa.Index, - Spi: sa.Spi, - Protocol: vpp_ipsec.IpsecProto(sa.Protocol), - CryptoAlgorithm: vpp_ipsec.IpsecCryptoAlg(sa.CryptoAlg), - CryptoKey: vpp_ipsec.Key{ - Data: cryptoKey, - Length: uint8(len(cryptoKey)), - }, - Salt: sa.CryptoSalt, - IntegrityAlgorithm: vpp_ipsec.IpsecIntegAlg(sa.IntegAlg), - IntegrityKey: vpp_ipsec.Key{ - Data: integKey, - Length: uint8(len(integKey)), - }, - TunnelSrc: tunnelSrc, - TunnelDst: tunnelDst, - Flags: flags, - }, - } - reply := &vpp_ipsec.IpsecSadEntryAddDelReply{} - - if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func (h *IPSecVppHandler) tunProtectAddUpdateEntry(tp *ipsec.TunnelProtection, swIfIndex uint32) error { - if len(tp.SaOut) == 0 || len(tp.SaIn) == 0 { - return errors.New("missing outbound/inbound SA") - } - if len(tp.SaIn) > int(^uint8(0)) { - return errors.New("invalid number of inbound SAs") - } - req := &vpp_ipsec.IpsecTunnelProtectUpdate{Tunnel: vpp_ipsec.IpsecTunnelProtect{ - SwIfIndex: vpp_ipsec.InterfaceIndex(swIfIndex), - SaOut: tp.SaOut[0], - SaIn: tp.SaIn, - NSaIn: uint8(len(tp.SaIn)), - }} - reply := &vpp_ipsec.IpsecTunnelProtectUpdateReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - return nil -} - -func (h *IPSecVppHandler) tunProtectDelEntry(tp *ipsec.TunnelProtection, swIfIndex uint32) error { - req := &vpp_ipsec.IpsecTunnelProtectDel{ - SwIfIndex: vpp_ipsec.InterfaceIndex(swIfIndex), - } - reply := &vpp_ipsec.IpsecTunnelProtectDelReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - return nil -} - -func boolToUint(value bool) uint8 { - if value { - return 1 - } - return 0 -} diff --git a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/ipsec_vppcalls_test.go b/plugins/vpp/ipsecplugin/vppcalls/vpp2001/ipsec_vppcalls_test.go deleted file mode 100644 index fd32928242..0000000000 --- a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/ipsec_vppcalls_test.go +++ /dev/null @@ -1,379 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "encoding/hex" - "fmt" - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipsec "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - ipsec "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipsec" -) - -func ipToAddr(ip string) vpp_ipsec.Address { - addr, err := vpp2001.IPToAddress(ip) - if err != nil { - panic(fmt.Sprintf("invalid IP: %s", ip)) - } - return addr -} - -func TestVppAddSPD(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSpdAddDelReply{}) - - err := ipSecHandler.AddSPD(10) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSpdAddDel{ - IsAdd: 1, - SpdID: 10, - })) -} - -func TestVppDelSPD(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSpdAddDelReply{}) - - err := ipSecHandler.DeleteSPD(10) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSpdAddDel{ - IsAdd: 0, - SpdID: 10, - })) -} - -func TestVppAddSP(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSpdEntryAddDelReply{}) - - err := ipSecHandler.AddSP(&ipsec.SecurityPolicy{ - SaIndex: 5, - SpdIndex: 10, - Priority: 10, - IsOutbound: true, - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSpdEntryAddDel{ - IsAdd: 1, - Entry: vpp_ipsec.IpsecSpdEntry{ - SpdID: 10, - SaID: 5, - Priority: 10, - IsOutbound: 1, - RemoteAddressStart: ipToAddr("0.0.0.0"), - RemoteAddressStop: ipToAddr("255.255.255.255"), - LocalAddressStart: ipToAddr("0.0.0.0"), - LocalAddressStop: ipToAddr("255.255.255.255"), - RemotePortStop: 65535, - LocalPortStop: 65535, - }, - })) -} - -func TestVppDelSP(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSpdEntryAddDelReply{}) - - err := ipSecHandler.DeleteSP(&ipsec.SecurityPolicy{ - SpdIndex: 10, - SaIndex: 2, - Priority: 5, - IsOutbound: true, - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSpdEntryAddDel{ - IsAdd: 0, - Entry: vpp_ipsec.IpsecSpdEntry{ - SpdID: 10, - SaID: 2, - Priority: 5, - IsOutbound: 1, - RemoteAddressStart: ipToAddr("0.0.0.0"), - RemoteAddressStop: ipToAddr("255.255.255.255"), - LocalAddressStart: ipToAddr("0.0.0.0"), - LocalAddressStop: ipToAddr("255.255.255.255"), - RemotePortStop: 65535, - LocalPortStop: 65535, - }, - })) -} - -func TestVppInterfaceAddSPD(t *testing.T) { - ctx, ipSecHandler, ifIndex := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecInterfaceAddDelSpdReply{}) - - ifIndex.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - err := ipSecHandler.AddSPDInterface(10, &ipsec.SecurityPolicyDatabase_Interface{ - Name: "if1", - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecInterfaceAddDelSpd{ - IsAdd: 1, - SpdID: 10, - SwIfIndex: 2, - })) -} - -func TestVppInterfaceDelSPD(t *testing.T) { - ctx, ipSecHandler, ifIndex := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecInterfaceAddDelSpdReply{}) - - ifIndex.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - err := ipSecHandler.DeleteSPDInterface(10, &ipsec.SecurityPolicyDatabase_Interface{ - Name: "if1", - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecInterfaceAddDelSpd{ - IsAdd: 0, - SpdID: 10, - SwIfIndex: 2, - })) -} - -func ipSecTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.IPSecVppAPI, ifaceidx.IfaceMetadataIndexRW) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - ifIndex := ifaceidx.NewIfaceIndex(log, "ipsec-test-ifidx") - ipSecHandler := vpp2001.NewIPSecVppHandler(ctx.MockChannel, ifIndex, log) - return ctx, ipSecHandler, ifIndex -} - -func TestVppAddSA(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSadEntryAddDelReply{}) - - cryptoKey, err := hex.DecodeString("") - Expect(err).To(BeNil()) - - err = ipSecHandler.AddSA(&ipsec.SecurityAssociation{ - Index: 1, - Spi: uint32(1001), - UseEsn: true, - UseAntiReplay: true, - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSadEntryAddDel{ - IsAdd: 1, - Entry: vpp_ipsec.IpsecSadEntry{ - SadID: 1, - Spi: 1001, - CryptoKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - IntegrityKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - Flags: ipsec_types.IPSEC_API_SAD_FLAG_USE_ESN | ipsec_types.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY, - }, - })) -} - -func TestVppDelSA(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSadEntryAddDelReply{}) - - cryptoKey, err := hex.DecodeString("") - Expect(err).To(BeNil()) - - err = ipSecHandler.DeleteSA(&ipsec.SecurityAssociation{ - Index: 1, - Spi: uint32(1001), - UseEsn: true, - UseAntiReplay: true, - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSadEntryAddDel{ - IsAdd: 0, - Entry: vpp_ipsec.IpsecSadEntry{ - SadID: 1, - Spi: 1001, - CryptoKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - IntegrityKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - Flags: ipsec_types.IPSEC_API_SAD_FLAG_USE_ESN | ipsec_types.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY, - }, - })) -} - -func TestVppAddSATunnelMode(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSadEntryAddDelReply{}) - - cryptoKey, err := hex.DecodeString("") - Expect(err).To(BeNil()) - - err = ipSecHandler.AddSA(&ipsec.SecurityAssociation{ - Index: 1, - Spi: uint32(1001), - TunnelSrcAddr: "10.1.0.1", - TunnelDstAddr: "20.1.0.1", - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSadEntryAddDel{ - IsAdd: 1, - Entry: vpp_ipsec.IpsecSadEntry{ - SadID: 1, - Spi: 1001, - CryptoKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - IntegrityKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - TunnelSrc: ipsec_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ipsec_types.AddressUnion{XXX_UnionData: [16]byte{10, 1, 0, 1}}, - }, - TunnelDst: ipsec_types.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ipsec_types.AddressUnion{XXX_UnionData: [16]byte{20, 1, 0, 1}}, - }, - Flags: ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL, - }, - })) -} - -func TestVppAddSATunnelModeIPv6(t *testing.T) { - ctx, ipSecHandler, _ := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecSadEntryAddDelReply{}) - - cryptoKey, err := hex.DecodeString("") - Expect(err).To(BeNil()) - - err = ipSecHandler.AddSA(&ipsec.SecurityAssociation{ - Index: 1, - Spi: uint32(1001), - TunnelSrcAddr: "1234::", - TunnelDstAddr: "abcd::", - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecSadEntryAddDel{ - IsAdd: 1, - Entry: vpp_ipsec.IpsecSadEntry{ - SadID: 1, - Spi: 1001, - CryptoKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - IntegrityKey: vpp_ipsec.Key{ - Length: uint8(len(cryptoKey)), - Data: cryptoKey, - }, - TunnelSrc: ipsec_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ipsec_types.AddressUnion{XXX_UnionData: [16]byte{18, 52}}, - }, - TunnelDst: ipsec_types.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ipsec_types.AddressUnion{XXX_UnionData: [16]byte{171, 205}}, - }, - Flags: ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL | ipsec_types.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6, - }, - })) -} - -func TestVppAddTunnelProtection(t *testing.T) { - ctx, ipSecHandler, ifIndex := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndex.Put("ipip-tunnel", &ifaceidx.IfaceMetadata{SwIfIndex: 5}) - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecTunnelProtectUpdateReply{}) - err := ipSecHandler.AddTunnelProtection(&ipsec.TunnelProtection{ - Interface: "ipip-tunnel", - SaOut: []uint32{10}, - SaIn: []uint32{20, 30}, - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecTunnelProtectUpdate{ - Tunnel: vpp_ipsec.IpsecTunnelProtect{ - SwIfIndex: 5, - SaOut: 10, - NSaIn: 2, - SaIn: []uint32{20, 30}, - }, - })) -} - -func TestVppDelTunnelProtection(t *testing.T) { - ctx, ipSecHandler, ifIndex := ipSecTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndex.Put("ipip-tunnel", &ifaceidx.IfaceMetadata{SwIfIndex: 5}) - - ctx.MockVpp.MockReply(&vpp_ipsec.IpsecTunnelProtectDelReply{}) - - err := ipSecHandler.DeleteTunnelProtection(&ipsec.TunnelProtection{ - Interface: "ipip-tunnel", - }) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(BeEquivalentTo(&vpp_ipsec.IpsecTunnelProtectDel{ - SwIfIndex: 5, - })) -} diff --git a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/vppcalls_handlers.go b/plugins/vpp/ipsecplugin/vppcalls/vpp2001/vppcalls_handlers.go deleted file mode 100644 index dafc1b05e9..0000000000 --- a/plugins/vpp/ipsecplugin/vppcalls/vpp2001/vppcalls_handlers.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_ipsec "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ipsec" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ipsecplugin/vppcalls" -) - -func init() { - var msgs []govppapi.Message - msgs = append(msgs, vpp_ipsec.AllMessages()...) - - vppcalls.AddHandlerVersion(vpp2001.Version, msgs, NewIPSecVppHandler) -} - -// IPSecVppHandler is accessor for IPSec-related vppcalls methods -type IPSecVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -func NewIPSecVppHandler(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) vppcalls.IPSecVppAPI { - return &IPSecVppHandler{ch, ifIdx, log} -} - -func ipsecAddrToIP(addr vpp_ipsec.Address) net.IP { - if addr.Af == ip_types.ADDRESS_IP6 { - addrIP := addr.Un.GetIP6() - return net.IP(addrIP[:]) - } - addrIP := addr.Un.GetIP4() - return net.IP(addrIP[:]) -} - -func IPToAddress(ipstr string) (addr ip_types.Address, err error) { - netIP := net.ParseIP(ipstr) - if netIP == nil { - return ip_types.Address{}, fmt.Errorf("invalid IP: %q", ipstr) - } - if ip4 := netIP.To4(); ip4 == nil { - addr.Af = ip_types.ADDRESS_IP6 - var ip6addr ip_types.IP6Address - copy(ip6addr[:], netIP.To16()) - addr.Un.SetIP6(ip6addr) - } else { - addr.Af = ip_types.ADDRESS_IP4 - var ip4addr ip_types.IP4Address - copy(ip4addr[:], ip4) - addr.Un.SetIP4(ip4addr) - } - return -} diff --git a/plugins/vpp/l2plugin/l2plugin.go b/plugins/vpp/l2plugin/l2plugin.go index b8252e6e63..d81736a9c9 100644 --- a/plugins/vpp/l2plugin/l2plugin.go +++ b/plugins/vpp/l2plugin/l2plugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -32,7 +32,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/descriptor/adapter" "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls/vpp2101" diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/arp_term_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/arp_term_vppcalls.go deleted file mode 100644 index 3b489d87b4..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/arp_term_vppcalls.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" -) - -func (h *BridgeDomainVppHandler) callBdIPMacAddDel(isAdd bool, bdID uint32, mac string, ip string) error { - ipAddr, err := ipToAddress(ip) - if err != nil { - return err - } - macAddr, err := net.ParseMAC(mac) - if err != nil { - return err - } - bdEntry := vpp_l2.BdIPMac{ - BdID: bdID, - IP: ipAddr, - } - copy(bdEntry.Mac[:], macAddr) - - req := &vpp_l2.BdIPMacAddDel{ - IsAdd: boolToUint(isAdd), - Entry: bdEntry, - } - - reply := &vpp_l2.BdIPMacAddDelReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// AddArpTerminationTableEntry creates ARP termination entry for bridge domain. -func (h *BridgeDomainVppHandler) AddArpTerminationTableEntry(bdID uint32, mac string, ip string) error { - err := h.callBdIPMacAddDel(true, bdID, mac, ip) - if err != nil { - return err - } - return nil -} - -// RemoveArpTerminationTableEntry removes ARP termination entry from bridge domain. -func (h *BridgeDomainVppHandler) RemoveArpTerminationTableEntry(bdID uint32, mac string, ip string) error { - err := h.callBdIPMacAddDel(false, bdID, mac, ip) - if err != nil { - return err - } - return nil -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/arp_term_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/arp_term_vppcalls_test.go deleted file mode 100644 index 253a10f299..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/arp_term_vppcalls_test.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" -) - -func TestVppAddArpTerminationTableEntry(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BdIPMacAddDelReply{}) - - err := bdHandler.AddArpTerminationTableEntry( - 4, "FF:FF:FF:FF:FF:FF", "192.168.4.4") - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(&vpp_l2.BdIPMacAddDel{ - Entry: vpp_l2.BdIPMac{ - BdID: 4, - IP: vpp_l2.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4( - vpp_l2.IP4Address{192, 168, 4, 4}, - ), - }, - Mac: vpp_l2.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - }, - IsAdd: 1, - })) -} - -func TestVppAddArpTerminationTableEntryIPv6(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BdIPMacAddDelReply{}) - - err := bdHandler.AddArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "2001:db9::54") - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(&vpp_l2.BdIPMacAddDel{ - Entry: vpp_l2.BdIPMac{ - BdID: 4, - IP: vpp_l2.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6( - vpp_l2.IP6Address{32, 1, 13, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84}, - ), - }, - Mac: vpp_l2.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - }, - IsAdd: 1, - })) -} - -func TestVppRemoveArpTerminationTableEntry(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BdIPMacAddDelReply{}) - - err := bdHandler.RemoveArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "192.168.4.4") - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(&vpp_l2.BdIPMacAddDel{ - Entry: vpp_l2.BdIPMac{ - BdID: 4, - IP: vpp_l2.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4( - vpp_l2.IP4Address{192, 168, 4, 4}, - ), - }, - Mac: vpp_l2.MacAddress{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - }, - IsAdd: 0, - })) -} - -func TestVppArpTerminationTableEntryMacError(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BdIPMacAddDelReply{}) - - err := bdHandler.AddArpTerminationTableEntry(4, "in:va:li:d:ma:c", "192.168.4.4") - Expect(err).Should(HaveOccurred()) - - err = bdHandler.RemoveArpTerminationTableEntry(4, "in:va:li:d:ma:c", "192.168.4.4") - Expect(err).Should(HaveOccurred()) -} - -func TestVppArpTerminationTableEntryIpError(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BdIPMacAddDelReply{}) - - err := bdHandler.AddArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "") - Expect(err).Should(HaveOccurred()) - - err = bdHandler.RemoveArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "") - Expect(err).Should(HaveOccurred()) -} - -func TestVppArpTerminationTableEntryError(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BdIPMacAddDelReply{ - Retval: 1, - }) - - err := bdHandler.AddArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "192.168.4.4") - Expect(err).Should(HaveOccurred()) - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - - err = bdHandler.RemoveArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "192.168.4.4") - Expect(err).Should(HaveOccurred()) -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/bridge_domain_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/bridge_domain_vppcalls.go deleted file mode 100644 index 5568fc971a..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/bridge_domain_vppcalls.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -// AddBridgeDomain adds new bridge domain. -func (h *BridgeDomainVppHandler) AddBridgeDomain(bdIdx uint32, bd *l2.BridgeDomain) error { - req := &vpp_l2.BridgeDomainAddDel{ - IsAdd: 1, - BdID: bdIdx, - Learn: boolToUint(bd.Learn), - ArpTerm: boolToUint(bd.ArpTermination), - Flood: boolToUint(bd.Flood), - UuFlood: boolToUint(bd.UnknownUnicastFlood), - Forward: boolToUint(bd.Forward), - MacAge: uint8(bd.MacAge), - BdTag: []byte(bd.Name), - } - reply := &vpp_l2.BridgeDomainAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// DeleteBridgeDomain removes existing bridge domain. -func (h *BridgeDomainVppHandler) DeleteBridgeDomain(bdIdx uint32) error { - req := &vpp_l2.BridgeDomainAddDel{ - IsAdd: 0, - BdID: bdIdx, - } - reply := &vpp_l2.BridgeDomainAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func boolToUint(value bool) uint8 { - if value { - return 1 - } - return 0 -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/bridge_domain_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/bridge_domain_vppcalls_test.go deleted file mode 100644 index 5ab2b79416..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/bridge_domain_vppcalls_test.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -const ( - dummyBridgeDomain = 4 - dummyBridgeDomainName = "bridge_domain" -) - -// Input test data for creating bridge domain -var createTestDataInBD = &l2.BridgeDomain{ - Name: dummyBridgeDomainName, - Flood: true, - UnknownUnicastFlood: true, - Forward: true, - Learn: true, - ArpTermination: true, - MacAge: 45, -} - -// Output test data for creating bridge domain -var createTestDataOutBD = &vpp_l2.BridgeDomainAddDel{ - BdID: dummyBridgeDomain, - Flood: 1, - UuFlood: 1, - Forward: 1, - Learn: 1, - ArpTerm: 1, - MacAge: 45, - BdTag: []byte(dummyBridgeDomainName), - IsAdd: 1, -} - -// Output test data for deleting bridge domain -var deleteTestDataOutBd = &vpp_l2.BridgeDomainAddDel{ - BdID: dummyBridgeDomain, - IsAdd: 0, -} - -func TestVppAddBridgeDomain(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - err := bdHandler.AddBridgeDomain(dummyBridgeDomain, createTestDataInBD) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(createTestDataOutBD)) -} - -func TestVppAddBridgeDomainError(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{Retval: 1}) - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2Bridge{}) - - err := bdHandler.AddBridgeDomain(dummyBridgeDomain, createTestDataInBD) - Expect(err).Should(HaveOccurred()) - - err = bdHandler.AddBridgeDomain(dummyBridgeDomain, createTestDataInBD) - Expect(err).Should(HaveOccurred()) -} - -func TestVppDeleteBridgeDomain(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - err := bdHandler.DeleteBridgeDomain(dummyBridgeDomain) - - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(deleteTestDataOutBd)) -} - -func TestVppDeleteBridgeDomainError(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{Retval: 1}) - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2Bridge{}) - - err := bdHandler.DeleteBridgeDomain(dummyBridgeDomain) - Expect(err).Should(HaveOccurred()) - - err = bdHandler.DeleteBridgeDomain(dummyBridgeDomain) - Expect(err).Should(HaveOccurred()) -} - -func bdTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.BridgeDomainVppAPI, ifaceidx.IfaceMetadataIndexRW) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - ifIndex := ifaceidx.NewIfaceIndex(log, "bd-test-ifidx") - bdHandler := vpp2001.NewL2VppHandler(ctx.MockChannel, ifIndex, nil, log) - return ctx, bdHandler, ifIndex -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/doc.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/doc.go deleted file mode 100644 index f2dada3211..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package vppcalls contains wrappers over VPP binary APIs for bridge-domains, -// and L2 FIBs and XConnect pairs and helpers for dumping them. -package vpp2001 diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/dump_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/dump_vppcalls.go deleted file mode 100644 index a56095df7a..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/dump_vppcalls.go +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "bytes" - "net" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -// DumpBridgeDomains implements bridge domain handler. -func (h *BridgeDomainVppHandler) DumpBridgeDomains() ([]*vppcalls.BridgeDomainDetails, error) { - // At first prepare bridge domain ARP termination table which needs to be dumped separately. - bdArpTab, err := h.dumpBridgeDomainMacTable() - if err != nil { - return nil, errors.Errorf("failed to dump arp termination table: %v", err) - } - - // list of resulting BDs - var bds []*vppcalls.BridgeDomainDetails - - // dump bridge domains - reqCtx := h.callsChannel.SendMultiRequest(&vpp_l2.BridgeDomainDump{BdID: ^uint32(0)}) - - for { - bdDetails := &vpp_l2.BridgeDomainDetails{} - stop, err := reqCtx.ReceiveReply(bdDetails) - if stop { - break - } - if err != nil { - return nil, err - } - - // bridge domain metadata - bdData := &vppcalls.BridgeDomainDetails{ - Bd: &l2.BridgeDomain{ - Name: string(bytes.Replace(bdDetails.BdTag, []byte{0x00}, []byte{}, -1)), - Flood: bdDetails.Flood > 0, - UnknownUnicastFlood: bdDetails.UuFlood > 0, - Forward: bdDetails.Forward > 0, - Learn: bdDetails.Learn > 0, - ArpTermination: bdDetails.ArpTerm > 0, - MacAge: uint32(bdDetails.MacAge), - }, - Meta: &vppcalls.BridgeDomainMeta{ - BdID: bdDetails.BdID, - }, - } - - // bridge domain interfaces - for _, iface := range bdDetails.SwIfDetails { - ifaceName, _, exists := h.ifIndexes.LookupBySwIfIndex(iface.SwIfIndex) - if !exists { - h.log.Warnf("Bridge domain dump: interface name for index %d not found", iface.SwIfIndex) - continue - } - // Bvi - var bvi bool - if iface.SwIfIndex == bdDetails.BviSwIfIndex { - bvi = true - } - // add interface entry - bdData.Bd.Interfaces = append(bdData.Bd.Interfaces, &l2.BridgeDomain_Interface{ - Name: ifaceName, - BridgedVirtualInterface: bvi, - SplitHorizonGroup: uint32(iface.Shg), - }) - } - - // Add ARP termination entries. - arpTable, ok := bdArpTab[bdDetails.BdID] - if ok { - bdData.Bd.ArpTerminationTable = arpTable - } - - bds = append(bds, bdData) - } - - return bds, nil -} - -// Reads ARP termination table from all bridge domains. Result is then added to bridge domains. -func (h *BridgeDomainVppHandler) dumpBridgeDomainMacTable() (map[uint32][]*l2.BridgeDomain_ArpTerminationEntry, error) { - bdArpTable := make(map[uint32][]*l2.BridgeDomain_ArpTerminationEntry) - req := &vpp_l2.BdIPMacDump{BdID: ^uint32(0)} - - reqCtx := h.callsChannel.SendMultiRequest(req) - for { - msg := &vpp_l2.BdIPMacDetails{} - stop, err := reqCtx.ReceiveReply(msg) - if err != nil { - return nil, err - } - if stop { - break - } - - // Prepare ARP entry - arpEntry := &l2.BridgeDomain_ArpTerminationEntry{} - arpEntry.IpAddress = parseAddressToString(msg.Entry.IP) - arpEntry.PhysAddress = net.HardwareAddr(msg.Entry.Mac[:]).String() - - // Add ARP entry to result map - bdArpTable[msg.Entry.BdID] = append(bdArpTable[msg.Entry.BdID], arpEntry) - } - - return bdArpTable, nil -} - -// DumpL2FIBs dumps VPP L2 FIB table entries into the northbound API -// data structure map indexed by destination MAC address. -func (h *FIBVppHandler) DumpL2FIBs() (map[string]*vppcalls.FibTableDetails, error) { - // map for the resulting FIBs - fibs := make(map[string]*vppcalls.FibTableDetails) - - reqCtx := h.callsChannel.SendMultiRequest(&vpp_l2.L2FibTableDump{BdID: ^uint32(0)}) - for { - fibDetails := &vpp_l2.L2FibTableDetails{} - stop, err := reqCtx.ReceiveReply(fibDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return nil, err - } - - mac := net.HardwareAddr(fibDetails.Mac).String() - var action l2.FIBEntry_Action - if fibDetails.FilterMac > 0 { - action = l2.FIBEntry_DROP - } else { - action = l2.FIBEntry_FORWARD - } - - // Interface name (only for FORWARD entries) - var ifName string - if action == l2.FIBEntry_FORWARD { - var exists bool - ifName, _, exists = h.ifIndexes.LookupBySwIfIndex(fibDetails.SwIfIndex) - if !exists { - h.log.Warnf("FIB dump: interface name for index %d not found", fibDetails.SwIfIndex) - continue - } - } - // Bridge domain name - bdName, _, exists := h.bdIndexes.LookupByIndex(fibDetails.BdID) - if !exists { - h.log.Warnf("FIB dump: bridge domain name for index %d not found", fibDetails.BdID) - continue - } - - fibs[mac] = &vppcalls.FibTableDetails{ - Fib: &l2.FIBEntry{ - PhysAddress: mac, - BridgeDomain: bdName, - Action: action, - OutgoingInterface: ifName, - StaticConfig: fibDetails.StaticMac > 0, - BridgedVirtualInterface: fibDetails.BviMac > 0, - }, - Meta: &vppcalls.FibMeta{ - BdID: fibDetails.BdID, - IfIdx: fibDetails.SwIfIndex, - }, - } - } - - return fibs, nil -} - -// DumpXConnectPairs implements xconnect handler. -func (h *XConnectVppHandler) DumpXConnectPairs() (map[uint32]*vppcalls.XConnectDetails, error) { - // map for the resulting xconnect pairs - xpairs := make(map[uint32]*vppcalls.XConnectDetails) - - reqCtx := h.callsChannel.SendMultiRequest(&vpp_l2.L2XconnectDump{}) - for { - pairs := &vpp_l2.L2XconnectDetails{} - stop, err := reqCtx.ReceiveReply(pairs) - if stop { - break - } - if err != nil { - return nil, err - } - - // Find interface names - rxIfaceName, _, exists := h.ifIndexes.LookupBySwIfIndex(pairs.RxSwIfIndex) - if !exists { - h.log.Warnf("XConnect dump: rx interface name for index %d not found", pairs.RxSwIfIndex) - continue - } - txIfaceName, _, exists := h.ifIndexes.LookupBySwIfIndex(pairs.TxSwIfIndex) - if !exists { - h.log.Warnf("XConnect dump: tx interface name for index %d not found", pairs.TxSwIfIndex) - continue - } - - xpairs[pairs.RxSwIfIndex] = &vppcalls.XConnectDetails{ - Xc: &l2.XConnectPair{ - ReceiveInterface: rxIfaceName, - TransmitInterface: txIfaceName, - }, - Meta: &vppcalls.XcMeta{ - ReceiveInterfaceSwIfIdx: pairs.RxSwIfIndex, - TransmitInterfaceSwIfIdx: pairs.TxSwIfIndex, - }, - } - } - - return xpairs, nil -} - -func parseAddressToString(address vpp_l2.Address) string { - var nhIP net.IP = make([]byte, 16) - copy(nhIP[:], address.Un.XXX_UnionData[:]) - if address.Af == ip_types.ADDRESS_IP4 { - return nhIP[:4].To4().String() - } - if address.Af == ip_types.ADDRESS_IP6 { - return nhIP.To16().String() - } - - return "" -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/dump_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/dump_vppcalls_test.go deleted file mode 100644 index d7d8e41120..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/dump_vppcalls_test.go +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - govppapi "git.fd.io/govpp.git/api" - . "github.com/onsi/gomega" - - "go.ligato.io/vpp-agent/v3/pkg/idxvpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -var testDataInMessagesBDs = []govppapi.Message{ - &vpp_l2.BridgeDomainDetails{ - BdID: 4, - Flood: 1, UuFlood: 1, Forward: 1, Learn: 1, ArpTerm: 1, MacAge: 140, - SwIfDetails: []vpp_l2.BridgeDomainSwIf{ - {SwIfIndex: 5}, - {SwIfIndex: 7}, - }, - }, - &vpp_l2.BridgeDomainDetails{ - BdID: 5, - Flood: 0, UuFlood: 0, Forward: 0, Learn: 0, ArpTerm: 0, MacAge: 141, - SwIfDetails: []vpp_l2.BridgeDomainSwIf{ - {SwIfIndex: 5}, - {SwIfIndex: 8}, - }, - }, -} - -var testDataOutMessage = []*vppcalls.BridgeDomainDetails{ - { - Bd: &l2.BridgeDomain{ - Flood: true, - UnknownUnicastFlood: true, - Forward: true, - Learn: true, - ArpTermination: true, - MacAge: 140, - Interfaces: []*l2.BridgeDomain_Interface{ - { - Name: "if1", - }, - { - Name: "if2", - }, - }, - }, - Meta: &vppcalls.BridgeDomainMeta{ - BdID: 4, - }, - }, { - Bd: &l2.BridgeDomain{ - Flood: false, - UnknownUnicastFlood: false, - Forward: false, - Learn: false, - ArpTermination: false, - MacAge: 141, - Interfaces: []*l2.BridgeDomain_Interface{ - { - Name: "if1", - }, - { - Name: "if3", - }, - }, - ArpTerminationTable: []*l2.BridgeDomain_ArpTerminationEntry{ - { - IpAddress: "192.168.0.1", - PhysAddress: "aa:aa:aa:aa:aa:aa", - }, - }, - }, - Meta: &vppcalls.BridgeDomainMeta{ - BdID: 5, - }, - }, -} - -// TestDumpBridgeDomains tests DumpBridgeDomains method -func TestDumpBridgeDomains(t *testing.T) { - ctx, bdHandler, ifIndexes := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 5}) - ifIndexes.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 7}) - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_l2.BdIPMacDump{}).GetMessageName(), - Ping: true, - Message: &vpp_l2.BdIPMacDetails{}, - }, - { - Name: (&vpp_l2.BridgeDomainDump{}).GetMessageName(), - Ping: true, - Message: testDataInMessagesBDs[0], - }, - }) - - bridgeDomains, err := bdHandler.DumpBridgeDomains() - - Expect(err).To(BeNil()) - Expect(bridgeDomains).To(HaveLen(1)) - Expect(bridgeDomains[0]).To(Equal(testDataOutMessage[0])) - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - _, err = bdHandler.DumpBridgeDomains() - Expect(err).Should(HaveOccurred()) -} - -// TestDumpBridgeDomains tests DumpBridgeDomains method -func TestDumpBridgeDomainsWithARP(t *testing.T) { - ctx, bdHandler, ifIndexes := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 5}) - ifIndexes.Put("if3", &ifaceidx.IfaceMetadata{SwIfIndex: 8}) - - ctx.MockReplies([]*vppmock.HandleReplies{ - { - Name: (&vpp_l2.BdIPMacDump{}).GetMessageName(), - Ping: true, - Message: &vpp_l2.BdIPMacDetails{ - Entry: vpp_l2.BdIPMac{ - BdID: 5, - IP: vpp_l2.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4( - vpp_l2.IP4Address{192, 168, 0, 1}, - ), - }, - Mac: vpp_l2.MacAddress{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}, - }, - }, - }, - { - Name: (&vpp_l2.BridgeDomainDump{}).GetMessageName(), - Ping: true, - Message: testDataInMessagesBDs[1], - }, - }) - - bridgeDomains, err := bdHandler.DumpBridgeDomains() - - Expect(err).To(BeNil()) - Expect(bridgeDomains).To(HaveLen(1)) - Expect(bridgeDomains[0]).To(Equal(testDataOutMessage[1])) - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - _, err = bdHandler.DumpBridgeDomains() - Expect(err).Should(HaveOccurred()) -} - -var testDataInMessagesFIBs = []govppapi.Message{ - &vpp_l2.L2FibTableDetails{ - BdID: 10, - Mac: []byte{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}, - BviMac: 0, SwIfIndex: ^uint32(0), FilterMac: 1, StaticMac: 0, - }, - &vpp_l2.L2FibTableDetails{ - BdID: 20, - Mac: []byte{0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB}, - BviMac: 1, SwIfIndex: 1, FilterMac: 0, StaticMac: 1, - }, -} - -var testDataOutFIBs = []*vppcalls.FibTableDetails{ - { - Fib: &l2.FIBEntry{ - PhysAddress: "aa:aa:aa:aa:aa:aa", - BridgeDomain: "bd1", - Action: l2.FIBEntry_DROP, - StaticConfig: false, - BridgedVirtualInterface: false, - OutgoingInterface: "", - }, - Meta: &vppcalls.FibMeta{ - BdID: 10, - IfIdx: ^uint32(0), - }, - }, - { - Fib: &l2.FIBEntry{ - PhysAddress: "bb:bb:bb:bb:bb:bb", - BridgeDomain: "bd2", - Action: l2.FIBEntry_FORWARD, - StaticConfig: true, - BridgedVirtualInterface: true, - OutgoingInterface: "if1", - }, - Meta: &vppcalls.FibMeta{ - BdID: 20, - IfIdx: 1, - }, - }, -} - -// Scenario: -// - 2 FIB entries in VPP -// TestDumpFIBTableEntries tests DumpFIBTableEntries method -func TestDumpFIBTableEntries(t *testing.T) { - ctx, fibHandler, ifIndexes, bdIndexes := fibTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - bdIndexes.Put("bd1", &idxvpp.OnlyIndex{Index: 10}) - bdIndexes.Put("bd2", &idxvpp.OnlyIndex{Index: 20}) - - ctx.MockVpp.MockReply(testDataInMessagesFIBs...) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - fibTable, err := fibHandler.DumpL2FIBs() - Expect(err).To(BeNil()) - Expect(fibTable).To(HaveLen(2)) - Expect(fibTable["aa:aa:aa:aa:aa:aa"]).To(Equal(testDataOutFIBs[0])) - Expect(fibTable["bb:bb:bb:bb:bb:bb"]).To(Equal(testDataOutFIBs[1])) - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - _, err = fibHandler.DumpL2FIBs() - Expect(err).Should(HaveOccurred()) -} - -var testDataInXConnect = []govppapi.Message{ - &vpp_l2.L2XconnectDetails{ - RxSwIfIndex: 1, - TxSwIfIndex: 2, - }, - &vpp_l2.L2XconnectDetails{ - RxSwIfIndex: 3, - TxSwIfIndex: 4, - }, -} - -var testDataOutXconnect = []*vppcalls.XConnectDetails{ - { - Xc: &l2.XConnectPair{ - ReceiveInterface: "if1", - TransmitInterface: "if2", - }, - Meta: &vppcalls.XcMeta{ - ReceiveInterfaceSwIfIdx: 1, - TransmitInterfaceSwIfIdx: 2, - }, - }, - { - Xc: &l2.XConnectPair{ - ReceiveInterface: "if3", - TransmitInterface: "if4", - }, - Meta: &vppcalls.XcMeta{ - ReceiveInterfaceSwIfIdx: 3, - TransmitInterfaceSwIfIdx: 4, - }, - }, -} - -// Scenario: -// - 2 Xconnect entries in VPP -// TestDumpXConnectPairs tests DumpXConnectPairs method -func TestDumpXConnectPairs(t *testing.T) { - ctx, xcHandler, ifIndex := xcTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndex.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - ifIndex.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - ifIndex.Put("if3", &ifaceidx.IfaceMetadata{SwIfIndex: 3}) - ifIndex.Put("if4", &ifaceidx.IfaceMetadata{SwIfIndex: 4}) - - ctx.MockVpp.MockReply(testDataInXConnect...) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - xConnectPairs, err := xcHandler.DumpXConnectPairs() - - Expect(err).To(BeNil()) - Expect(xConnectPairs).To(HaveLen(2)) - Expect(xConnectPairs[1]).To(Equal(testDataOutXconnect[0])) - Expect(xConnectPairs[3]).To(Equal(testDataOutXconnect[1])) - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - _, err = xcHandler.DumpXConnectPairs() - Expect(err).Should(HaveOccurred()) -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/interface_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/interface_vppcalls.go deleted file mode 100644 index 6cd7b83867..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/interface_vppcalls.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - - "github.com/pkg/errors" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -// AddInterfaceToBridgeDomain puts interface into bridge domain. -func (h *BridgeDomainVppHandler) AddInterfaceToBridgeDomain(bdIdx uint32, ifaceCfg *l2.BridgeDomain_Interface) error { - ifaceMeta, found := h.ifIndexes.LookupByName(ifaceCfg.Name) - if !found { - return errors.New("failed to get interface metadata") - } - if err := h.addDelInterfaceToBridgeDomain(bdIdx, ifaceCfg, ifaceMeta.GetIndex(), true); err != nil { - return err - } - return nil -} - -// DeleteInterfaceFromBridgeDomain removes interface from bridge domain. -func (h *BridgeDomainVppHandler) DeleteInterfaceFromBridgeDomain(bdIdx uint32, ifaceCfg *l2.BridgeDomain_Interface) error { - ifaceMeta, found := h.ifIndexes.LookupByName(ifaceCfg.Name) - if !found { - return errors.New("failed to get interface metadata") - } - if err := h.addDelInterfaceToBridgeDomain(bdIdx, ifaceCfg, ifaceMeta.GetIndex(), false); err != nil { - return err - } - return nil -} - -func (h *BridgeDomainVppHandler) addDelInterfaceToBridgeDomain(bdIdx uint32, ifaceCfg *l2.BridgeDomain_Interface, - ifIdx uint32, add bool) error { - req := &vpp_l2.SwInterfaceSetL2Bridge{ - BdID: bdIdx, - RxSwIfIndex: ifIdx, - Shg: uint8(ifaceCfg.SplitHorizonGroup), - Enable: boolToUint(add), - } - // Set as BVI. - if ifaceCfg.BridgedVirtualInterface { - req.PortType = vpp_l2.L2_API_PORT_TYPE_BVI - } - reply := &vpp_l2.SwInterfaceSetL2BridgeReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return fmt.Errorf("%s returned error: %v", reply.GetMessageName(), err) - } - - return nil -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/interface_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/interface_vppcalls_test.go deleted file mode 100644 index 20e27abb1b..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/interface_vppcalls_test.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -func TestAddInterfaceToBridgeDomain(t *testing.T) { - ctx, bdHandler, ifaceIdx := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2BridgeReply{}) - err := bdHandler.AddInterfaceToBridgeDomain(1, &l2.BridgeDomain_Interface{ - Name: "if1", - BridgedVirtualInterface: true, - SplitHorizonGroup: 0, - }) - - Expect(err).To(BeNil()) - Expect(ctx.MockChannel.Msgs).To(HaveLen(1)) - msg := ctx.MockChannel.Msgs[0] - Expect(msg).To(BeEquivalentTo(&vpp_l2.SwInterfaceSetL2Bridge{ - RxSwIfIndex: uint32(1), - BdID: 1, - Shg: uint8(0), - PortType: vpp_l2.L2_API_PORT_TYPE_BVI, - Enable: 1, - })) -} - -func TestAddMissingInterfaceToBridgeDomain(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - // missing: ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2BridgeReply{}) - err := bdHandler.AddInterfaceToBridgeDomain(1, &l2.BridgeDomain_Interface{ - Name: "if1", - BridgedVirtualInterface: true, - SplitHorizonGroup: 0, - }) - - Expect(err).ToNot(BeNil()) - Expect(ctx.MockChannel.Msgs).To(BeEmpty()) -} - -func TestAddInterfaceToBridgeDomainWithError(t *testing.T) { - ctx, bdHandler, ifaceIdx := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2Bridge{}) // wrong reply message type - err := bdHandler.AddInterfaceToBridgeDomain(1, &l2.BridgeDomain_Interface{ - Name: "if1", - BridgedVirtualInterface: true, - SplitHorizonGroup: 0, - }) - - Expect(err).ToNot(BeNil()) - Expect(ctx.MockChannel.Msgs).To(HaveLen(1)) -} - -func TestAddInterfaceToBridgeDomainWithNonZeroRetval(t *testing.T) { - ctx, bdHandler, ifaceIdx := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2BridgeReply{ - Retval: 1, - }) - err := bdHandler.AddInterfaceToBridgeDomain(1, &l2.BridgeDomain_Interface{ - Name: "if1", - BridgedVirtualInterface: true, - SplitHorizonGroup: 0, - }) - - Expect(err).ToNot(BeNil()) - Expect(ctx.MockChannel.Msgs).To(HaveLen(1)) -} - -func TestDeleteInterfaceFromBridgeDomain(t *testing.T) { - ctx, bdHandler, ifaceIdx := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 10}) - - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2BridgeReply{}) - err := bdHandler.DeleteInterfaceFromBridgeDomain(4, &l2.BridgeDomain_Interface{ - Name: "if1", - SplitHorizonGroup: 12, - }) - - Expect(err).To(BeNil()) - Expect(ctx.MockChannel.Msgs).To(HaveLen(1)) - msg := ctx.MockChannel.Msgs[0] - Expect(msg).To(BeEquivalentTo(&vpp_l2.SwInterfaceSetL2Bridge{ - RxSwIfIndex: uint32(10), - BdID: 4, - Shg: uint8(12), - PortType: vpp_l2.L2_API_PORT_TYPE_NORMAL, - Enable: 0, - })) -} - -func TestDeleteMissingInterfaceFromBridgeDomain(t *testing.T) { - ctx, bdHandler, _ := bdTestSetup(t) - defer ctx.TeardownTestCtx() - - // missing: ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 10}) - - ctx.MockVpp.MockReply(&vpp_l2.SwInterfaceSetL2BridgeReply{}) - err := bdHandler.DeleteInterfaceFromBridgeDomain(4, &l2.BridgeDomain_Interface{ - Name: "if1", - SplitHorizonGroup: 12, - }) - - Expect(err).ToNot(BeNil()) - Expect(ctx.MockChannel.Msgs).To(BeEmpty()) -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/l2fib_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/l2fib_vppcalls.go deleted file mode 100644 index 0983dcc110..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/l2fib_vppcalls.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "errors" - "net" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -// AddL2FIB creates L2 FIB table entry. -func (h *FIBVppHandler) AddL2FIB(fib *l2.FIBEntry) error { - return h.l2fibAddDel(fib, true) -} - -// DeleteL2FIB removes existing L2 FIB table entry. -func (h *FIBVppHandler) DeleteL2FIB(fib *l2.FIBEntry) error { - return h.l2fibAddDel(fib, false) -} - -func (h *FIBVppHandler) l2fibAddDel(fib *l2.FIBEntry, isAdd bool) (err error) { - // get bridge domain metadata - bdMeta, found := h.bdIndexes.LookupByName(fib.BridgeDomain) - if !found { - return errors.New("failed to get bridge domain metadata") - } - - // get outgoing interface index - swIfIndex := ^uint32(0) // ~0 is used by DROP entries - if fib.Action == l2.FIBEntry_FORWARD { - ifaceMeta, found := h.ifIndexes.LookupByName(fib.OutgoingInterface) - if !found { - return errors.New("failed to get interface metadata") - } - swIfIndex = ifaceMeta.GetIndex() - } - - // parse MAC address - var mac []byte - if fib.PhysAddress != "" { - mac, err = net.ParseMAC(fib.PhysAddress) - if err != nil { - return err - } - } - - // add L2 FIB - req := &vpp_l2.L2fibAddDel{ - IsAdd: boolToUint(isAdd), - Mac: mac, - BdID: bdMeta.GetIndex(), - SwIfIndex: swIfIndex, - BviMac: boolToUint(fib.BridgedVirtualInterface), - StaticMac: boolToUint(fib.StaticConfig), - FilterMac: boolToUint(fib.Action == l2.FIBEntry_DROP), - } - reply := &vpp_l2.L2fibAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/l2fib_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/l2fib_vppcalls_test.go deleted file mode 100644 index b98ff2e075..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/l2fib_vppcalls_test.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - "go.ligato.io/cn-infra/v2/logging/logrus" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls/vpp2001" - - . "github.com/onsi/gomega" - - "go.ligato.io/vpp-agent/v3/pkg/idxvpp" - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2" -) - -var testDataInFib = []*l2.FIBEntry{ - {PhysAddress: "FF:FF:FF:FF:FF:FF", BridgeDomain: "bd1", OutgoingInterface: "if1", Action: l2.FIBEntry_FORWARD, StaticConfig: true, BridgedVirtualInterface: true}, - {PhysAddress: "AA:AA:AA:AA:AA:AA", BridgeDomain: "bd1", OutgoingInterface: "if1", Action: l2.FIBEntry_FORWARD, StaticConfig: true}, - {PhysAddress: "BB:BB:BB:BB:BB:BB", BridgeDomain: "bd1", Action: l2.FIBEntry_DROP}, - {PhysAddress: "CC:CC:CC:CC:CC:CC", BridgeDomain: "bd1", OutgoingInterface: "if1", Action: l2.FIBEntry_FORWARD}, -} - -var testDatasOutFib = []*vpp_l2.L2fibAddDel{ - {BdID: 5, SwIfIndex: 55, BviMac: 1, Mac: []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, StaticMac: 1, FilterMac: 0}, - {BdID: 5, SwIfIndex: 55, BviMac: 0, Mac: []byte{0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}, StaticMac: 1, FilterMac: 0}, - {BdID: 5, SwIfIndex: ^uint32(0), BviMac: 0, Mac: []byte{0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB}, StaticMac: 0, FilterMac: 1}, - {BdID: 5, SwIfIndex: 55, BviMac: 0, Mac: []byte{0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC}, StaticMac: 0, FilterMac: 0}, -} - -func TestL2FibAdd(t *testing.T) { - ctx, fibHandler, ifaceIdx, bdIndexes := fibTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 55}) - bdIndexes.Put("bd1", &idxvpp.OnlyIndex{Index: 5}) - - for i := 0; i < len(testDataInFib); i++ { - ctx.MockVpp.MockReply(&vpp_l2.L2fibAddDelReply{}) - err := fibHandler.AddL2FIB(testDataInFib[i]) - Expect(err).ShouldNot(HaveOccurred()) - testDatasOutFib[i].IsAdd = 1 - Expect(ctx.MockChannel.Msg).To(Equal(testDatasOutFib[i])) - } -} - -func TestL2FibAddError(t *testing.T) { - ctx, fibHandler, ifaceIdx, bdIndexes := fibTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 55}) - bdIndexes.Put("bd1", &idxvpp.OnlyIndex{Index: 5}) - - err := fibHandler.AddL2FIB(&l2.FIBEntry{PhysAddress: "not:mac:addr", BridgeDomain: "bd1", OutgoingInterface: "if1"}) - Expect(err).Should(HaveOccurred()) - - ctx.MockVpp.MockReply(&vpp_l2.L2fibAddDelReply{Retval: 1}) - err = fibHandler.AddL2FIB(testDataInFib[0]) - Expect(err).Should(HaveOccurred()) - - ctx.MockVpp.MockReply(&vpp_l2.BridgeDomainAddDelReply{}) - err = fibHandler.AddL2FIB(testDataInFib[0]) - Expect(err).Should(HaveOccurred()) - - err = fibHandler.AddL2FIB(&l2.FIBEntry{PhysAddress: "CC:CC:CC:CC:CC:CC", BridgeDomain: "non-existing-bd", OutgoingInterface: "if1"}) - Expect(err).Should(HaveOccurred()) - - err = fibHandler.AddL2FIB(&l2.FIBEntry{PhysAddress: "CC:CC:CC:CC:CC:CC", BridgeDomain: "bd1", OutgoingInterface: "non-existing-iface"}) - Expect(err).Should(HaveOccurred()) -} - -func TestL2FibDelete(t *testing.T) { - ctx, fibHandler, ifaceIdx, bdIndexes := fibTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 55}) - bdIndexes.Put("bd1", &idxvpp.OnlyIndex{Index: 5}) - - for i := 0; i < len(testDataInFib); i++ { - ctx.MockVpp.MockReply(&vpp_l2.L2fibAddDelReply{}) - err := fibHandler.DeleteL2FIB(testDataInFib[i]) - Expect(err).ShouldNot(HaveOccurred()) - testDatasOutFib[i].IsAdd = 0 - Expect(ctx.MockChannel.Msg).To(Equal(testDatasOutFib[i])) - } -} - -func fibTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.FIBVppAPI, ifaceidx.IfaceMetadataIndexRW, idxvpp.NameToIndexRW) { - ctx := vppmock.SetupTestCtx(t) - logger := logrus.NewLogger("test-log") - ifaceIdx := ifaceidx.NewIfaceIndex(logger, "fib-if-idx") - bdIndexes := idxvpp.NewNameToIndex(logger, "fib-bd-idx", nil) - fibHandler := vpp2001.NewL2VppHandler(ctx.MockChannel, ifaceIdx, bdIndexes, logger) - return ctx, fibHandler, ifaceIdx, bdIndexes -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/vppcalls_handler.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 160371ff83..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/pkg/idxvpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - l2ba "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls" -) - -func init() { - vppcalls.AddHandlerVersion(vpp2001.Version, l2ba.AllMessages(), NewL2VppHandler) -} - -type L2VppHandler struct { - *BridgeDomainVppHandler - *FIBVppHandler - *XConnectVppHandler -} - -func NewL2VppHandler(ch govppapi.Channel, - ifIdx ifaceidx.IfaceMetadataIndex, bdIdx idxvpp.NameToIndex, log logging.Logger, -) vppcalls.L2VppAPI { - return &L2VppHandler{ - BridgeDomainVppHandler: newBridgeDomainVppHandler(ch, ifIdx, log), - FIBVppHandler: newFIBVppHandler(ch, ifIdx, bdIdx, log), - XConnectVppHandler: newXConnectVppHandler(ch, ifIdx, log), - } -} - -// BridgeDomainVppHandler is accessor for bridge domain-related vppcalls methods. -type BridgeDomainVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// FIBVppHandler is accessor for FIB-related vppcalls methods. -type FIBVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - bdIndexes idxvpp.NameToIndex - log logging.Logger -} - -// XConnectVppHandler is accessor for cross-connect-related vppcalls methods. -type XConnectVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// NewBridgeDomainVppHandler creates new instance of bridge domain vppcalls handler. -func newBridgeDomainVppHandler(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) *BridgeDomainVppHandler { - return &BridgeDomainVppHandler{ - callsChannel: ch, - ifIndexes: ifIdx, - log: log, - } -} - -// NewFIBVppHandler creates new instance of FIB vppcalls handler. -func newFIBVppHandler(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, bdIndexes idxvpp.NameToIndex, log logging.Logger) *FIBVppHandler { - return &FIBVppHandler{ - callsChannel: ch, - ifIndexes: ifIdx, - bdIndexes: bdIndexes, - log: log, - } -} - -// NewXConnectVppHandler creates new instance of cross connect vppcalls handler. -func newXConnectVppHandler(ch govppapi.Channel, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) *XConnectVppHandler { - return &XConnectVppHandler{ - callsChannel: ch, - ifIndexes: ifIdx, - log: log, - } -} - -func ipToAddress(ipstr string) (addr l2ba.Address, err error) { - netIP := net.ParseIP(ipstr) - if netIP == nil { - return l2ba.Address{}, fmt.Errorf("invalid IP: %q", ipstr) - } - if ip4 := netIP.To4(); ip4 == nil { - addr.Af = ip_types.ADDRESS_IP6 - var ip6addr l2ba.IP6Address - copy(ip6addr[:], netIP.To16()) - addr.Un.SetIP6(ip6addr) - } else { - addr.Af = ip_types.ADDRESS_IP4 - var ip4addr l2ba.IP4Address - copy(ip4addr[:], ip4) - addr.Un.SetIP4(ip4addr) - } - return -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/xconnect_vppcalls.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/xconnect_vppcalls.go deleted file mode 100644 index 6cfc519f97..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/xconnect_vppcalls.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "errors" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" -) - -// AddL2XConnect creates xConnect between two existing interfaces. -func (h *XConnectVppHandler) AddL2XConnect(rxIface, txIface string) error { - return h.addDelXConnect(rxIface, txIface, true) -} - -// DeleteL2XConnect removes xConnect between two interfaces. -func (h *XConnectVppHandler) DeleteL2XConnect(rxIface, txIface string) error { - return h.addDelXConnect(rxIface, txIface, false) -} - -func (h *XConnectVppHandler) addDelXConnect(rxIface, txIface string, enable bool) error { - // get Rx interface metadata - rxIfaceMeta, found := h.ifIndexes.LookupByName(rxIface) - if !found { - return errors.New("failed to get Rx interface metadata") - } - - // get Tx interface metadata - txIfaceMeta, found := h.ifIndexes.LookupByName(txIface) - if !found { - return errors.New("failed to get Tx interface metadata") - } - - // add/del xConnect pair - req := &vpp_l2.SwInterfaceSetL2Xconnect{ - Enable: boolToUint(enable), - TxSwIfIndex: txIfaceMeta.GetIndex(), - RxSwIfIndex: rxIfaceMeta.GetIndex(), - } - reply := &vpp_l2.SwInterfaceSetL2XconnectReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} diff --git a/plugins/vpp/l2plugin/vppcalls/vpp2001/xconnect_vppcalls_test.go b/plugins/vpp/l2plugin/vppcalls/vpp2001/xconnect_vppcalls_test.go deleted file mode 100644 index e1398b9268..0000000000 --- a/plugins/vpp/l2plugin/vppcalls/vpp2001/xconnect_vppcalls_test.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - govppapi "git.fd.io/govpp.git/api" - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l2" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l2plugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" -) - -var inTestDataXConnect = []struct { - receiveIfaceIndex string - transmitIfaceIndex string - message govppapi.Message -}{ - {"rxIf1", "txIf1", &vpp_l2.SwInterfaceSetL2XconnectReply{}}, - {"rxIf2", "txIf2", &vpp_l2.SwInterfaceSetL2XconnectReply{Retval: 1}}, - {"rxIf2", "txIf2", &vpp_l2.BridgeDomainAddDelReply{}}, -} - -var outTestDataXConnect = []struct { - outData *vpp_l2.SwInterfaceSetL2Xconnect - isResultOk bool -}{ - {&vpp_l2.SwInterfaceSetL2Xconnect{ - RxSwIfIndex: 100, - TxSwIfIndex: 200, - }, true}, - {&vpp_l2.SwInterfaceSetL2Xconnect{ - RxSwIfIndex: 101, - TxSwIfIndex: 201, - }, false}, - {&vpp_l2.SwInterfaceSetL2Xconnect{ - RxSwIfIndex: 101, - TxSwIfIndex: 201, - }, false}, -} - -/** -scenarios: -- enabling xconnect - - ok - - retvalue != 0 - - returned VPP message != what is expected -*/ -// TestVppSetL2XConnect tests VppSetL2XConnect method -func TestVppSetL2XConnect(t *testing.T) { - ctx, xcHandler, ifaceIdx := xcTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("rxIf1", &ifaceidx.IfaceMetadata{SwIfIndex: 100}) - ifaceIdx.Put("rxIf2", &ifaceidx.IfaceMetadata{SwIfIndex: 101}) - ifaceIdx.Put("txIf1", &ifaceidx.IfaceMetadata{SwIfIndex: 200}) - ifaceIdx.Put("txIf2", &ifaceidx.IfaceMetadata{SwIfIndex: 201}) - - for i := 0; i < len(inTestDataXConnect); i++ { - ctx.MockVpp.MockReply(inTestDataXConnect[i].message) - err := xcHandler.AddL2XConnect(inTestDataXConnect[i].receiveIfaceIndex, - inTestDataXConnect[i].transmitIfaceIndex) - - if outTestDataXConnect[i].isResultOk { - Expect(err).To(BeNil()) - } else { - Expect(err).NotTo(BeNil()) - } - outTestDataXConnect[i].outData.Enable = 1 - Expect(ctx.MockChannel.Msg).To(Equal(outTestDataXConnect[i].outData)) - } -} - -/** -scenarios: -- disabling xconnect - - ok - - retvalue != 0 - - returned VPP message != what is expected -*/ -// TestVppUnsetL2XConnect tests VppUnsetL2XConnect method -func TestVppUnsetL2XConnect(t *testing.T) { - ctx, xcHandler, ifaceIdx := xcTestSetup(t) - defer ctx.TeardownTestCtx() - - ifaceIdx.Put("rxIf1", &ifaceidx.IfaceMetadata{SwIfIndex: 100}) - ifaceIdx.Put("rxIf2", &ifaceidx.IfaceMetadata{SwIfIndex: 101}) - ifaceIdx.Put("txIf1", &ifaceidx.IfaceMetadata{SwIfIndex: 200}) - ifaceIdx.Put("txIf2", &ifaceidx.IfaceMetadata{SwIfIndex: 201}) - - for i := 0; i < len(inTestDataXConnect); i++ { - ctx.MockVpp.MockReply(inTestDataXConnect[i].message) - err := xcHandler.DeleteL2XConnect(inTestDataXConnect[i].receiveIfaceIndex, - inTestDataXConnect[i].transmitIfaceIndex) - - if outTestDataXConnect[i].isResultOk { - Expect(err).To(BeNil()) - } else { - Expect(err).NotTo(BeNil()) - } - outTestDataXConnect[i].outData.Enable = 0 - Expect(ctx.MockChannel.Msg).To(Equal(outTestDataXConnect[i].outData)) - } -} - -func xcTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.XConnectVppAPI, ifaceidx.IfaceMetadataIndexRW) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - ifaceIdx := ifaceidx.NewIfaceIndex(log, "xc-if-idx") - xcHandler := vpp2001.NewL2VppHandler(ctx.MockChannel, ifaceIdx, nil, log) - return ctx, xcHandler, ifaceIdx -} diff --git a/plugins/vpp/l3plugin/l3plugin.go b/plugins/vpp/l3plugin/l3plugin.go index 48eb6a8e6e..8e2afbaa7c 100644 --- a/plugins/vpp/l3plugin/l3plugin.go +++ b/plugins/vpp/l3plugin/l3plugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -39,7 +39,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vrfidx" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2101" diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_dump.go deleted file mode 100644 index 4a2eb6dd14..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_dump.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - vpp_ip_neighbor "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_neighbor" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -// DumpArpEntries implements arp handler. -func (h *ArpVppHandler) DumpArpEntries() ([]*vppcalls.ArpDetails, error) { - arpV4Entries, err := h.dumpArpEntries(false) - if err != nil { - return nil, err - } - arpV6Entries, err := h.dumpArpEntries(true) - if err != nil { - return nil, err - } - return append(arpV4Entries, arpV6Entries...), nil -} - -func (h *ArpVppHandler) dumpArpEntries(isIPv6 bool) ([]*vppcalls.ArpDetails, error) { - var entries []*vppcalls.ArpDetails - req := &vpp_ip_neighbor.IPNeighborDump{ - SwIfIndex: 0xffffffff, // Send multirequest to get all ARP entries for given IP version - } - if isIPv6 { - req.Af = ip_types.ADDRESS_IP6 - } - reqCtx := h.callsChannel.SendMultiRequest(req) - for { - arpDetails := &vpp_ip_neighbor.IPNeighborDetails{} - stop, err := reqCtx.ReceiveReply(arpDetails) - if stop { - break - } - if err != nil { - h.log.Error(err) - return nil, err - } - - // ARP interface - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(uint32(arpDetails.Neighbor.SwIfIndex)) - if !exists { - h.log.Warnf("ARP dump: interface name not found for index %d", arpDetails.Neighbor.SwIfIndex) - } - // IP & MAC address - var ip string - if arpDetails.Neighbor.IPAddress.Af == ip_types.ADDRESS_IP6 { - addr := arpDetails.Neighbor.IPAddress.Un.GetIP6() - ip = net.IP(addr[:]).To16().String() - } else { - addr := arpDetails.Neighbor.IPAddress.Un.GetIP4() - ip = net.IP(addr[:]).To4().String() - } - - // ARP entry - arp := &l3.ARPEntry{ - Interface: ifName, - IpAddress: ip, - PhysAddress: net.HardwareAddr(arpDetails.Neighbor.MacAddress[:]).String(), - Static: arpDetails.Neighbor.Flags&vpp_ip_neighbor.IP_API_NEIGHBOR_FLAG_STATIC != 0, - } - // ARP meta - meta := &vppcalls.ArpMeta{ - SwIfIndex: uint32(arpDetails.Neighbor.SwIfIndex), - } - - entries = append(entries, &vppcalls.ArpDetails{ - Arp: arp, - Meta: meta, - }) - } - - return entries, nil -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_vppcalls.go deleted file mode 100644 index 004fecc8d8..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_vppcalls.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ip_neighbor "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_neighbor" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -// vppAddDelArp adds or removes ARP entry according to provided input -func (h *ArpVppHandler) vppAddDelArp(entry *l3.ARPEntry, delete bool) error { - meta, found := h.ifIndexes.LookupByName(entry.Interface) - if !found { - return errors.Errorf("interface %s not found", entry.Interface) - } - - var flags vpp_ip_neighbor.IPNeighborFlags - flags |= vpp_ip_neighbor.IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY - if entry.Static { - flags |= vpp_ip_neighbor.IP_API_NEIGHBOR_FLAG_STATIC - } - - req := &vpp_ip_neighbor.IPNeighborAddDel{ - IsAdd: !delete, - Neighbor: vpp_ip_neighbor.IPNeighbor{ - SwIfIndex: interface_types.InterfaceIndex(meta.SwIfIndex), - Flags: flags, - }, - } - - var err error - req.Neighbor.IPAddress, err = ipToAddress(entry.IpAddress) - if err != nil { - return errors.WithStack(err) - } - - macAddr, err := net.ParseMAC(entry.PhysAddress) - if err != nil { - return err - } - copy(req.Neighbor.MacAddress[:], macAddr) - - reply := &vpp_ip_neighbor.IPNeighborAddDelReply{} - if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// VppAddArp implements arp handler. -func (h *ArpVppHandler) VppAddArp(entry *l3.ARPEntry) error { - return h.vppAddDelArp(entry, false) -} - -// VppDelArp implements arp handler. -func (h *ArpVppHandler) VppDelArp(entry *l3.ARPEntry) error { - return h.vppAddDelArp(entry, true) -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_vppcalls_test.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_vppcalls_test.go deleted file mode 100644 index 342e17ddd0..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/arp_vppcalls_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_ip_neighbor "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_neighbor" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -var arpEntries = []*l3.ARPEntry{ - { - Interface: "if1", - IpAddress: "192.168.10.21", - PhysAddress: "59:6C:45:59:8E:BD", - Static: true, - }, - { - Interface: "if1", - IpAddress: "192.168.10.22", - PhysAddress: "6C:45:59:59:8E:BD", - Static: false, - }, - { - Interface: "if1", - IpAddress: "dead::1", - PhysAddress: "8E:BD:6C:45:59:59", - Static: false, - }, -} - -// Test adding of ARP -func TestAddArp(t *testing.T) { - ctx, ifIndexes, arpHandler := arpTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_ip_neighbor.IPNeighborAddDelReply{}) - err := arpHandler.VppAddArp(arpEntries[0]) - Expect(err).To(Succeed()) - ctx.MockVpp.MockReply(&vpp_ip_neighbor.IPNeighborAddDelReply{}) - err = arpHandler.VppAddArp(arpEntries[1]) - Expect(err).To(Succeed()) - ctx.MockVpp.MockReply(&vpp_ip_neighbor.IPNeighborAddDelReply{}) - err = arpHandler.VppAddArp(arpEntries[2]) - Expect(err).To(Succeed()) - - ctx.MockVpp.MockReply(&vpp_ip_neighbor.IPNeighborAddDelReply{Retval: 1}) - err = arpHandler.VppAddArp(arpEntries[0]) - Expect(err).NotTo(BeNil()) -} - -// Test deleting of ARP -func TestDelArp(t *testing.T) { - ctx, ifIndexes, arpHandler := arpTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_ip_neighbor.IPNeighborAddDelReply{}) - err := arpHandler.VppDelArp(arpEntries[0]) - Expect(err).To(Succeed()) -} - -func arpTestSetup(t *testing.T) (*vppmock.TestCtx, ifaceidx.IfaceMetadataIndexRW, vppcalls.ArpVppAPI) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - ifIndexes := ifaceidx.NewIfaceIndex(logrus.NewLogger("test"), "test") - arpHandler := vpp2001.NewArpVppHandler(ctx.MockChannel, ifIndexes, log) - return ctx, ifIndexes, arpHandler -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/dhcpproxy_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/dhcpproxy_dump.go deleted file mode 100644 index ffb55e8e57..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/dhcpproxy_dump.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2019 PANTHEON.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -func (h *DHCPProxyHandler) DumpDHCPProxy() (entry []*vppcalls.DHCPProxyDetails, err error) { - ipv4Entries, err := h.dumpDHCPProxyForIPVersion(false) - if err != nil { - return nil, err - } - entry = append(entry, ipv4Entries...) - ipv6Entries, err := h.dumpDHCPProxyForIPVersion(true) - if err != nil { - return nil, err - } - - entry = append(entry, ipv6Entries...) - return entry, nil -} - -func (h *DHCPProxyHandler) dumpDHCPProxyForIPVersion(isIPv6 bool) (entry []*vppcalls.DHCPProxyDetails, err error) { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_dhcp.DHCPProxyDump{IsIP6: isIPv6}) - for { - dhcpProxyDetails := &vpp_dhcp.DHCPProxyDetails{} - stop, err := reqCtx.ReceiveReply(dhcpProxyDetails) - if stop { - break - } - if err != nil { - h.log.Error(err) - return nil, err - } - proxy := &l3.DHCPProxy{ - RxVrfId: dhcpProxyDetails.RxVrfID, - SourceIpAddress: addressToString(dhcpProxyDetails.DHCPSrcAddress), - } - - for _, server := range dhcpProxyDetails.Servers { - proxyServer := &l3.DHCPProxy_DHCPServer{ - IpAddress: addressToString(server.DHCPServer), - VrfId: server.ServerVrfID, - } - proxy.Servers = append(proxy.Servers, proxyServer) - } - - entry = append(entry, &vppcalls.DHCPProxyDetails{ - DHCPProxy: proxy, - }) - } - return -} - -func addressToString(address vpp_dhcp.Address) string { - if address.Af == ip_types.ADDRESS_IP6 { - ipAddr := address.Un.GetIP6() - return net.IP(ipAddr[:]).To16().String() - } - ipAddr := address.Un.GetIP4() - return net.IP(ipAddr[:]).To4().String() -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/dhcpproxy_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/dhcpproxy_vppcalls.go deleted file mode 100644 index e93658e58d..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/dhcpproxy_vppcalls.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2019 PANTHEON.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "github.com/pkg/errors" - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -func (h *DHCPProxyHandler) createDeleteDHCPProxy(entry *l3.DHCPProxy, delete bool) (err error) { - config := &vpp_dhcp.DHCPProxyConfig{ - RxVrfID: entry.RxVrfId, - IsAdd: !delete, - } - if config.DHCPSrcAddress, err = ipToDHCPAddress(entry.SourceIpAddress); err != nil { - return errors.Errorf("Invalid source IP address: %q", entry.SourceIpAddress) - } - for _, server := range entry.Servers { - config.ServerVrfID = server.VrfId - if config.DHCPServer, err = ipToDHCPAddress(server.IpAddress); err != nil { - return errors.Errorf("Invalid server IP address: %q", server.IpAddress) - } - reply := &vpp_dhcp.DHCPProxyConfigReply{} - if err := h.callsChannel.SendRequest(config).ReceiveReply(reply); err != nil { - return err - } - } - - return nil -} - -func (h *DHCPProxyHandler) CreateDHCPProxy(entry *l3.DHCPProxy) error { - return h.createDeleteDHCPProxy(entry, false) -} - -func (h *DHCPProxyHandler) DeleteDHCPProxy(entry *l3.DHCPProxy) error { - return h.createDeleteDHCPProxy(entry, true) -} - -func ipToDHCPAddress(address string) (dhcpAddr vpp_dhcp.Address, err error) { - netIP := net.ParseIP(address) - if netIP == nil { - return vpp_dhcp.Address{}, fmt.Errorf("invalid IP: %q", address) - } - if ip4 := netIP.To4(); ip4 == nil { - dhcpAddr.Af = ip_types.ADDRESS_IP6 - var ip6addr vpp_dhcp.IP6Address - copy(ip6addr[:], netIP.To16()) - dhcpAddr.Un.SetIP6(ip6addr) - } else { - dhcpAddr.Af = ip_types.ADDRESS_IP4 - var ip4addr vpp_dhcp.IP4Address - copy(ip4addr[:], ip4) - dhcpAddr.Un.SetIP4(ip4addr) - } - return -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/doc.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/doc.go deleted file mode 100644 index d73f761000..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// Package vppcalls contains wrappers over VPP binary APIs for ARPs, proxy ARPs, L3 FIBs and helpers for dumping them. -package vpp2001 diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/ipneigh_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/ipneigh_vppcalls.go deleted file mode 100644 index b26030dd6d..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/ipneigh_vppcalls.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "strconv" - - //vpp_ip_neighbor "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_neighbor" - //"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -/* - FIXME: IP neighbor configuraton is not implemented for 20.01, because - of breaking change in the API. - New proto model must be defined to support configuring this properly. - The current model does not allow separated config for IPv4 and IPv6. -*/ - -// DefaultIPScanNeighbor implements ip neigh handler. -func (h *IPNeighHandler) DefaultIPScanNeighbor() *l3.IPScanNeighbor { - return nil - - /*return &l3.IPScanNeighbor{ - Mode: l3.IPScanNeighbor_DISABLED, - MaxProcTime: 0, - MaxUpdate: 50000, - ScanInterval: 0, - ScanIntDelay: 0, - StaleThreshold: 0, - }*/ -} - -// SetIPScanNeighbor implements ip neigh handler. -func (h *IPNeighHandler) SetIPScanNeighbor(data *l3.IPScanNeighbor) (err error) { - return vppcalls.ErrIPNeighborNotImplemented - - /*switch data.Mode { - case l3.IPScanNeighbor_IPV4: - return h.setIPScanNeighbor(ip_types.ADDRESS_IP4, data.MaxUpdate, data.MaxProcTime, recycle) - case l3.IPScanNeighbor_IPV6: - return h.setIPScanNeighbor(ip_types.ADDRESS_IP6, data.MaxUpdate, data.MaxProcTime, recycle) - case l3.IPScanNeighbor_BOTH: - err = h.setIPScanNeighbor(ip_types.ADDRESS_IP4, data.MaxUpdate, data.MaxProcTime, recycle) - if err != nil { - return err - } - err = h.setIPScanNeighbor(ip_types.ADDRESS_IP6, data.MaxUpdate, data.MaxProcTime, recycle) - if err != nil { - return err - } - case l3.IPScanNeighbor_DISABLED: - err = h.setIPScanNeighbor(ip_types.ADDRESS_IP4, 0, 0, false) - if err != nil { - return err - } - err = h.setIPScanNeighbor(ip_types.ADDRESS_IP6, 0, 0, false) - if err != nil { - return err - } - default: - return fmt.Errorf("unknown IP Scan Neighbor mode: %v", data.Mode) - } - return nil*/ -} - -/*func (h *IPNeighHandler) setIPScanNeighbor(af ip_types.AddressFamily, maxNum, maxAge uint32, recycle bool) error { - req := &vpp_ip_neighbor.IPNeighborConfig{ - Af: af, - MaxNumber: maxNum, - MaxAge: maxAge, - Recycle: recycle, - } - reply := &vpp_ip_neighbor.IPNeighborConfigReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -}*/ - -var ( -/* - Sample outputs for VPP CLI 'show ip neighbor-config' - --- - ip4: - limit:50000, age:0, recycle:0 - ip6: - limit:50000, age:0, recycle:0 - --- -*/ -//cliIPScanNeighRe = regexp.MustCompile(`(ip4|ip6):\n\s+limit:([0-9]+),\s+age:([0-9]+),\s+recycle:([0-9]+)\s+`) -) - -// GetIPScanNeighbor dumps current IP Scan Neighbor configuration. -func (h *IPNeighHandler) GetIPScanNeighbor() (*l3.IPScanNeighbor, error) { - return nil, vppcalls.ErrIPNeighborNotImplemented - - /*data, err := h.RunCli(context.TODO(), "show ip neighbor-config") - if err != nil { - return nil, err - } - - allMatches := cliIPScanNeighRe.FindAllStringSubmatch(data, 2) - - fmt.Printf("%d MATCHES:\n%q\n", len(allMatches), allMatches) - - if len(allMatches) != 2 || len(allMatches[0]) != 5 || len(allMatches[1]) != 5 { - h.log.Warnf("invalid 'show ip neighbor-config' output: %q", data) - return nil, errors.Errorf("invalid VPP CLI output for ip neighbor config") - } - - ipScanNeigh := &l3.IPScanNeighbor{} - - for _, matches := range allMatches { - switch matches[1] { - case "ip4": - ipScanNeigh.Mode = l3.IPScanNeighbor_IPV4 - case "ip6": - ipScanNeigh.Mode = l3.IPScanNeighbor_IPV6 - } - ipScanNeigh.MaxUpdate = h.strToUint32(matches[2]) - ipScanNeigh.MaxProcTime = h.strToUint32(matches[3]) - ipScanNeigh.ScanInterval = h.strToUint32(matches[4]) - } - - return ipScanNeigh, nil*/ -} - -func (h *IPNeighHandler) strToUint32(s string) uint32 { - if s == "" { - return 0 - } - n, err := strconv.ParseUint(s, 10, 32) - if err != nil { - h.log.Error(err) - } - return uint32(n) -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/ipneigh_vppcalls_test.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/ipneigh_vppcalls_test.go deleted file mode 100644 index 920514ccb9..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/ipneigh_vppcalls_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -/* -import ( - "testing" - - . "github.com/onsi/gomega" - - vpp_vpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - - -func TestGetIPScanNeighbor(t *testing.T) { - tests := []struct { - name string - cliReply string - expected l3.IPScanNeighbor - }{ - { - name: "default", - cliReply: `ip4: - limit:50000, age:0, recycle:0 -ip6: - limit:50000, age:0, recycle:0 -`, - expected: l3.IPScanNeighbor{ - Mode: l3.IPScanNeighbor_DISABLED, - MaxUpdate: 50000, - }, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - ctx := vppmock.SetupTestCtx(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_vpe.CliInbandReply{ - Reply: test.cliReply, - }) - - handler := NewIPNeighVppHandler(ctx.MockChannel, nil) - - ipNeigh, err := handler.GetIPScanNeighbor() - Expect(err).ShouldNot(HaveOccurred()) - Expect(ipNeigh.Mode).To(Equal(test.expected.Mode)) - Expect(ipNeigh.ScanInterval).To(Equal(test.expected.ScanInterval)) - Expect(ipNeigh.ScanIntDelay).To(Equal(test.expected.ScanIntDelay)) - Expect(ipNeigh.StaleThreshold).To(Equal(test.expected.StaleThreshold)) - Expect(ipNeigh.MaxUpdate).To(Equal(test.expected.MaxUpdate)) - Expect(ipNeigh.MaxProcTime).To(Equal(test.expected.MaxProcTime)) - }) - } -} -*/ diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/l3xc_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/l3xc_vppcalls.go deleted file mode 100644 index 4aa7913a0f..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/l3xc_vppcalls.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "io" - "net" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l3xc" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" -) - -func (h *L3XCHandler) DumpAllL3XC(ctx context.Context) ([]vppcalls.L3XC, error) { - return h.DumpL3XC(ctx, ^uint32(0)) -} - -func (h *L3XCHandler) DumpL3XC(ctx context.Context, index uint32) ([]vppcalls.L3XC, error) { - if h.l3xc == nil { - // no-op when disabled - return nil, nil - } - - dump, err := h.l3xc.DumpL3xc(ctx, &l3xc.L3xcDump{ - SwIfIndex: interface_types.InterfaceIndex(index), - }) - if err != nil { - return nil, err - } - l3xcs := make([]vppcalls.L3XC, 0) - for { - recv, err := dump.Recv() - if err == io.EOF { - break - } else if err != nil { - return nil, err - } - paths := make([]vppcalls.Path, len(recv.L3xc.Paths)) - for i, p := range recv.L3xc.Paths { - var nextHop net.IP - if p.Proto == fib_types.FIB_API_PATH_NH_PROTO_IP6 { - ip6Addr := p.Nh.Address.GetIP6() - nextHop = net.IP(ip6Addr[:]).To16() - } else { - ip4Addr := p.Nh.Address.GetIP4() - nextHop = net.IP(ip4Addr[:4]).To4() - } - paths[i] = vppcalls.Path{ - SwIfIndex: p.SwIfIndex, - Weight: p.Weight, - Preference: p.Preference, - NextHop: nextHop, - } - } - l3xcs = append(l3xcs, vppcalls.L3XC{ - SwIfIndex: uint32(recv.L3xc.SwIfIndex), - IsIPv6: recv.L3xc.IsIP6, - Paths: paths, - }) - } - return l3xcs, nil -} - -func (h *L3XCHandler) UpdateL3XC(ctx context.Context, xc *vppcalls.L3XC) error { - if h.l3xc == nil { - return errors.Wrap(vpp.ErrPluginDisabled, "l3xc") - } - - paths := make([]l3xc.FibPath, len(xc.Paths)) - for i, p := range xc.Paths { - fibPath := l3xc.FibPath{ - SwIfIndex: p.SwIfIndex, - Weight: p.Weight, - Preference: p.Preference, - Type: fib_types.FIB_API_PATH_TYPE_NORMAL, - } - fibPath.Nh, fibPath.Proto = getL3XCFibPathNhAndProto(p.NextHop) - paths[i] = fibPath - } - _, err := h.l3xc.L3xcUpdate(ctx, &l3xc.L3xcUpdate{ - L3xc: l3xc.L3xc{ - SwIfIndex: interface_types.InterfaceIndex(xc.SwIfIndex), - IsIP6: xc.IsIPv6, - Paths: paths, - }, - }) - if err != nil { - return err - } - return nil -} - -func (h *L3XCHandler) DeleteL3XC(ctx context.Context, index uint32, ipv6 bool) error { - if h.l3xc == nil { - return errors.Wrap(vpp.ErrPluginDisabled, "l3xc") - } - - _, err := h.l3xc.L3xcDel(ctx, &l3xc.L3xcDel{ - SwIfIndex: interface_types.InterfaceIndex(index), - IsIP6: ipv6, - }) - if err != nil { - return err - } - return nil -} - -func getL3XCFibPathNhAndProto(netIP net.IP) (nh l3xc.FibPathNh, proto l3xc.FibPathNhProto) { - var addrUnion fib_types.AddressUnion - if netIP.To4() == nil { - proto = fib_types.FIB_API_PATH_NH_PROTO_IP6 - var ip6addr fib_types.IP6Address - copy(ip6addr[:], netIP.To16()) - addrUnion.SetIP6(ip6addr) - } else { - proto = fib_types.FIB_API_PATH_NH_PROTO_IP4 - var ip4addr fib_types.IP4Address - copy(ip4addr[:], netIP.To4()) - addrUnion.SetIP4(ip4addr) - } - return l3xc.FibPathNh{ - Address: addrUnion, - ViaLabel: NextHopViaLabelUnset, - ClassifyTableIndex: ClassifyTableIndexUnset, - }, proto -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_dump.go deleted file mode 100644 index 69325f4181..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_dump.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - vpp_arp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/arp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -// DumpProxyArpRanges implements proxy arp handler. -func (h *ProxyArpVppHandler) DumpProxyArpRanges() (pArpRngs []*vppcalls.ProxyArpRangesDetails, err error) { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_arp.ProxyArpDump{}) - - for { - proxyArpDetails := &vpp_arp.ProxyArpDetails{} - stop, err := reqCtx.ReceiveReply(proxyArpDetails) - if stop { - break - } - if err != nil { - h.log.Error(err) - return nil, err - } - - pArpRngs = append(pArpRngs, &vppcalls.ProxyArpRangesDetails{ - Range: &l3.ProxyARP_Range{ - FirstIpAddr: net.IP(proxyArpDetails.Proxy.Low[:]).To4().String(), - LastIpAddr: net.IP(proxyArpDetails.Proxy.Hi[:]).To4().String(), - VrfId: proxyArpDetails.Proxy.TableID, - }, - }) - } - - return pArpRngs, nil -} - -// DumpProxyArpInterfaces implements proxy arp handler. -func (h *ProxyArpVppHandler) DumpProxyArpInterfaces() (pArpIfs []*vppcalls.ProxyArpInterfaceDetails, err error) { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_arp.ProxyArpIntfcDump{}) - - for { - proxyArpDetails := &vpp_arp.ProxyArpIntfcDetails{} - stop, err := reqCtx.ReceiveReply(proxyArpDetails) - if stop { - break - } - if err != nil { - h.log.Error(err) - return nil, err - } - - // Interface - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(proxyArpDetails.SwIfIndex) - if !exists { - h.log.Warnf("Proxy ARP interface dump: missing name for interface index %d", proxyArpDetails.SwIfIndex) - } - - // Create entry - pArpIfs = append(pArpIfs, &vppcalls.ProxyArpInterfaceDetails{ - Interface: &l3.ProxyARP_Interface{ - Name: ifName, - }, - Meta: &vppcalls.ProxyArpInterfaceMeta{ - SwIfIndex: proxyArpDetails.SwIfIndex, - }, - }) - - } - - return pArpIfs, nil -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_vppcalls.go deleted file mode 100644 index e59b15efd9..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_vppcalls.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "github.com/pkg/errors" - - vpp_arp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/arp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" -) - -// EnableProxyArpInterface implements proxy arp handler. -func (h *ProxyArpVppHandler) EnableProxyArpInterface(ifName string) error { - return h.vppAddDelProxyArpInterface(ifName, true) -} - -// DisableProxyArpInterface implements proxy arp handler. -func (h *ProxyArpVppHandler) DisableProxyArpInterface(ifName string) error { - return h.vppAddDelProxyArpInterface(ifName, false) -} - -// AddProxyArpRange implements proxy arp handler. -func (h *ProxyArpVppHandler) AddProxyArpRange(firstIP, lastIP []byte, vrfID uint32) error { - return h.vppAddDelProxyArpRange(firstIP, lastIP, vrfID, true) -} - -// DeleteProxyArpRange implements proxy arp handler. -func (h *ProxyArpVppHandler) DeleteProxyArpRange(firstIP, lastIP []byte, vrfID uint32) error { - return h.vppAddDelProxyArpRange(firstIP, lastIP, vrfID, false) -} - -// vppAddDelProxyArpInterface adds or removes proxy ARP interface entry according to provided input -func (h *ProxyArpVppHandler) vppAddDelProxyArpInterface(ifName string, enable bool) error { - meta, found := h.ifIndexes.LookupByName(ifName) - if !found { - return errors.Errorf("interface %s not found", ifName) - } - - req := &vpp_arp.ProxyArpIntfcEnableDisable{ - Enable: enable, - SwIfIndex: interface_types.InterfaceIndex(meta.SwIfIndex), - } - - reply := &vpp_arp.ProxyArpIntfcEnableDisableReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - h.log.Debugf("interface %v enabled for proxy arp: %v", req.SwIfIndex, enable) - - return nil -} - -// vppAddDelProxyArpRange adds or removes proxy ARP range according to provided input. -func (h *ProxyArpVppHandler) vppAddDelProxyArpRange(firstIP, lastIP []byte, vrf uint32, isAdd bool) error { - validateIPBytes := func(b []byte) error { - ip := net.IP(b) - if ip.To4() == nil { - return fmt.Errorf("IP bytes %v are not valid IPv4 address", b) - } - return nil - } - if err := validateIPBytes(firstIP); err != nil { - return fmt.Errorf("bad first IP: %v", err) - } - if err := validateIPBytes(lastIP); err != nil { - return fmt.Errorf("bad last IP: %v", err) - } - - proxy := vpp_arp.ProxyArp{ - TableID: vrf, - } - copy(proxy.Low[:], firstIP) - copy(proxy.Hi[:], lastIP) - - req := &vpp_arp.ProxyArpAddDel{ - IsAdd: isAdd, - Proxy: proxy, - } - - reply := &vpp_arp.ProxyArpAddDelReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - h.log.Debugf("proxy arp range: %v - %v (vrf: %d) added: %v", proxy.Low, proxy.Hi, proxy.TableID, isAdd) - - return nil -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_vppcalls_test.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_vppcalls_test.go deleted file mode 100644 index deaa5c60aa..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/proxyarp_vppcalls_test.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_arp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/arp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" -) - -// Test enable/disable proxy arp -func TestProxyArp(t *testing.T) { - ctx, ifIndexes, pArpHandler := pArpTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpIntfcEnableDisableReply{}) - err := pArpHandler.EnableProxyArpInterface("if1") - Expect(err).To(Succeed()) - - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpIntfcEnableDisableReply{}) - err = pArpHandler.DisableProxyArpInterface("if1") - Expect(err).To(Succeed()) - - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpIntfcEnableDisableReply{Retval: 1}) - err = pArpHandler.DisableProxyArpInterface("if1") - Expect(err).NotTo(BeNil()) -} - -func TestProxyArpRange(t *testing.T) { - ctx, _, pArpHandler := pArpTestSetup(t) - defer ctx.TeardownTestCtx() - - t.Run("Add: success case", func(t *testing.T) { - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpAddDelReply{Retval: 0}) - - Expect(pArpHandler.AddProxyArpRange( - []byte{192, 168, 10, 20}, []byte{192, 168, 10, 30}, 0, - )).To(Succeed()) - }) - - testAddProxyARPRangeError := func(firstIP, lastIP []byte, vrf uint32) { - t.Helper() - - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpAddDelReply{Retval: 0}) - Expect(pArpHandler.AddProxyArpRange(firstIP, lastIP, vrf)).ToNot(Succeed()) - - //Get mocked reply, since VPP call should not happen before. - Expect( - ctx.MockVPPClient.SendRequest(&vpp_arp.ProxyArpAddDel{}).ReceiveReply(&vpp_arp.ProxyArpAddDelReply{}), - ).To(Succeed()) - } - t.Run("Add: error cases", func(t *testing.T) { - // Bad first IP address. - testAddProxyARPRangeError([]byte{192, 168, 20}, []byte{192, 168, 10, 30}, 0) - // Bad last IP address. - testAddProxyARPRangeError([]byte{192, 168, 10, 20}, []byte{192, 168, 30}, 0) - // Bad both IP addresses. - testAddProxyARPRangeError([]byte{192, 168, 20}, []byte{192, 168, 30}, 0) - }) - - t.Run("Delete: success case", func(t *testing.T) { - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpAddDelReply{Retval: 0}) - - Expect(pArpHandler.DeleteProxyArpRange( - []byte{192, 168, 10, 20}, []byte{192, 168, 10, 30}, 0, - )).To(Succeed()) - }) - - testDelProxyARPRangeError := func(firstIP, lastIP []byte, vrf uint32) { - t.Helper() - - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpAddDelReply{Retval: 0}) - Expect(pArpHandler.DeleteProxyArpRange(firstIP, lastIP, vrf)).ToNot(Succeed()) - - //Get mocked reply, since VPP call should not happen before. - Expect( - ctx.MockVPPClient.SendRequest(&vpp_arp.ProxyArpAddDel{}).ReceiveReply(&vpp_arp.ProxyArpAddDelReply{}), - ).To(Succeed()) - } - t.Run("Delete: error cases", func(t *testing.T) { - // Bad first IP address. - testDelProxyARPRangeError([]byte{192, 168, 20}, []byte{192, 168, 10, 30}, 0) - // Bad last IP address. - testDelProxyARPRangeError([]byte{192, 168, 10, 20}, []byte{192, 168, 30}, 0) - // Bad both IP addresses. - testDelProxyARPRangeError([]byte{192, 168, 20}, []byte{192, 168, 30}, 0) - }) - - // Test retval in "add" scenario. - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpAddDelReply{Retval: 1}) - Expect(pArpHandler.AddProxyArpRange( - []byte{192, 168, 10, 20}, []byte{192, 168, 10, 30}, 0, - )).ToNot(Succeed()) - - // Test retval in "delete" scenario. - ctx.MockVpp.MockReply(&vpp_arp.ProxyArpAddDelReply{Retval: 1}) - Expect(pArpHandler.DeleteProxyArpRange( - []byte{192, 168, 10, 20}, []byte{192, 168, 10, 30}, 0, - )).ToNot(Succeed()) -} - -func pArpTestSetup(t *testing.T) (*vppmock.TestCtx, ifaceidx.IfaceMetadataIndexRW, vppcalls.ProxyArpVppAPI) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - ifIndexes := ifaceidx.NewIfaceIndex(logrus.NewLogger("test"), "test") - pArpHandler := vpp2001.NewProxyArpVppHandler(ctx.MockChannel, ifIndexes, log) - return ctx, ifIndexes, pArpHandler -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/route_dump.go deleted file mode 100644 index 5204fd3b0c..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_dump.go +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -// DumpRoutes implements route handler. -func (h *RouteHandler) DumpRoutes() (routes []*vppcalls.RouteDetails, err error) { - // dump routes for every VRF and for both IP versions - for _, vrfMeta := range h.vrfIndexes.ListAllVrfMetadata() { - ipRoutes, err := h.dumpRoutesForVrfAndIP(vrfMeta.GetIndex(), vrfMeta.GetProtocol()) - if err != nil { - return nil, err - } - routes = append(routes, ipRoutes...) - } - return routes, nil -} - -// dumpRoutesForVrf returns routes for given VRF and IP versiob -func (h *RouteHandler) dumpRoutesForVrfAndIP(vrfID uint32, proto l3.VrfTable_Protocol) (routes []*vppcalls.RouteDetails, err error) { - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ip.IPRouteDump{ - Table: vpp_ip.IPTable{ - TableID: vrfID, - IsIP6: protoToUint(proto), - }, - }) - for { - fibDetails := &vpp_ip.IPRouteDetails{} - stop, err := reqCtx.ReceiveReply(fibDetails) - if stop { - break - } - if err != nil { - return nil, err - } - ipRoute, err := h.dumpRouteIPDetails(fibDetails.Route) - if err != nil { - return nil, err - } - routes = append(routes, ipRoute...) - } - - return routes, nil -} - -// dumpRouteIPDetails processes static route details and returns a route objects. Number of routes returned -// depends on size of path list. -func (h *RouteHandler) dumpRouteIPDetails(ipRoute vpp_ip.IPRoute) ([]*vppcalls.RouteDetails, error) { - // Common fields for every route path (destination IP, VRF) - var dstIP string - if ipRoute.Prefix.Address.Af == ip_types.ADDRESS_IP6 { - ip6Addr := ipRoute.Prefix.Address.Un.GetIP6() - dstIP = fmt.Sprintf("%s/%d", net.IP(ip6Addr[:]).To16().String(), uint32(ipRoute.Prefix.Len)) - } else { - ip4Addr := ipRoute.Prefix.Address.Un.GetIP4() - dstIP = fmt.Sprintf("%s/%d", net.IP(ip4Addr[:4]).To4().String(), uint32(ipRoute.Prefix.Len)) - } - - var routeDetails []*vppcalls.RouteDetails - - // Paths - if ipRoute.NPaths > 0 { - for _, path := range ipRoute.Paths { - // Next hop IP address - var nextHopIP string - netIP := make([]byte, 16) - copy(netIP[:], path.Nh.Address.XXX_UnionData[:]) - if path.Proto == fib_types.FIB_API_PATH_NH_PROTO_IP6 { - nextHopIP = fmt.Sprintf("%s", net.IP(netIP).To16().String()) - } else { - nextHopIP = fmt.Sprintf("%s", net.IP(netIP[:4]).To4().String()) - } - - // Route type (if via VRF is used) - var routeType l3.Route_RouteType - var viaVrfID uint32 - if path.Type == fib_types.FIB_API_PATH_TYPE_DROP { - routeType = l3.Route_DROP - } else if path.SwIfIndex == NextHopOutgoingIfUnset && path.TableID != ipRoute.TableID { - // outgoing interface not specified and path table is not equal to route table id = inter-VRF route - routeType = l3.Route_INTER_VRF - viaVrfID = path.TableID - } else { - routeType = l3.Route_INTRA_VRF // default - } - - // Outgoing interface - var ifName string - var ifIdx uint32 - if path.SwIfIndex == NextHopOutgoingIfUnset { - ifIdx = NextHopOutgoingIfUnset - } else { - var exists bool - ifIdx = path.SwIfIndex - if ifName, _, exists = h.ifIndexes.LookupBySwIfIndex(path.SwIfIndex); !exists { - h.log.Warnf("Static route dump: interface name for index %d not found", path.SwIfIndex) - } - } - - // Route configuration - route := &l3.Route{ - Type: routeType, - VrfId: ipRoute.TableID, - DstNetwork: dstIP, - NextHopAddr: nextHopIP, - OutgoingInterface: ifName, - Weight: uint32(path.Weight), - Preference: uint32(path.Preference), - ViaVrfId: viaVrfID, - } - - labelStack := make([]vppcalls.FibMplsLabel, len(path.LabelStack)) - for i, l := range path.LabelStack { - labelStack[i] = vppcalls.FibMplsLabel{ - IsUniform: uintToBool(l.IsUniform), - Label: l.Label, - TTL: l.TTL, - Exp: l.Exp, - } - } - - // Route metadata - meta := &vppcalls.RouteMeta{ - OutgoingIfIdx: ifIdx, - IsIPv6: path.Proto == fib_types.FIB_API_PATH_NH_PROTO_IP6, - NextHopID: path.Nh.ObjID, - RpfID: path.RpfID, - LabelStack: labelStack, - } - resolvePathType(meta, path.Type) - resolvePathFlags(meta, path.Flags) - // Note: VPP does not return table name as in older versions, the field - // is filled using index map - vrfName, _, exists := h.vrfIndexes.LookupByVRFIndex(ipRoute.TableID) - if exists { - meta.TableName = vrfName - } - - routeDetails = append(routeDetails, &vppcalls.RouteDetails{ - Route: route, - Meta: meta, - }) - } - } else { - // Return route without path fields, but this is not a valid configuration - h.log.Warnf("Route with destination IP %s (VRF %d) has no path specified", dstIP, ipRoute.TableID) - routeDetails = append(routeDetails, &vppcalls.RouteDetails{ - Route: &l3.Route{ - Type: l3.Route_INTRA_VRF, // default - VrfId: ipRoute.TableID, - DstNetwork: dstIP, - }, - }) - } - - return routeDetails, nil -} - -func resolvePathType(meta *vppcalls.RouteMeta, pathType vpp_ip.FibPathType) { - switch pathType { - case fib_types.FIB_API_PATH_TYPE_LOCAL: - meta.IsLocal = true - case fib_types.FIB_API_PATH_TYPE_UDP_ENCAP: - meta.IsUDPEncap = true - case fib_types.FIB_API_PATH_TYPE_ICMP_UNREACH: - meta.IsUnreach = true - case fib_types.FIB_API_PATH_TYPE_ICMP_PROHIBIT: - meta.IsProhibit = true - case fib_types.FIB_API_PATH_TYPE_DVR: - meta.IsDvr = true - case fib_types.FIB_API_PATH_TYPE_SOURCE_LOOKUP: - meta.IsSourceLookup = true - } -} - -func resolvePathFlags(meta *vppcalls.RouteMeta, pathFlags vpp_ip.FibPathFlags) { - switch pathFlags { - case fib_types.FIB_API_PATH_FLAG_RESOLVE_VIA_HOST: - meta.IsResolveHost = true - case fib_types.FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED: - meta.IsResolveAttached = true - } -} - -func protoToUint(proto l3.VrfTable_Protocol) bool { - if proto == l3.VrfTable_IPV6 { - return true - } - return false -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_dump_test.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/route_dump_test.go deleted file mode 100644 index 9a01dd4c6a..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_dump_test.go +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "testing" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vrfidx" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - netallock_mock "go.ligato.io/vpp-agent/v3/plugins/netalloc/mock" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - vpp_vpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" -) - -// Test dumping routes -func TestDumpStaticRoutes(t *testing.T) { - ctx := vppmock.SetupTestCtx(t) - defer ctx.TeardownTestCtx() - ifIndexes := ifaceidx.NewIfaceIndex(logrus.NewLogger("test-if"), "test-if") - vrfIndexes := vrfidx.NewVRFIndex(logrus.NewLogger("test-vrf"), "test-vrf") - l3handler := NewRouteVppHandler(ctx.MockChannel, ifIndexes, vrfIndexes, netallock_mock.NewMockNetAlloc(), - logrus.DefaultLogger()) - - vrfIndexes.Put("vrf1-ipv4", &vrfidx.VRFMetadata{Index: 0, Protocol: l3.VrfTable_IPV4}) - vrfIndexes.Put("vrf1-ipv6", &vrfidx.VRFMetadata{Index: 0, Protocol: l3.VrfTable_IPV6}) - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - ifIndexes.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - ctx.MockVpp.MockReply(&vpp_ip.IPRouteDetails{ - Route: vpp_ip.IPRoute{ - Prefix: vpp_ip.Prefix{ - Address: vpp_ip.Address{ - Af: ip_types.ADDRESS_IP4, - Un: ip_types.AddressUnionIP4([4]uint8{10, 0, 0, 1}), - }, - }, - Paths: []vpp_ip.FibPath{ - { - SwIfIndex: 2, - }, - }, - }, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - ctx.MockVpp.MockReply(&vpp_ip.IPRouteDetails{ - Route: vpp_ip.IPRoute{ - Prefix: vpp_ip.Prefix{ - Address: vpp_ip.Address{ - Af: ip_types.ADDRESS_IP6, - Un: ip_types.AddressUnionIP6([16]uint8{255, 255, 10, 1}), - }, - }, - Paths: []vpp_ip.FibPath{ - { - SwIfIndex: 1, - }, - }, - }, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - rtDetails, err := l3handler.DumpRoutes() - Expect(err).To(Succeed()) - Expect(rtDetails).To(HaveLen(2)) - Expect(rtDetails[0].Route.OutgoingInterface).To(Equal("if2")) - Expect(rtDetails[1].Route.OutgoingInterface).To(Equal("if1")) -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/route_vppcalls.go deleted file mode 100644 index 17f860fb46..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_vppcalls.go +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "net" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/fib_types" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/proto/ligato/netalloc" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -const ( - // NextHopViaLabelUnset constant has to be assigned into the field next hop - // via label in ip_add_del_route binary message if next hop via label is not defined. - // Equals to MPLS_LABEL_INVALID defined in VPP - NextHopViaLabelUnset uint32 = 0xfffff + 1 - - // ClassifyTableIndexUnset is a default value for field classify_table_index in ip_add_del_route binary message. - ClassifyTableIndexUnset = ^uint32(0) - - // NextHopOutgoingIfUnset constant has to be assigned into the field next_hop_outgoing_interface - // in ip_add_del_route binary message if outgoing interface for next hop is not defined. - NextHopOutgoingIfUnset = ^uint32(0) -) - -// vppAddDelRoute adds or removes route, according to provided input. Every route has to contain VRF ID (default is 0). -func (h *RouteHandler) vppAddDelRoute(route *l3.Route, rtIfIdx uint32, delete bool) error { - req := &vpp_ip.IPRouteAddDel{ - // Multi path is always true - IsMultipath: true, - IsAdd: !delete, - } - - // Common route parameters - fibPath := vpp_ip.FibPath{ - Weight: uint8(route.Weight), - Preference: uint8(route.Preference), - } - if route.NextHopAddr != "" { - nextHop, err := h.addrAlloc.GetOrParseIPAddress(route.NextHopAddr, - route.OutgoingInterface, netalloc.IPAddressForm_ADDR_ONLY) - if err != nil { - return err - } - fibPath.Nh, fibPath.Proto = setFibPathNhAndProto(nextHop.IP) - } - - // VRF/Other route parameters based on type - if route.Type == l3.Route_INTER_VRF { - fibPath.SwIfIndex = rtIfIdx - fibPath.TableID = route.ViaVrfId - } else if route.Type == l3.Route_DROP { - fibPath.Type = fib_types.FIB_API_PATH_TYPE_DROP - } else { - fibPath.SwIfIndex = rtIfIdx - fibPath.TableID = route.VrfId - } - // Destination address - dstNet, err := h.addrAlloc.GetOrParseIPAddress(route.DstNetwork, - "", netalloc.IPAddressForm_ADDR_NET) - if err != nil { - return err - } - prefix := networkToPrefix(dstNet) - - req.Route = vpp_ip.IPRoute{ - TableID: route.VrfId, - Prefix: prefix, - NPaths: 1, - Paths: []vpp_ip.FibPath{fibPath}, - } - - reply := &vpp_ip.IPRouteAddDelReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// VppAddRoute implements route handler. -func (h *RouteHandler) VppAddRoute(ctx context.Context, route *l3.Route) error { - swIfIdx, err := h.getRouteSwIfIndex(route.OutgoingInterface) - if err != nil { - return err - } - - return h.vppAddDelRoute(route, swIfIdx, false) -} - -// VppDelRoute implements route handler. -func (h *RouteHandler) VppDelRoute(ctx context.Context, route *l3.Route) error { - swIfIdx, err := h.getRouteSwIfIndex(route.OutgoingInterface) - if err != nil { - return err - } - - return h.vppAddDelRoute(route, swIfIdx, true) -} - -func setFibPathNhAndProto(netIP net.IP) (nh vpp_ip.FibPathNh, proto vpp_ip.FibPathNhProto) { - var addrUnion vpp_ip.AddressUnion - if netIP.To4() == nil { - proto = fib_types.FIB_API_PATH_NH_PROTO_IP6 - var ip6addr vpp_ip.IP6Address - copy(ip6addr[:], netIP.To16()) - addrUnion.SetIP6(ip6addr) - } else { - proto = fib_types.FIB_API_PATH_NH_PROTO_IP4 - var ip4addr vpp_ip.IP4Address - copy(ip4addr[:], netIP.To4()) - addrUnion.SetIP4(ip4addr) - } - - return vpp_ip.FibPathNh{ - Address: addrUnion, - ViaLabel: NextHopViaLabelUnset, - ClassifyTableIndex: ClassifyTableIndexUnset, - }, proto -} - -func (h *RouteHandler) getRouteSwIfIndex(ifName string) (swIfIdx uint32, err error) { - swIfIdx = NextHopOutgoingIfUnset - if ifName != "" { - meta, found := h.ifIndexes.LookupByName(ifName) - if !found { - return 0, errors.Errorf("interface %s not found", ifName) - } - swIfIdx = meta.SwIfIndex - } - return -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_vppcalls_test.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/route_vppcalls_test.go deleted file mode 100644 index 28f3e0710c..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/route_vppcalls_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vrfidx" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - netallock_mock "go.ligato.io/vpp-agent/v3/plugins/netalloc/mock" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - ifvppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" - ifvpp2001_379 "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -var routes = []*l3.Route{ - { - VrfId: 1, - DstNetwork: "192.168.10.21/24", - NextHopAddr: "192.168.30.1", - OutgoingInterface: "iface1", - }, - { - VrfId: 2, - DstNetwork: "10.0.0.1/24", - NextHopAddr: "192.168.30.1", - }, - { - VrfId: 2, - DstNetwork: "10.11.0.1/16", - NextHopAddr: "192.168.30.1", - OutgoingInterface: "iface3", - }, -} - -// Test adding routes -func TestAddRoute(t *testing.T) { - ctx, _, rtHandler := routeTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPRouteAddDelReply{}) - err := rtHandler.VppAddRoute(ctx.Context, routes[0]) - Expect(err).To(Succeed()) - - ctx.MockVpp.MockReply(&vpp_ip.IPRouteAddDelReply{}) - err = rtHandler.VppAddRoute(ctx.Context, routes[2]) - Expect(err).To(Not(BeNil())) // unknown interface -} - -// Test deleting routes -func TestDeleteRoute(t *testing.T) { - ctx, _, rtHandler := routeTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPRouteAddDelReply{}) - err := rtHandler.VppDelRoute(ctx.Context, routes[0]) - Expect(err).To(Succeed()) - - ctx.MockVpp.MockReply(&vpp_ip.IPRouteAddDelReply{}) - err = rtHandler.VppDelRoute(ctx.Context, routes[1]) - Expect(err).To(Succeed()) - - ctx.MockVpp.MockReply(&vpp_ip.IPRouteAddDelReply{Retval: 1}) - err = rtHandler.VppDelRoute(ctx.Context, routes[0]) - Expect(err).To(Not(BeNil())) -} - -func routeTestSetup(t *testing.T) (*vppmock.TestCtx, ifvppcalls.InterfaceVppAPI, vppcalls.RouteVppAPI) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - ifHandler := ifvpp2001_379.NewInterfaceVppHandler(ctx.MockVPPClient, log) - ifIndexes := ifaceidx.NewIfaceIndex(logrus.NewLogger("test-if"), "test-if") - vrfIndexes := vrfidx.NewVRFIndex(logrus.NewLogger("test-vrf"), "test-vrf") - ifIndexes.Put("iface1", &ifaceidx.IfaceMetadata{ - SwIfIndex: 1, - }) - rtHandler := vpp2001.NewRouteVppHandler(ctx.MockChannel, ifIndexes, vrfIndexes, netallock_mock.NewMockNetAlloc(), log) - return ctx, ifHandler, rtHandler -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/vppcalls_handlers.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/vppcalls_handlers.go deleted file mode 100644 index 1de0512bba..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/vppcalls_handlers.go +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "context" - "fmt" - "net" - - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - "go.ligato.io/cn-infra/v2/logging/logrus" - - corevppcalls "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls" - vpe_vpp2001 "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/netalloc" - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - vpp_dhcp "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/dhcp" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - vpp_ip_neighbor "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_neighbor" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/l3xc" - vpp_vpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vrfidx" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -func init() { - var msgs []govppapi.Message - msgs = append(msgs, vpp_ip.AllMessages()...) - msgs = append(msgs, vpp_ip_neighbor.AllMessages()...) - msgs = append(msgs, vpp_vpe.AllMessages()...) - msgs = append(msgs, vpp_dhcp.AllMessages()...) - - vppcalls.AddHandlerVersion(vpp2001.Version, msgs, NewL3VppHandler) -} - -type L3VppHandler struct { - *ArpVppHandler - *ProxyArpVppHandler - *RouteHandler - *IPNeighHandler - *VrfTableHandler - *DHCPProxyHandler - *L3XCHandler - *TeibHandlerUnsupported - *VrrpVppHandler -} - -func NewL3VppHandler( - c vpp.Client, - ifIdx ifaceidx.IfaceMetadataIndex, - vrfIdx vrfidx.VRFMetadataIndex, - addrAlloc netalloc.AddressAllocator, - log logging.Logger, -) vppcalls.L3VppAPI { - ch, err := c.NewAPIChannel() - if err != nil { - logging.Warnf("creating channel failed: %v", err) - return nil - } - return &L3VppHandler{ - ArpVppHandler: NewArpVppHandler(ch, ifIdx, log), - ProxyArpVppHandler: NewProxyArpVppHandler(ch, ifIdx, log), - RouteHandler: NewRouteVppHandler(ch, ifIdx, vrfIdx, addrAlloc, log), - IPNeighHandler: NewIPNeighVppHandler(ch, log), - VrfTableHandler: NewVrfTableVppHandler(ch, log), - DHCPProxyHandler: NewDHCPProxyHandler(ch, log), - L3XCHandler: NewL3XCHandler(c, ifIdx, log), - VrrpVppHandler: NewVrrpVppHandler(ch, log), - TeibHandlerUnsupported: &TeibHandlerUnsupported{}, - } -} - -// ArpVppHandler is accessor for ARP-related vppcalls methods -type ArpVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// DHCPProxyHandler is accessor for DHCP proxy-related vppcalls methods -type DHCPProxyHandler struct { - callsChannel govppapi.Channel - log logging.Logger -} - -// ProxyArpVppHandler is accessor for proxy ARP-related vppcalls methods -type ProxyArpVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// RouteHandler is accessor for route-related vppcalls methods -type RouteHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - vrfIndexes vrfidx.VRFMetadataIndex - addrAlloc netalloc.AddressAllocator - log logging.Logger -} - -// IPNeighHandler is accessor for ip-neighbor-related vppcalls methods -type IPNeighHandler struct { - callsChannel govppapi.Channel - log logging.Logger - corevppcalls.VppCoreAPI -} - -// VrfTableHandler is accessor for vrf-related vppcalls methods -type VrfTableHandler struct { - callsChannel govppapi.Channel - log logging.Logger -} - -// VrrpVppHandler is accessor for vrrp-related vppcalls methods -type VrrpVppHandler struct { - callsChannel govppapi.Channel - log logging.Logger -} - -// NewArpVppHandler creates new instance of IPsec vppcalls handler -func NewArpVppHandler(callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) *ArpVppHandler { - if log == nil { - log = logrus.NewLogger("arp-handler") - } - return &ArpVppHandler{ - callsChannel: callsChan, - ifIndexes: ifIndexes, - log: log, - } -} - -// NewProxyArpVppHandler creates new instance of proxy ARP vppcalls handler -func NewProxyArpVppHandler(callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) *ProxyArpVppHandler { - if log == nil { - log = logrus.NewLogger("proxy-arp-handler") - } - return &ProxyArpVppHandler{ - callsChannel: callsChan, - ifIndexes: ifIndexes, - log: log, - } -} - -// NewRouteVppHandler creates new instance of route vppcalls handler -func NewRouteVppHandler(callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceMetadataIndex, - vrfIdx vrfidx.VRFMetadataIndex, addrAlloc netalloc.AddressAllocator, log logging.Logger) *RouteHandler { - if log == nil { - log = logrus.NewLogger("route-handler") - } - return &RouteHandler{ - callsChannel: callsChan, - ifIndexes: ifIndexes, - vrfIndexes: vrfIdx, - addrAlloc: addrAlloc, - log: log, - } -} - -// NewIPNeighVppHandler creates new instance of ip neighbor vppcalls handler -func NewIPNeighVppHandler(callsChan govppapi.Channel, log logging.Logger) *IPNeighHandler { - if log == nil { - log = logrus.NewLogger("ip-neigh") - } - return &IPNeighHandler{ - callsChannel: callsChan, - log: log, - VppCoreAPI: vpe_vpp2001.NewVpeHandler(callsChan), - } -} - -// NewVrfTableVppHandler creates new instance of vrf-table vppcalls handler -func NewVrfTableVppHandler(callsChan govppapi.Channel, log logging.Logger) *VrfTableHandler { - if log == nil { - log = logrus.NewLogger("vrf-table-handler") - } - return &VrfTableHandler{ - callsChannel: callsChan, - log: log, - } -} - -// NewDHCPProxyHandler creates new instance of vrf-table vppcalls handler -func NewDHCPProxyHandler(callsChan govppapi.Channel, log logging.Logger) *DHCPProxyHandler { - if log == nil { - log = logrus.NewLogger("dhcp-proxy-handler") - } - return &DHCPProxyHandler{ - callsChannel: callsChan, - log: log, - } -} - -type L3XCHandler struct { - l3xc l3xc.RPCService - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// NewL3XCHandler creates new instance of L3XC vppcalls handler -func NewL3XCHandler(c vpp.Client, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger) *L3XCHandler { - if log == nil { - log = logrus.NewLogger("l3xc-handler") - } - h := &L3XCHandler{ - ifIndexes: ifIndexes, - log: log, - } - if c.IsPluginLoaded(l3xc.ModuleName) { - ch, err := c.NewAPIChannel() - if err != nil { - logging.Warnf("creating channel failed: %v", err) - return nil - } - h.l3xc = l3xc.NewServiceClient(ch) - } - return h -} - -// NewVrrpVppHandler creates new instance of VRRP handler -func NewVrrpVppHandler(callsChan govppapi.Channel, log logging.Logger) *VrrpVppHandler { - if log == nil { - log = logrus.NewLogger("vrrp-handler") - } - return &VrrpVppHandler{ - callsChannel: callsChan, - log: log, - } -} - -type TeibHandlerUnsupported struct{} - -func (h *TeibHandlerUnsupported) VppAddTeibEntry(ctx context.Context, entry *l3.TeibEntry) error { - return fmt.Errorf("%w in VPP %s", vppcalls.ErrTeibUnsupported, vpp2001.Version) -} - -func (h *TeibHandlerUnsupported) VppDelTeibEntry(ctx context.Context, entry *l3.TeibEntry) error { - return fmt.Errorf("%w in VPP %s", vppcalls.ErrTeibUnsupported, vpp2001.Version) -} - -func (h *TeibHandlerUnsupported) DumpTeib() ([]*l3.TeibEntry, error) { - return nil, fmt.Errorf("%w in VPP %s", vppcalls.ErrTeibUnsupported, vpp2001.Version) -} - -func ipToAddress(ipstr string) (addr vpp_ip.Address, err error) { - netIP := net.ParseIP(ipstr) - if netIP == nil { - return vpp_ip.Address{}, fmt.Errorf("invalid IP: %q", ipstr) - } - if ip4 := netIP.To4(); ip4 == nil { - addr.Af = ip_types.ADDRESS_IP6 - var ip6addr vpp_ip.IP6Address - copy(ip6addr[:], netIP.To16()) - addr.Un.SetIP6(ip6addr) - } else { - addr.Af = ip_types.ADDRESS_IP4 - var ip4addr vpp_ip.IP4Address - copy(ip4addr[:], ip4) - addr.Un.SetIP4(ip4addr) - } - return -} - -func networkToPrefix(dstNetwork *net.IPNet) vpp_ip.Prefix { - var addr vpp_ip.Address - if dstNetwork.IP.To4() == nil { - addr.Af = ip_types.ADDRESS_IP6 - var ip6addr vpp_ip.IP6Address - copy(ip6addr[:], dstNetwork.IP.To16()) - addr.Un.SetIP6(ip6addr) - } else { - addr.Af = ip_types.ADDRESS_IP4 - var ip4addr vpp_ip.IP4Address - copy(ip4addr[:], dstNetwork.IP.To4()) - addr.Un.SetIP4(ip4addr) - } - mask, _ := dstNetwork.Mask.Size() - return vpp_ip.Prefix{ - Address: addr, - Len: uint8(mask), - } -} - -func uintToBool(value uint8) bool { - if value == 0 { - return false - } - return true -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_dump.go deleted file mode 100644 index 5f9e265c4f..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_dump.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "strings" - - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -// DumpVrfTables dumps all configured VRF tables. -func (h *VrfTableHandler) DumpVrfTables() (tables []*l3.VrfTable, err error) { - // dump IPv4 VRF tables - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ip.IPTableDump{}) - for { - fibDetails := &vpp_ip.IPTableDetails{} - stop, err := reqCtx.ReceiveReply(fibDetails) - if stop { - break - } - if err != nil { - return nil, err - } - tables = append(tables, &l3.VrfTable{ - Id: fibDetails.Table.TableID, - Protocol: getTableProto(fibDetails.Table.IsIP6), - Label: strings.Trim(fibDetails.Table.Name, "\x00"), - }) - } - - return tables, nil -} - -func getTableProto(isIPv6 bool) l3.VrfTable_Protocol { - if isIPv6 { - return l3.VrfTable_IPV6 - } - return l3.VrfTable_IPV4 -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_dump_test.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_dump_test.go deleted file mode 100644 index 72a9079f2e..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_dump_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - vpp_vpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -func TestDumpVrfTables(t *testing.T) { - ctx := vppmock.SetupTestCtx(t) - defer ctx.TeardownTestCtx() - vthandler := NewVrfTableVppHandler(ctx.MockChannel, logrus.DefaultLogger()) - - ctx.MockVpp.MockReply( - &vpp_ip.IPTableDetails{ - Table: vpp_ip.IPTable{ - TableID: 1, - Name: "table3", - IsIP6: false, - }, - }, - &vpp_ip.IPTableDetails{ - Table: vpp_ip.IPTable{ - TableID: 2, - Name: "table3", - IsIP6: false, - }, - }, - &vpp_ip.IPTableDetails{ - Table: vpp_ip.IPTable{ - TableID: 3, - Name: "table2", - IsIP6: true, - }, - }, - ) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - ctx.MockVpp.MockReply( - &vpp_ip.IPRouteDetails{ - Route: vpp_ip.IPRoute{ - TableID: 2, - Paths: []vpp_ip.FibPath{{SwIfIndex: 5}}, - }, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - vrfTables, err := vthandler.DumpVrfTables() - Expect(err).To(Succeed()) - Expect(vrfTables).To(HaveLen(3)) - if vrfTables[0].Label == "table2" { - Expect(vrfTables[1]).To(Equal(&l3.VrfTable{Id: 3, Protocol: l3.VrfTable_IPV4, Label: "table3"})) - Expect(vrfTables[0]).To(Equal(&l3.VrfTable{Id: 2, Protocol: l3.VrfTable_IPV4, Label: "table2"})) - } else { - Expect(vrfTables[0]).To(Equal(&l3.VrfTable{Id: 1, Protocol: l3.VrfTable_IPV4, Label: "table3"})) - Expect(vrfTables[1]).To(Equal(&l3.VrfTable{Id: 2, Protocol: l3.VrfTable_IPV4, Label: "table3"})) - } - Expect(vrfTables[2]).To(Equal(&l3.VrfTable{Id: 3, Protocol: l3.VrfTable_IPV6, Label: "table2"})) -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_vppcalls.go deleted file mode 100644 index ab6bb82633..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_vppcalls.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -// AddVrfTable adds new VRF table. -func (h *VrfTableHandler) AddVrfTable(table *l3.VrfTable) error { - return h.addDelVrfTable(table, true) -} - -// DelVrfTable deletes existing VRF table. -func (h *VrfTableHandler) DelVrfTable(table *l3.VrfTable) error { - return h.addDelVrfTable(table, false) -} - -func (h *VrfTableHandler) addDelVrfTable(table *l3.VrfTable, isAdd bool) error { - req := &vpp_ip.IPTableAddDel{ - Table: vpp_ip.IPTable{ - TableID: table.Id, - IsIP6: table.GetProtocol() == l3.VrfTable_IPV6, - Name: table.Label, - }, - IsAdd: isAdd, - } - reply := &vpp_ip.IPTableAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// SetVrfFlowHashSettings sets IP flow hash settings for a VRF table. -func (h *VrfTableHandler) SetVrfFlowHashSettings(vrfID uint32, isIPv6 bool, hashFields *l3.VrfTable_FlowHashSettings) error { - req := &vpp_ip.SetIPFlowHash{ - VrfID: vrfID, - IsIPv6: isIPv6, - Src: hashFields.UseSrcIp, - Dst: hashFields.UseDstIp, - Sport: hashFields.UseSrcPort, - Dport: hashFields.UseDstPort, - Proto: hashFields.UseProtocol, - Reverse: hashFields.Reverse, - Symmetric: hashFields.Symmetric, - } - reply := &vpp_ip.SetIPFlowHashReply{} - - err := h.callsChannel.SendRequest(req).ReceiveReply(reply) - return err -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_vppcalls_test.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_vppcalls_test.go deleted file mode 100644 index d061ff9dc7..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrf_vppcalls_test.go +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -var vrfTables = []*l3.VrfTable{ - { - Id: 1, - Protocol: l3.VrfTable_IPV4, - Label: "table1", - }, - { - Id: 1, - Protocol: l3.VrfTable_IPV6, - Label: "table1", - }, - { - Id: 2, - Protocol: l3.VrfTable_IPV6, - Label: "table2", - }, -} - -// Test adding routes -func TestAddVrfTable(t *testing.T) { - ctx, vtHandler := vrfTableTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{}) - err := vtHandler.AddVrfTable(vrfTables[0]) - Expect(err).To(Succeed()) - - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPTableAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.Table.IsIP6).To(BeFalse()) - Expect(vppMsg.IsAdd).To(BeTrue()) - Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{}) - err = vtHandler.AddVrfTable(vrfTables[1]) - Expect(err).To(Succeed()) - - vppMsg, ok = ctx.MockChannel.Msg.(*vpp_ip.IPTableAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.Table.IsIP6).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeTrue()) - Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{}) - err = vtHandler.AddVrfTable(vrfTables[2]) - Expect(err).To(Succeed()) - - vppMsg, ok = ctx.MockChannel.Msg.(*vpp_ip.IPTableAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Table.TableID).To(BeEquivalentTo(2)) - Expect(vppMsg.Table.IsIP6).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeTrue()) - Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table2"))) - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{Retval: 1}) - err = vtHandler.AddVrfTable(vrfTables[0]) - Expect(err).To(Not(BeNil())) -} - -// Test deleting routes -func TestDeleteVrfTable(t *testing.T) { - ctx, vtHandler := vrfTableTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{}) - err := vtHandler.DelVrfTable(vrfTables[0]) - Expect(err).To(Succeed()) - - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPTableAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.Table.IsIP6).To(BeFalse()) - Expect(vppMsg.IsAdd).To(BeFalse()) - Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{}) - err = vtHandler.DelVrfTable(vrfTables[1]) - Expect(err).To(Succeed()) - - vppMsg, ok = ctx.MockChannel.Msg.(*vpp_ip.IPTableAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Table.TableID).To(BeEquivalentTo(1)) - Expect(vppMsg.Table.IsIP6).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeFalse()) - Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table1"))) - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{}) - err = vtHandler.DelVrfTable(vrfTables[2]) - Expect(err).To(Succeed()) - - vppMsg, ok = ctx.MockChannel.Msg.(*vpp_ip.IPTableAddDel) - Expect(ok).To(BeTrue()) - Expect(vppMsg.Table.TableID).To(BeEquivalentTo(2)) - Expect(vppMsg.Table.IsIP6).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeFalse()) - Expect(vppMsg.Table.Name).To(BeEquivalentTo([]byte("table2"))) - - ctx.MockVpp.MockReply(&vpp_ip.IPTableAddDelReply{Retval: 1}) - err = vtHandler.DelVrfTable(vrfTables[0]) - Expect(err).To(Not(BeNil())) -} - -// Test VRF flow hash settings -func TestVrfFlowHashSettings(t *testing.T) { - ctx, vtHandler := vrfTableTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.SetIPFlowHashReply{}) - err := vtHandler.SetVrfFlowHashSettings(5, true, - &l3.VrfTable_FlowHashSettings{ - UseSrcIp: true, - UseSrcPort: true, - Symmetric: true, - }) - Expect(err).To(Succeed()) - - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.SetIPFlowHash) - Expect(ok).To(BeTrue()) - Expect(vppMsg.VrfID).To(BeEquivalentTo(5)) - Expect(vppMsg.IsIPv6).To(BeTrue()) - Expect(vppMsg.Src).To(BeTrue()) - Expect(vppMsg.Dst).To(BeFalse()) - Expect(vppMsg.Sport).To(BeTrue()) - Expect(vppMsg.Dport).To(BeFalse()) - Expect(vppMsg.Proto).To(BeFalse()) - Expect(vppMsg.Symmetric).To(BeTrue()) - Expect(vppMsg.Reverse).To(BeFalse()) -} - -func vrfTableTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.VrfTableVppAPI) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - vtHandler := vpp2001.NewVrfTableVppHandler(ctx.MockChannel, log) - return ctx, vtHandler -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrrp_dump.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/vrrp_dump.go deleted file mode 100644 index c611e5f1fa..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrrp_dump.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" -) - -// DumpVrrpEntries implements VRRP handler (not supported in VPP 20.01). -func (h *VrrpVppHandler) DumpVrrpEntries() (entries []*vppcalls.VrrpDetails, err error) { - err = fmt.Errorf("%w in VPP 20.01", vppcalls.ErrVRRPUnsupported) - return -} diff --git a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrrp_vppcalls.go b/plugins/vpp/l3plugin/vppcalls/vpp2001/vrrp_vppcalls.go deleted file mode 100644 index 1aed7b1b94..0000000000 --- a/plugins/vpp/l3plugin/vppcalls/vpp2001/vrrp_vppcalls.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/l3plugin/vppcalls" - l3 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l3" -) - -// VppAddVrrp implements VRRP handler (not supported in VPP 20.01). -func (h *VrrpVppHandler) VppAddVrrp(entry *l3.VRRPEntry) error { - return fmt.Errorf("%w in VPP 20.01", vppcalls.ErrVRRPUnsupported) -} - -// VppDelVrrp implements VRRP handler (not supported in VPP 20.01). -func (h *VrrpVppHandler) VppDelVrrp(entry *l3.VRRPEntry) error { - return fmt.Errorf("%w in VPP 20.01", vppcalls.ErrVRRPUnsupported) -} - -// VppStartVrrp implements VRRP handler. -func (h *VrrpVppHandler) VppStartVrrp(entry *l3.VRRPEntry) error { - return fmt.Errorf("%w in VPP 20.01", vppcalls.ErrVRRPUnsupported) -} - -// VppStopVrrp implements VRRP handler. -func (h *VrrpVppHandler) VppStopVrrp(entry *l3.VRRPEntry) error { - return fmt.Errorf("%w in VPP 20.01", vppcalls.ErrVRRPUnsupported) -} diff --git a/plugins/vpp/natplugin/natplugin.go b/plugins/vpp/natplugin/natplugin.go index fc53ecd3cd..2c568fd0ad 100644 --- a/plugins/vpp/natplugin/natplugin.go +++ b/plugins/vpp/natplugin/natplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/descriptor" "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/natplugin/vppcalls/vpp2001/dump_nat_vppcalls.go b/plugins/vpp/natplugin/vppcalls/vpp2001/dump_nat_vppcalls.go deleted file mode 100644 index 9222cd6d1c..0000000000 --- a/plugins/vpp/natplugin/vppcalls/vpp2001/dump_nat_vppcalls.go +++ /dev/null @@ -1,706 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - "sort" - "strings" - - "github.com/golang/protobuf/proto" - - vpp_nat "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/nat" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" - nat "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat" -) - -// DNATs sorted by tags -type dnatMap map[string]*nat.DNat44 - -// static mappings sorted by tags -type stMappingMap map[string][]*nat.DNat44_StaticMapping - -// identity mappings sorted by tags -type idMappingMap map[string][]*nat.DNat44_IdentityMapping - -// WithLegacyStartupConf returns true if the loaded VPP NAT plugin is still using -// the legacy startup NAT configuration (this is the case for VPP <= 20.09). -func (h *NatVppHandler) WithLegacyStartupConf() bool { - return true -} - -func (h *NatVppHandler) DefaultNat44GlobalConfig() *nat.Nat44Global { - return &nat.Nat44Global{ - Forwarding: false, - EndpointIndependent: true, - NatInterfaces: nil, - AddressPool: nil, - VirtualReassembly: nil, // VirtualReassembly is not part of NAT API in VPP 20.01+ anymore - } -} - -// Nat44GlobalConfigDump dumps global NAT44 config in NB format. -func (h *NatVppHandler) Nat44GlobalConfigDump(dumpDeprecated bool) (cfg *nat.Nat44Global, err error) { - cfg = &nat.Nat44Global{} - cfg.Forwarding, err = h.isNat44ForwardingEnabled() - if err != nil { - return nil, err - } - cfg.VirtualReassembly, _, err = h.virtualReassemblyDump() - if err != nil { - return nil, err - } - if dumpDeprecated { - cfg.NatInterfaces, err = h.nat44InterfaceDump() - if err != nil { - return nil, err - } - cfg.AddressPool, err = h.nat44AddressDump() - if err != nil { - return nil, err - } - } - return -} - -// DNat44Dump dumps all configured DNAT-44 configurations ordered by label. -func (h *NatVppHandler) DNat44Dump() (dnats []*nat.DNat44, err error) { - dnatMap := make(dnatMap) - - // Static mappings - natStMappings, err := h.nat44StaticMappingDump() - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 static mappings: %v", err) - } - for label, mappings := range natStMappings { - dnat := getOrCreateDNAT(dnatMap, label) - dnat.StMappings = append(dnat.StMappings, mappings...) - } - - // Static mappings with load balancer - natStLbMappings, err := h.nat44StaticMappingLbDump() - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 static mappings with load balancer: %v", err) - } - for label, mappings := range natStLbMappings { - dnat := getOrCreateDNAT(dnatMap, label) - dnat.StMappings = append(dnat.StMappings, mappings...) - } - - // Identity mappings - natIDMappings, err := h.nat44IdentityMappingDump() - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 identity mappings: %v", err) - } - for label, mappings := range natIDMappings { - dnat := getOrCreateDNAT(dnatMap, label) - dnat.IdMappings = append(dnat.IdMappings, mappings...) - } - - // Convert map of DNAT configurations into a list. - for _, dnat := range dnatMap { - dnats = append(dnats, dnat) - } - - // sort to simplify testing - sort.Slice(dnats, func(i, j int) bool { return dnats[i].Label < dnats[j].Label }) - - return dnats, nil -} - -// Nat44InterfacesDump dumps NAT44 config of all NAT44-enabled interfaces. -func (h *NatVppHandler) Nat44InterfacesDump() (natIfs []*nat.Nat44Interface, err error) { - - // dump NAT interfaces without output feature enabled - req1 := &vpp_nat.Nat44InterfaceDump{} - reqContext := h.callsChannel.SendMultiRequest(req1) - for { - msg := &vpp_nat.Nat44InterfaceDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 interface: %v", err) - } - if stop { - break - } - ifName, _, found := h.ifIndexes.LookupBySwIfIndex(uint32(msg.SwIfIndex)) - if !found { - h.log.Warnf("Interface with index %d not found in the mapping", msg.SwIfIndex) - continue - } - flags := getNat44Flags(msg.Flags) - natIf := &nat.Nat44Interface{ - Name: ifName, - NatInside: flags.isInside, - NatOutside: flags.isOutside, - OutputFeature: false, - } - natIfs = append(natIfs, natIf) - } - - // dump interfaces with output feature enabled - req2 := &vpp_nat.Nat44InterfaceOutputFeatureDump{} - reqContext = h.callsChannel.SendMultiRequest(req2) - for { - msg := &vpp_nat.Nat44InterfaceOutputFeatureDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 interface output feature: %v", err) - } - if stop { - break - } - ifName, _, found := h.ifIndexes.LookupBySwIfIndex(uint32(msg.SwIfIndex)) - if !found { - h.log.Warnf("Interface with index %d not found in the mapping", msg.SwIfIndex) - continue - } - flags := getNat44Flags(msg.Flags) - natIf := &nat.Nat44Interface{ - Name: ifName, - NatInside: flags.isInside, - NatOutside: flags.isOutside, - OutputFeature: true, - } - if !natIf.NatInside && !natIf.NatOutside { - natIf.NatOutside = true - } - natIfs = append(natIfs, natIf) - } - return -} - -// Nat44AddressPoolsDump dumps all configured NAT44 address pools. -func (h *NatVppHandler) Nat44AddressPoolsDump() (natPools []*nat.Nat44AddressPool, err error) { - var curPool *nat.Nat44AddressPool - var lastIP net.IP - - req := &vpp_nat.Nat44AddressDump{} - reqContext := h.callsChannel.SendMultiRequest(req) - - for { - msg := &vpp_nat.Nat44AddressDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 Address pool: %v", err) - } - if stop { - break - } - ip := net.IP(msg.IPAddress[:]) - isTwiceNat := getNat44Flags(msg.Flags).isTwiceNat - // merge subsequent IPs into a single pool - if curPool != nil && curPool.VrfId == msg.VrfID && curPool.TwiceNat == isTwiceNat && ip.Equal(incIP(lastIP)) { - // update current pool - curPool.LastIp = ip.String() - } else { - // start a new pool - pool := &nat.Nat44AddressPool{ - FirstIp: ip.String(), - VrfId: msg.VrfID, - TwiceNat: isTwiceNat, - } - curPool = pool - natPools = append(natPools, pool) - } - lastIP = ip - } - return -} - -// nat44AddressDump returns NAT44 address pool configured in the VPP. -// Deprecated. Functionality moved to Nat44AddressPoolsDump. Kept for backward compatibility. -func (h *NatVppHandler) nat44AddressDump() (addressPool []*nat.Nat44Global_Address, err error) { - req := &vpp_nat.Nat44AddressDump{} - reqContext := h.callsChannel.SendMultiRequest(req) - - for { - msg := &vpp_nat.Nat44AddressDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 Address pool: %v", err) - } - if stop { - break - } - - addressPool = append(addressPool, &nat.Nat44Global_Address{ - Address: net.IP(msg.IPAddress[:]).String(), - VrfId: msg.VrfID, - TwiceNat: getNat44Flags(msg.Flags).isTwiceNat, - }) - } - - return -} - -// virtualReassemblyDump returns current NAT virtual-reassembly configuration. -func (h *NatVppHandler) virtualReassemblyDump() (vrIPv4 *nat.VirtualReassembly, vrIPv6 *nat.VirtualReassembly, err error) { - /*ipv4vr, err := h.ip.IPReassemblyGet(context.TODO(), &vpp_ip.IPReassemblyGet{IsIP6: false}) - if err != nil { - return nil, nil, fmt.Errorf("getting virtual reassembly IPv4 config failed: %w", err) - } - h.log.Debugf("IP Reassembly config IPv4: %+v\n", ipv4vr) - ipv6vr, err := h.ip.IPReassemblyGet(context.TODO(), &vpp_ip.IPReassemblyGet{IsIP6: true}) - if err != nil { - return nil, nil, fmt.Errorf("getting virtual reassembly IPv6 config failed: %w", err) - } - h.log.Debugf("IP Reassembly config IPv6: %+v\n", ipv6vr)*/ - - // Virtual Reassembly has been removed from NAT API in VPP (moved to IP API) - // TODO: define IPReassembly model in L3 plugin - return nil, nil, nil - /*vrIPv4 = &nat.VirtualReassembly{ - Timeout: reply.IP4Timeout, - MaxReassemblies: uint32(reply.IP4MaxReass), - MaxFragments: uint32(reply.IP4MaxFrag), - DropFragments: uintToBool(reply.IP4DropFrag), - } - vrIPv6 = &nat.VirtualReassembly{ - Timeout: reply.IP6Timeout, - MaxReassemblies: uint32(reply.IP6MaxReass), - MaxFragments: uint32(reply.IP6MaxFrag), - DropFragments: uintToBool(reply.IP6DropFrag), - } - return*/ -} - -// nat44StaticMappingDump returns a map of NAT44 static mappings sorted by tags -func (h *NatVppHandler) nat44StaticMappingDump() (entries stMappingMap, err error) { - entries = make(stMappingMap) - childMappings := make(stMappingMap) - req := &vpp_nat.Nat44StaticMappingDump{} - reqContext := h.callsChannel.SendMultiRequest(req) - - for { - msg := &vpp_nat.Nat44StaticMappingDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 static mapping: %v", err) - } - if stop { - break - } - lcIPAddress := net.IP(msg.LocalIPAddress[:]).String() - exIPAddress := net.IP(msg.ExternalIPAddress[:]).String() - - // Parse tag (DNAT label) - tag := strings.TrimRight(msg.Tag, "\x00") - if _, hasTag := entries[tag]; !hasTag { - entries[tag] = []*nat.DNat44_StaticMapping{} - childMappings[tag] = []*nat.DNat44_StaticMapping{} - } - - // resolve interface name - var ( - found bool - extIfaceName string - extIfaceMeta *ifaceidx.IfaceMetadata - ) - if msg.ExternalSwIfIndex != NoInterface { - extIfaceName, extIfaceMeta, found = h.ifIndexes.LookupBySwIfIndex(uint32(msg.ExternalSwIfIndex)) - if !found { - h.log.Warnf("Interface with index %v not found in the mapping", msg.ExternalSwIfIndex) - continue - } - } - - flags := getNat44Flags(msg.Flags) - - // Add mapping into the map. - mapping := &nat.DNat44_StaticMapping{ - ExternalInterface: extIfaceName, - ExternalIp: exIPAddress, - ExternalPort: uint32(msg.ExternalPort), - LocalIps: []*nat.DNat44_StaticMapping_LocalIP{ // single-value - { - VrfId: msg.VrfID, - LocalIp: lcIPAddress, - LocalPort: uint32(msg.LocalPort), - }, - }, - Protocol: h.protocolNumberToNBValue(msg.Protocol), - TwiceNat: h.getTwiceNatMode(flags.isTwiceNat, flags.isSelfTwiceNat), - // if there is only one backend the affinity can not be set - SessionAffinity: 0, - } - entries[tag] = append(entries[tag], mapping) - - if msg.ExternalSwIfIndex != NoInterface { - // collect auto-generated "child" mappings (interface replaced with every assigned IP address) - for _, ipAddr := range h.getInterfaceIPAddresses(extIfaceName, extIfaceMeta) { - childMapping := proto.Clone(mapping).(*nat.DNat44_StaticMapping) - childMapping.ExternalIp = ipAddr - childMapping.ExternalInterface = "" - childMappings[tag] = append(childMappings[tag], childMapping) - } - } - } - - // do not dump auto-generated child mappings - for tag, mappings := range entries { - var filtered []*nat.DNat44_StaticMapping - for _, mapping := range mappings { - isChild := false - for _, child := range childMappings[tag] { - if proto.Equal(mapping, child) { - isChild = true - break - } - } - if !isChild { - filtered = append(filtered, mapping) - } - } - entries[tag] = filtered - } - return entries, nil -} - -// nat44StaticMappingLbDump returns a map of NAT44 static mapping with load balancing sorted by tags. -func (h *NatVppHandler) nat44StaticMappingLbDump() (entries stMappingMap, err error) { - entries = make(stMappingMap) - req := &vpp_nat.Nat44LbStaticMappingDump{} - reqContext := h.callsChannel.SendMultiRequest(req) - - for { - msg := &vpp_nat.Nat44LbStaticMappingDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 lb-static mapping: %v", err) - } - if stop { - break - } - - // Parse tag (DNAT label) - tag := strings.TrimRight(msg.Tag, "\x00") - if _, hasTag := entries[tag]; !hasTag { - entries[tag] = []*nat.DNat44_StaticMapping{} - } - - // Prepare localIPs - var locals []*nat.DNat44_StaticMapping_LocalIP - for _, localIPVal := range msg.Locals { - locals = append(locals, &nat.DNat44_StaticMapping_LocalIP{ - VrfId: localIPVal.VrfID, - LocalIp: net.IP(localIPVal.Addr[:]).String(), - LocalPort: uint32(localIPVal.Port), - Probability: uint32(localIPVal.Probability), - }) - } - exIPAddress := net.IP(msg.ExternalAddr[:]).String() - - flags := getNat44Flags(msg.Flags) - - // Add mapping into the map. - mapping := &nat.DNat44_StaticMapping{ - ExternalIp: exIPAddress, - ExternalPort: uint32(msg.ExternalPort), - LocalIps: locals, - Protocol: h.protocolNumberToNBValue(msg.Protocol), - TwiceNat: h.getTwiceNatMode(flags.isTwiceNat, flags.isSelfTwiceNat), - SessionAffinity: msg.Affinity, - } - entries[tag] = append(entries[tag], mapping) - } - - return entries, nil -} - -// nat44IdentityMappingDump returns a map of NAT44 identity mappings sorted by tags. -func (h *NatVppHandler) nat44IdentityMappingDump() (entries idMappingMap, err error) { - entries = make(idMappingMap) - childMappings := make(idMappingMap) - req := &vpp_nat.Nat44IdentityMappingDump{} - reqContext := h.callsChannel.SendMultiRequest(req) - - for { - msg := &vpp_nat.Nat44IdentityMappingDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 identity mapping: %v", err) - } - if stop { - break - } - - // Parse tag (DNAT label) - tag := strings.TrimRight(msg.Tag, "\x00") - if _, hasTag := entries[tag]; !hasTag { - entries[tag] = []*nat.DNat44_IdentityMapping{} - childMappings[tag] = []*nat.DNat44_IdentityMapping{} - } - - // resolve interface name - var ( - found bool - ifaceName string - ifaceMeta *ifaceidx.IfaceMetadata - ) - if msg.SwIfIndex != NoInterface { - ifaceName, ifaceMeta, found = h.ifIndexes.LookupBySwIfIndex(uint32(msg.SwIfIndex)) - if !found { - h.log.Warnf("Interface with index %v not found in the mapping", msg.SwIfIndex) - continue - } - } - - // Add mapping into the map. - mapping := &nat.DNat44_IdentityMapping{ - IpAddress: net.IP(msg.IPAddress[:]).String(), - VrfId: msg.VrfID, - Interface: ifaceName, - Port: uint32(msg.Port), - Protocol: h.protocolNumberToNBValue(msg.Protocol), - } - entries[tag] = append(entries[tag], mapping) - - if msg.SwIfIndex != NoInterface { - // collect auto-generated "child" mappings (interface replaced with every assigned IP address) - for _, ipAddr := range h.getInterfaceIPAddresses(ifaceName, ifaceMeta) { - childMapping := proto.Clone(mapping).(*nat.DNat44_IdentityMapping) - childMapping.IpAddress = ipAddr - childMapping.Interface = "" - childMappings[tag] = append(childMappings[tag], childMapping) - } - } - } - - // do not dump auto-generated child mappings - for tag, mappings := range entries { - var filtered []*nat.DNat44_IdentityMapping - for _, mapping := range mappings { - isChild := false - for _, child := range childMappings[tag] { - if proto.Equal(mapping, child) { - isChild = true - break - } - } - if !isChild { - filtered = append(filtered, mapping) - } - } - entries[tag] = filtered - } - - return entries, nil -} - -// nat44InterfaceDump dumps NAT44 interface features. -// Deprecated. Functionality moved to Nat44Nat44InterfacesDump. Kept for backward compatibility. -func (h *NatVppHandler) nat44InterfaceDump() (interfaces []*nat.Nat44Global_Interface, err error) { - - /* dump non-Output interfaces first */ - req1 := &vpp_nat.Nat44InterfaceDump{} - reqContext := h.callsChannel.SendMultiRequest(req1) - - for { - msg := &vpp_nat.Nat44InterfaceDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 interface: %v", err) - } - if stop { - break - } - - // Find interface name - ifName, _, found := h.ifIndexes.LookupBySwIfIndex(uint32(msg.SwIfIndex)) - if !found { - h.log.Warnf("Interface with index %d not found in the mapping", msg.SwIfIndex) - continue - } - - flags := getNat44Flags(msg.Flags) - - if flags.isInside { - interfaces = append(interfaces, &nat.Nat44Global_Interface{ - Name: ifName, - IsInside: true, - }) - } else { - interfaces = append(interfaces, &nat.Nat44Global_Interface{ - Name: ifName, - IsInside: false, - }) - } - } - - /* dump Output interfaces next */ - req2 := &vpp_nat.Nat44InterfaceOutputFeatureDump{} - reqContext = h.callsChannel.SendMultiRequest(req2) - - for { - msg := &vpp_nat.Nat44InterfaceOutputFeatureDetails{} - stop, err := reqContext.ReceiveReply(msg) - if err != nil { - return nil, fmt.Errorf("failed to dump NAT44 interface output feature: %v", err) - } - if stop { - break - } - - // Find interface name - ifName, _, found := h.ifIndexes.LookupBySwIfIndex(uint32(msg.SwIfIndex)) - if !found { - h.log.Warnf("Interface with index %d not found in the mapping", msg.SwIfIndex) - continue - } - - flags := getNat44Flags(msg.Flags) - - interfaces = append(interfaces, &nat.Nat44Global_Interface{ - Name: ifName, - IsInside: flags.isInside, - OutputFeature: true, - }) - } - - return interfaces, nil -} - -// Nat44IsForwardingEnabled checks if the NAT44 forwarding is enabled. -func (h *NatVppHandler) isNat44ForwardingEnabled() (isEnabled bool, err error) { - req := &vpp_nat.Nat44ForwardingIsEnabled{} - - reply := &vpp_nat.Nat44ForwardingIsEnabledReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return false, fmt.Errorf("failed to dump NAT44 forwarding: %v", err) - } - - isEnabled = reply.Enabled - return isEnabled, nil -} - -func (h *NatVppHandler) getInterfaceIPAddresses(ifaceName string, ifaceMeta *ifaceidx.IfaceMetadata) (ipAddrs []string) { - ipAddrNets := ifaceMeta.IPAddresses - dhcpLease, hasDHCPLease := h.dhcpIndex.GetValue(ifaceName) - if hasDHCPLease { - lease := dhcpLease.(*ifs.DHCPLease) - ipAddrNets = append(ipAddrNets, lease.HostIpAddress) - } - for _, ipAddrNet := range ipAddrNets { - ipAddr := strings.Split(ipAddrNet, "/")[0] - ipAddrs = append(ipAddrs, ipAddr) - } - return ipAddrs -} - -// protocolNumberToNBValue converts protocol numeric representation into the corresponding enum -// enum value from the NB model. -func (h *NatVppHandler) protocolNumberToNBValue(protocol uint8) (proto nat.DNat44_Protocol) { - switch protocol { - case TCP: - return nat.DNat44_TCP - case UDP: - return nat.DNat44_UDP - case ICMP: - return nat.DNat44_ICMP - default: - h.log.Warnf("Unknown protocol %v", protocol) - return 0 - } -} - -// protocolNBValueToNumber converts protocol enum value from the NB model into the -// corresponding numeric representation. -func (h *NatVppHandler) protocolNBValueToNumber(protocol nat.DNat44_Protocol) (proto uint8) { - switch protocol { - case nat.DNat44_TCP: - return TCP - case nat.DNat44_UDP: - return UDP - case nat.DNat44_ICMP: - return ICMP - default: - h.log.Warnf("Unknown protocol %v, defaulting to TCP", protocol) - return TCP - } -} - -func (h *NatVppHandler) getTwiceNatMode(twiceNat, selfTwiceNat bool) nat.DNat44_StaticMapping_TwiceNatMode { - if twiceNat { - if selfTwiceNat { - h.log.Warnf("Both TwiceNAT and self-TwiceNAT are enabled") - return 0 - } - return nat.DNat44_StaticMapping_ENABLED - } - if selfTwiceNat { - return nat.DNat44_StaticMapping_SELF - } - return nat.DNat44_StaticMapping_DISABLED -} - -func getOrCreateDNAT(dnats dnatMap, label string) *nat.DNat44 { - if _, created := dnats[label]; !created { - dnats[label] = &nat.DNat44{Label: label} - } - return dnats[label] -} - -func getNat44Flags(flags vpp_nat.NatConfigFlags) *nat44Flags { - natFlags := &nat44Flags{} - if flags&vpp_nat.NAT_IS_EXT_HOST_VALID != 0 { - natFlags.isExtHostValid = true - } - if flags&vpp_nat.NAT_IS_STATIC != 0 { - natFlags.isStatic = true - } - if flags&vpp_nat.NAT_IS_INSIDE != 0 { - natFlags.isInside = true - } - if flags&vpp_nat.NAT_IS_OUTSIDE != 0 { - natFlags.isOutside = true - } - if flags&vpp_nat.NAT_IS_ADDR_ONLY != 0 { - natFlags.isAddrOnly = true - } - if flags&vpp_nat.NAT_IS_OUT2IN_ONLY != 0 { - natFlags.isOut2In = true - } - if flags&vpp_nat.NAT_IS_SELF_TWICE_NAT != 0 { - natFlags.isSelfTwiceNat = true - } - if flags&vpp_nat.NAT_IS_TWICE_NAT != 0 { - natFlags.isTwiceNat = true - } - return natFlags -} - -func uintToBool(value uint8) bool { - if value == 0 { - return false - } - return true -} - -// incIP increments IP address and returns it. -// Based on: https://play.golang.org/p/m8TNTtygK0 -func incIP(ip net.IP) net.IP { - retIP := make(net.IP, len(ip)) - copy(retIP, ip) - for j := len(retIP) - 1; j >= 0; j-- { - retIP[j]++ - if retIP[j] > 0 { - break - } - } - return retIP -} diff --git a/plugins/vpp/natplugin/vppcalls/vpp2001/dump_nat_vppcalls_test.go b/plugins/vpp/natplugin/vppcalls/vpp2001/dump_nat_vppcalls_test.go deleted file mode 100644 index 425d1009dd..0000000000 --- a/plugins/vpp/natplugin/vppcalls/vpp2001/dump_nat_vppcalls_test.go +++ /dev/null @@ -1,467 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "net" - "testing" - - . "github.com/onsi/gomega" - - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" - nat "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat" - - "go.ligato.io/cn-infra/v2/idxmap" - idxmap_mem "go.ligato.io/cn-infra/v2/idxmap/mem" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_nat "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/nat" - vpp_vpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" -) - -func TestNat44GlobalConfigDump(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - // forwarding - ctx.MockVpp.MockReply(&vpp_nat.Nat44ForwardingIsEnabledReply{ - Enabled: true, - }) - - // virtual reassembly - /*ctx.MockVpp.MockReply(&vpp_nat.NatGetReassReply{ - // IPv4 - IP4Timeout: 10, - IP4MaxReass: 5, - IP4MaxFrag: 7, - IP4DropFrag: 1, - // IPv6 - IP6Timeout: 20, - IP6MaxReass: 8, - IP6MaxFrag: 13, - IP6DropFrag: 0,* - })*/ - - // non-output interfaces - ctx.MockVpp.MockReply( - &vpp_nat.Nat44InterfaceDetails{ - SwIfIndex: 1, - }, - &vpp_nat.Nat44InterfaceDetails{ - SwIfIndex: 2, - Flags: vpp_nat.NAT_IS_INSIDE, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - // output interfaces - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceOutputFeatureDetails{ - SwIfIndex: 3, - Flags: vpp_nat.NAT_IS_INSIDE, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - // address pool - ctx.MockVpp.MockReply( - &vpp_nat.Nat44AddressDetails{ - IPAddress: ipTo4Address("192.168.10.1"), - Flags: vpp_nat.NAT_IS_TWICE_NAT, - VrfID: 1, - }, - &vpp_nat.Nat44AddressDetails{ - IPAddress: ipTo4Address("192.168.10.2"), - VrfID: 2, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - swIfIndexes.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 3}) - - globalCfg, err := natHandler.Nat44GlobalConfigDump(true) - Expect(err).To(Succeed()) - - Expect(globalCfg.Forwarding).To(BeTrue()) - - Expect(globalCfg.AddressPool).To(HaveLen(2)) - Expect(globalCfg.AddressPool[0].Address).To(Equal("192.168.10.1")) - Expect(globalCfg.AddressPool[0].TwiceNat).To(BeTrue()) - Expect(globalCfg.AddressPool[0].VrfId).To(BeEquivalentTo(1)) - Expect(globalCfg.AddressPool[1].Address).To(Equal("192.168.10.2")) - Expect(globalCfg.AddressPool[1].TwiceNat).To(BeFalse()) - Expect(globalCfg.AddressPool[1].VrfId).To(BeEquivalentTo(2)) - - Expect(globalCfg.NatInterfaces).To(HaveLen(3)) - Expect(globalCfg.NatInterfaces[0].Name).To(Equal("if0")) - Expect(globalCfg.NatInterfaces[0].IsInside).To(BeFalse()) - Expect(globalCfg.NatInterfaces[0].OutputFeature).To(BeFalse()) - Expect(globalCfg.NatInterfaces[1].Name).To(Equal("if1")) - Expect(globalCfg.NatInterfaces[1].IsInside).To(BeTrue()) - Expect(globalCfg.NatInterfaces[1].OutputFeature).To(BeFalse()) - Expect(globalCfg.NatInterfaces[2].Name).To(Equal("if2")) - Expect(globalCfg.NatInterfaces[2].IsInside).To(BeTrue()) - Expect(globalCfg.NatInterfaces[2].OutputFeature).To(BeTrue()) - - /*Expect(globalCfg.VirtualReassembly).ToNot(BeNil()) - Expect(globalCfg.VirtualReassembly.Timeout).To(BeEquivalentTo(10)) - Expect(globalCfg.VirtualReassembly.MaxReassemblies).To(BeEquivalentTo(5)) - Expect(globalCfg.VirtualReassembly.MaxFragments).To(BeEquivalentTo(7)) - Expect(globalCfg.VirtualReassembly.DropFragments).To(BeTrue())*/ -} - -func TestNat44InterfacesDump(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - // non-output interfaces - ctx.MockVpp.MockReply( - &vpp_nat.Nat44InterfaceDetails{ - SwIfIndex: 1, - Flags: vpp_nat.NAT_IS_OUTSIDE, - }, - &vpp_nat.Nat44InterfaceDetails{ - SwIfIndex: 2, - Flags: vpp_nat.NAT_IS_INSIDE, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - // output interfaces - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceOutputFeatureDetails{ - SwIfIndex: 3, - Flags: vpp_nat.NAT_IS_INSIDE | vpp_nat.NAT_IS_OUTSIDE, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - swIfIndexes.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 3}) - - interfaces, err := natHandler.Nat44InterfacesDump() - Expect(err).To(Succeed()) - - Expect(interfaces).To(HaveLen(3)) - - Expect(interfaces[0].Name).To(Equal("if0")) - Expect(interfaces[0].NatInside).To(BeFalse()) - Expect(interfaces[0].NatOutside).To(BeTrue()) - Expect(interfaces[0].OutputFeature).To(BeFalse()) - - Expect(interfaces[1].Name).To(Equal("if1")) - Expect(interfaces[1].NatInside).To(BeTrue()) - Expect(interfaces[1].NatOutside).To(BeFalse()) - Expect(interfaces[1].OutputFeature).To(BeFalse()) - - Expect(interfaces[2].Name).To(Equal("if2")) - Expect(interfaces[2].NatInside).To(BeTrue()) - Expect(interfaces[2].NatOutside).To(BeTrue()) - Expect(interfaces[2].OutputFeature).To(BeTrue()) -} - -func TestNat44AddressPoolsDump(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - // address pool - ctx.MockVpp.MockReply( - &vpp_nat.Nat44AddressDetails{ - IPAddress: ipTo4Address("192.168.10.1"), - Flags: vpp_nat.NAT_IS_TWICE_NAT, - VrfID: 1, - }, - &vpp_nat.Nat44AddressDetails{ - IPAddress: ipTo4Address("192.168.10.2"), - VrfID: 2, - }, - &vpp_nat.Nat44AddressDetails{ - IPAddress: ipTo4Address("192.168.10.3"), - VrfID: 2, - }, - &vpp_nat.Nat44AddressDetails{ - IPAddress: ipTo4Address("192.168.10.4"), - VrfID: 2, - }) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - pools, err := natHandler.Nat44AddressPoolsDump() - Expect(err).To(Succeed()) - - Expect(pools).To(HaveLen(2)) - - Expect(pools[0].FirstIp).To(Equal("192.168.10.1")) - Expect(pools[0].LastIp).To(Equal("")) - Expect(pools[0].TwiceNat).To(BeTrue()) - Expect(pools[0].VrfId).To(BeEquivalentTo(1)) - - Expect(pools[1].FirstIp).To(Equal("192.168.10.2")) - Expect(pools[1].LastIp).To(Equal("192.168.10.4")) - Expect(pools[1].TwiceNat).To(BeFalse()) - Expect(pools[1].VrfId).To(BeEquivalentTo(2)) -} - -func TestDNATDump(t *testing.T) { - ctx, natHandler, swIfIndexes, dhcpIndexes := natTestSetup(t) - defer ctx.TeardownTestCtx() - - // non-LB static mappings - ctx.MockVpp.MockReply( - &vpp_nat.Nat44StaticMappingDetails{ - LocalIPAddress: ipTo4Address("10.10.11.120"), - ExternalIPAddress: ipTo4Address("10.36.20.20"), - Protocol: 6, - LocalPort: 8080, - ExternalPort: 80, - ExternalSwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 1", - Flags: vpp_nat.NAT_IS_TWICE_NAT, - }, - &vpp_nat.Nat44StaticMappingDetails{ - LocalIPAddress: ipTo4Address("10.10.11.120"), - Protocol: 6, - LocalPort: 8080, - ExternalPort: 80, - ExternalSwIfIndex: 1, - VrfID: 1, - Tag: "DNAT 1", - Flags: vpp_nat.NAT_IS_TWICE_NAT, - }, - &vpp_nat.Nat44StaticMappingDetails{ - LocalIPAddress: ipTo4Address("10.10.11.140"), - Protocol: 6, - LocalPort: 8081, - ExternalPort: 80, - ExternalSwIfIndex: 2, - VrfID: 1, - Tag: "DNAT 2", - Flags: vpp_nat.NAT_IS_SELF_TWICE_NAT, - }, - // auto-generated mappings with interface replaced by all assigned IP addresses - &vpp_nat.Nat44StaticMappingDetails{ - LocalIPAddress: ipTo4Address("10.10.11.120"), - ExternalIPAddress: ipTo4Address("10.36.20.30"), - Protocol: 6, - LocalPort: 8080, - ExternalPort: 80, - ExternalSwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 1", - Flags: vpp_nat.NAT_IS_TWICE_NAT, - }, - &vpp_nat.Nat44StaticMappingDetails{ - LocalIPAddress: ipTo4Address("10.10.11.120"), - ExternalIPAddress: ipTo4Address("10.36.20.31"), - Protocol: 6, - LocalPort: 8080, - ExternalPort: 80, - ExternalSwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 1", - Flags: vpp_nat.NAT_IS_TWICE_NAT, - }, - &vpp_nat.Nat44StaticMappingDetails{ - LocalIPAddress: ipTo4Address("10.10.11.140"), - ExternalIPAddress: ipTo4Address("10.36.40.10"), - Protocol: 6, - LocalPort: 8081, - ExternalPort: 80, - ExternalSwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 2", - Flags: vpp_nat.NAT_IS_SELF_TWICE_NAT, - }, - &vpp_nat.Nat44StaticMappingDetails{ - LocalIPAddress: ipTo4Address("10.10.11.140"), - ExternalIPAddress: ipTo4Address("10.36.40.20"), - Protocol: 6, - LocalPort: 8081, - ExternalPort: 80, - ExternalSwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 2", - Flags: vpp_nat.NAT_IS_SELF_TWICE_NAT, - }, - ) - - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - // LB static mappings - ctx.MockVpp.MockReply(&vpp_nat.Nat44LbStaticMappingDetails{ - ExternalAddr: ipTo4Address("10.36.20.60"), - ExternalPort: 53, - Protocol: 17, - Flags: vpp_nat.NAT_IS_OUT2IN_ONLY, - Tag: "DNAT 2", - LocalNum: 2, - Locals: []vpp_nat.Nat44LbAddrPort{ - { - Addr: ipTo4Address("10.10.11.161"), - Port: 53, - Probability: 1, - VrfID: 0, - }, - { - Addr: ipTo4Address("10.10.11.162"), - Port: 153, - Probability: 2, - VrfID: 0, - }, - }, - }) - - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - // identity mappings - ctx.MockVpp.MockReply( - &vpp_nat.Nat44IdentityMappingDetails{ - Flags: vpp_nat.NAT_IS_ADDR_ONLY, - Protocol: 17, - IPAddress: ipTo4Address("10.10.11.200"), - SwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 3", - }, - &vpp_nat.Nat44IdentityMappingDetails{ - Flags: vpp_nat.NAT_IS_ADDR_ONLY, - Protocol: 17, - SwIfIndex: 2, - VrfID: 1, - Tag: "DNAT 3", - }, - // auto-generated mappings with interface replaced by all assigned IP addresses - &vpp_nat.Nat44IdentityMappingDetails{ - Flags: vpp_nat.NAT_IS_ADDR_ONLY, - Protocol: 17, - IPAddress: ipTo4Address("10.36.40.10"), - SwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 3", - }, - &vpp_nat.Nat44IdentityMappingDetails{ - Flags: vpp_nat.NAT_IS_ADDR_ONLY, - Protocol: 17, - IPAddress: ipTo4Address("10.36.40.20"), - SwIfIndex: vpp2001.NoInterface, - VrfID: 1, - Tag: "DNAT 3", - }, - ) - - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - - // interfaces and their IP addresses - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1, IPAddresses: []string{"10.36.20.30", "10.36.20.31"}}) - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2, IPAddresses: []string{"10.36.40.10"}}) - dhcpIndexes.Put("if1", &ifs.DHCPLease{InterfaceName: "if0", HostIpAddress: "10.36.40.20"}) - - dnats, err := natHandler.DNat44Dump() - Expect(err).To(Succeed()) - - Expect(dnats).To(HaveLen(3)) - - dnat := dnats[0] - Expect(dnat.Label).To(Equal("DNAT 1")) - Expect(dnat.IdMappings).To(HaveLen(0)) - Expect(dnat.StMappings).To(HaveLen(2)) - // 1st mapping - Expect(dnat.StMappings[0].TwiceNat).To(Equal(nat.DNat44_StaticMapping_ENABLED)) - Expect(dnat.StMappings[0].Protocol).To(Equal(nat.DNat44_TCP)) - Expect(dnat.StMappings[0].ExternalInterface).To(BeEmpty()) - Expect(dnat.StMappings[0].ExternalIp).To(Equal("10.36.20.20")) - Expect(dnat.StMappings[0].ExternalPort).To(BeEquivalentTo(80)) - Expect(dnat.StMappings[0].LocalIps).To(HaveLen(1)) - Expect(dnat.StMappings[0].LocalIps[0].VrfId).To(BeEquivalentTo(1)) - Expect(dnat.StMappings[0].LocalIps[0].LocalIp).To(Equal("10.10.11.120")) - Expect(dnat.StMappings[0].LocalIps[0].LocalPort).To(BeEquivalentTo(8080)) - Expect(dnat.StMappings[0].LocalIps[0].Probability).To(BeEquivalentTo(0)) - // 2nd mapping - Expect(dnat.StMappings[1].TwiceNat).To(Equal(nat.DNat44_StaticMapping_ENABLED)) - Expect(dnat.StMappings[1].Protocol).To(Equal(nat.DNat44_TCP)) - Expect(dnat.StMappings[1].ExternalInterface).To(BeEquivalentTo("if0")) - Expect(dnat.StMappings[1].ExternalIp).To(BeEquivalentTo("0.0.0.0")) - Expect(dnat.StMappings[1].ExternalPort).To(BeEquivalentTo(80)) - Expect(dnat.StMappings[1].LocalIps).To(HaveLen(1)) - Expect(dnat.StMappings[1].LocalIps[0].VrfId).To(BeEquivalentTo(1)) - Expect(dnat.StMappings[1].LocalIps[0].LocalIp).To(Equal("10.10.11.120")) - Expect(dnat.StMappings[1].LocalIps[0].LocalPort).To(BeEquivalentTo(8080)) - Expect(dnat.StMappings[1].LocalIps[0].Probability).To(BeEquivalentTo(0)) - - dnat = dnats[1] - // -> non-LB mapping - Expect(dnat.Label).To(Equal("DNAT 2")) - Expect(dnat.IdMappings).To(HaveLen(0)) - Expect(dnat.StMappings).To(HaveLen(2)) - Expect(dnat.StMappings[0].TwiceNat).To(Equal(nat.DNat44_StaticMapping_SELF)) - Expect(dnat.StMappings[0].Protocol).To(Equal(nat.DNat44_TCP)) - Expect(dnat.StMappings[0].ExternalInterface).To(Equal("if1")) - Expect(dnat.StMappings[0].ExternalIp).To(BeEquivalentTo("0.0.0.0")) - Expect(dnat.StMappings[0].ExternalPort).To(BeEquivalentTo(80)) - Expect(dnat.StMappings[0].LocalIps).To(HaveLen(1)) - Expect(dnat.StMappings[0].LocalIps[0].VrfId).To(BeEquivalentTo(1)) - Expect(dnat.StMappings[0].LocalIps[0].LocalIp).To(Equal("10.10.11.140")) - Expect(dnat.StMappings[0].LocalIps[0].LocalPort).To(BeEquivalentTo(8081)) - Expect(dnat.StMappings[0].LocalIps[0].Probability).To(BeEquivalentTo(0)) - // -> LB mapping - Expect(dnat.StMappings[1].TwiceNat).To(Equal(nat.DNat44_StaticMapping_DISABLED)) - Expect(dnat.StMappings[1].Protocol).To(Equal(nat.DNat44_UDP)) - Expect(dnat.StMappings[1].ExternalInterface).To(BeEmpty()) - Expect(dnat.StMappings[1].ExternalIp).To(Equal("10.36.20.60")) - Expect(dnat.StMappings[1].ExternalPort).To(BeEquivalentTo(53)) - Expect(dnat.StMappings[1].LocalIps).To(HaveLen(2)) - Expect(dnat.StMappings[1].LocalIps[0].VrfId).To(BeEquivalentTo(0)) - Expect(dnat.StMappings[1].LocalIps[0].LocalIp).To(Equal("10.10.11.161")) - Expect(dnat.StMappings[1].LocalIps[0].LocalPort).To(BeEquivalentTo(53)) - Expect(dnat.StMappings[1].LocalIps[0].Probability).To(BeEquivalentTo(1)) - Expect(dnat.StMappings[1].LocalIps[1].VrfId).To(BeEquivalentTo(0)) - Expect(dnat.StMappings[1].LocalIps[1].LocalIp).To(Equal("10.10.11.162")) - Expect(dnat.StMappings[1].LocalIps[1].LocalPort).To(BeEquivalentTo(153)) - Expect(dnat.StMappings[1].LocalIps[1].Probability).To(BeEquivalentTo(2)) - - dnat = dnats[2] - Expect(dnat.Label).To(Equal("DNAT 3")) - Expect(dnat.StMappings).To(HaveLen(0)) - Expect(dnat.IdMappings).To(HaveLen(2)) - // 1st mapping - Expect(dnat.IdMappings[0].VrfId).To(BeEquivalentTo(1)) - Expect(dnat.IdMappings[0].Protocol).To(Equal(nat.DNat44_UDP)) - Expect(dnat.IdMappings[0].Port).To(BeEquivalentTo(0)) - Expect(dnat.IdMappings[0].IpAddress).To(Equal("10.10.11.200")) - Expect(dnat.IdMappings[0].Interface).To(BeEmpty()) - // 2nd mapping - Expect(dnat.IdMappings[1].VrfId).To(BeEquivalentTo(1)) - Expect(dnat.IdMappings[1].Protocol).To(Equal(nat.DNat44_UDP)) - Expect(dnat.IdMappings[1].Port).To(BeEquivalentTo(0)) - Expect(dnat.IdMappings[1].IpAddress).To(BeEquivalentTo("0.0.0.0")) - Expect(dnat.IdMappings[1].Interface).To(BeEquivalentTo("if1")) -} - -func natTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.NatVppAPI, ifaceidx.IfaceMetadataIndexRW, idxmap.NamedMappingRW) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test-log") - swIfIndexes := ifaceidx.NewIfaceIndex(logrus.DefaultLogger(), "test-sw_if_indexes") - dhcpIndexes := idxmap_mem.NewNamedMapping(logrus.DefaultLogger(), "test-dhcp_indexes", nil) - natHandler := vpp2001.NewNatVppHandler(ctx.MockChannel, swIfIndexes, dhcpIndexes, log) - return ctx, natHandler, swIfIndexes, dhcpIndexes -} - -func ipTo4Address(ipStr string) (addr vpp_nat.IP4Address) { - netIP := net.ParseIP(ipStr) - if ip4 := netIP.To4(); ip4 != nil { - copy(addr[:], ip4) - } - return -} diff --git a/plugins/vpp/natplugin/vppcalls/vpp2001/nat_vppcalls.go b/plugins/vpp/natplugin/vppcalls/vpp2001/nat_vppcalls.go deleted file mode 100644 index 3d14feab97..0000000000 --- a/plugins/vpp/natplugin/vppcalls/vpp2001/nat_vppcalls.go +++ /dev/null @@ -1,487 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - "github.com/pkg/errors" - - vpp_nat "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/nat" - "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls" - nat "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat" -) - -// Num protocol representation -const ( - ICMP uint8 = 1 - TCP uint8 = 6 - UDP uint8 = 17 -) - -const ( - // NoInterface is sw-if-idx which means 'no interface' - NoInterface = vpp_nat.InterfaceIndex(^uint32(0)) - // Maximal length of tag - maxTagLen = 64 -) - -// holds a list of NAT44 flags set -type nat44Flags struct { - isTwiceNat bool - isSelfTwiceNat bool - isOut2In bool - isAddrOnly bool - isOutside bool - isInside bool - isStatic bool - isExtHostValid bool -} - -// Enable NAT44 plugin and apply the given set of options. -func (h *NatVppHandler) EnableNAT44Plugin(opts vppcalls.Nat44InitOpts) error { - return fmt.Errorf("unsupported in VPP 20.01 (use VPP startup config file)") -} - -// DisableNAT44Plugin disables NAT44 plugin. -func (h *NatVppHandler) DisableNAT44Plugin() error { - return fmt.Errorf("unsupported in VPP 20.01 (use VPP startup config file)") -} - -// SetNat44Forwarding configures NAT44 forwarding. -func (h *NatVppHandler) SetNat44Forwarding(enableFwd bool) error { - req := &vpp_nat.Nat44ForwardingEnableDisable{ - Enable: enableFwd, - } - reply := &vpp_nat.Nat44ForwardingEnableDisableReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// EnableNat44Interface enables NAT44 feature for provided interface. -func (h *NatVppHandler) EnableNat44Interface(iface string, isInside, isOutput bool) error { - if isOutput { - return h.handleNat44InterfaceOutputFeature(iface, isInside, true) - } - return h.handleNat44Interface(iface, isInside, true) -} - -// DisableNat44Interface disables NAT44 feature for provided interface. -func (h *NatVppHandler) DisableNat44Interface(iface string, isInside, isOutput bool) error { - if isOutput { - return h.handleNat44InterfaceOutputFeature(iface, isInside, false) - } - return h.handleNat44Interface(iface, isInside, false) -} - -// AddNat44AddressPool adds new IPV4 address pool into the NAT pools. -func (h *NatVppHandler) AddNat44AddressPool(vrf uint32, firstIP, lastIP string, twiceNat bool) error { - return h.handleNat44AddressPool(vrf, firstIP, lastIP, twiceNat, true) -} - -// DelNat44AddressPool removes existing IPv4 address pool from the NAT pools. -func (h *NatVppHandler) DelNat44AddressPool(vrf uint32, firstIP, lastIP string, twiceNat bool) error { - return h.handleNat44AddressPool(vrf, firstIP, lastIP, twiceNat, false) -} - -// SetVirtualReassemblyIPv4 configures NAT virtual reassembly for IPv4 packets. -func (h *NatVppHandler) SetVirtualReassemblyIPv4(vrCfg *nat.VirtualReassembly) error { - return h.handleNatVirtualReassembly(vrCfg, false) -} - -// SetVirtualReassemblyIPv6 configures NAT virtual reassembly for IPv6 packets. -func (h *NatVppHandler) SetVirtualReassemblyIPv6(vrCfg *nat.VirtualReassembly) error { - return h.handleNatVirtualReassembly(vrCfg, true) -} - -// AddNat44IdentityMapping adds new NAT44 identity mapping -func (h *NatVppHandler) AddNat44IdentityMapping(mapping *nat.DNat44_IdentityMapping, dnatLabel string) error { - return h.handleNat44IdentityMapping(mapping, dnatLabel, true) -} - -// DelNat44IdentityMapping removes existing NAT44 identity mapping -func (h *NatVppHandler) DelNat44IdentityMapping(mapping *nat.DNat44_IdentityMapping, dnatLabel string) error { - return h.handleNat44IdentityMapping(mapping, dnatLabel, false) -} - -// AddNat44StaticMapping creates new NAT44 static mapping entry. -func (h *NatVppHandler) AddNat44StaticMapping(mapping *nat.DNat44_StaticMapping, dnatLabel string) error { - if len(mapping.LocalIps) == 0 { - return errors.Errorf("cannot configure static mapping for DNAT %s: no local address provided", dnatLabel) - } - if len(mapping.LocalIps) == 1 { - return h.handleNat44StaticMapping(mapping, dnatLabel, true) - } - return h.handleNat44StaticMappingLb(mapping, dnatLabel, true) -} - -// DelNat44StaticMapping removes existing NAT44 static mapping entry. -func (h *NatVppHandler) DelNat44StaticMapping(mapping *nat.DNat44_StaticMapping, dnatLabel string) error { - if len(mapping.LocalIps) == 0 { - return errors.Errorf("cannot un-configure static mapping from DNAT %s: no local address provided", dnatLabel) - } - if len(mapping.LocalIps) == 1 { - return h.handleNat44StaticMapping(mapping, dnatLabel, false) - } - return h.handleNat44StaticMappingLb(mapping, dnatLabel, false) -} - -// Calls VPP binary API to set/unset interface NAT44 feature. -func (h *NatVppHandler) handleNat44Interface(iface string, isInside, isAdd bool) error { - // get interface metadata - ifaceMeta, found := h.ifIndexes.LookupByName(iface) - if !found { - return errors.New("failed to get interface metadata") - } - - req := &vpp_nat.Nat44InterfaceAddDelFeature{ - SwIfIndex: vpp_nat.InterfaceIndex(ifaceMeta.SwIfIndex), - Flags: setNat44Flags(&nat44Flags{isInside: isInside}), - IsAdd: isAdd, - } - reply := &vpp_nat.Nat44InterfaceAddDelFeatureReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// Calls VPP binary API to set/unset interface NAT44 output feature -func (h *NatVppHandler) handleNat44InterfaceOutputFeature(iface string, isInside, isAdd bool) error { - // get interface metadata - ifaceMeta, found := h.ifIndexes.LookupByName(iface) - if !found { - return errors.New("failed to get interface metadata") - } - - req := &vpp_nat.Nat44InterfaceAddDelOutputFeature{ - SwIfIndex: vpp_nat.InterfaceIndex(ifaceMeta.SwIfIndex), - Flags: setNat44Flags(&nat44Flags{isInside: isInside}), - IsAdd: isAdd, - } - reply := &vpp_nat.Nat44InterfaceAddDelOutputFeatureReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// Calls VPP binary API to add/remove addresses to/from the NAT44 pool. -func (h *NatVppHandler) handleNat44AddressPool(vrf uint32, firstIP, lastIP string, twiceNat, isAdd bool) error { - firstAddr, err := ipTo4Address(firstIP) - if err != nil { - return errors.Errorf("unable to parse address %s from the NAT pool: %v", firstIP, err) - } - lastAddr := firstAddr - if lastIP != "" { - lastAddr, err = ipTo4Address(lastIP) - if err != nil { - return errors.Errorf("unable to parse address %s from the NAT pool: %v", lastIP, err) - } - } - - req := &vpp_nat.Nat44AddDelAddressRange{ - FirstIPAddress: firstAddr, - LastIPAddress: lastAddr, - VrfID: vrf, - Flags: setNat44Flags(&nat44Flags{isTwiceNat: twiceNat}), - IsAdd: isAdd, - } - reply := &vpp_nat.Nat44AddDelAddressRangeReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// Calls VPP binary API to setup NAT virtual reassembly -func (h *NatVppHandler) handleNatVirtualReassembly(vrCfg *nat.VirtualReassembly, isIpv6 bool) error { - // Virtual Reassembly has been removed from NAT API in VPP (moved to IP API) - // TODO: define IPReassembly model in L3 plugin - return nil - /*req := &vpp_nat.NatSetReass{ - Timeout: vrCfg.Timeout, - MaxReass: uint16(vrCfg.MaxReassemblies), - MaxFrag: uint8(vrCfg.MaxFragments), - DropFrag: boolToUint(vrCfg.DropFragments), - IsIP6: isIpv6, - } - reply := &vpp_nat.NatSetReassReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - }*/ -} - -// Calls VPP binary API to add/remove NAT44 static mapping -func (h *NatVppHandler) handleNat44StaticMapping(mapping *nat.DNat44_StaticMapping, dnatLabel string, isAdd bool) error { - var ifIdx = NoInterface - var exIPAddr vpp_nat.IP4Address - - if mapping.TwiceNatPoolIp != "" { - h.log.Debug("DNAT44 static mapping's twiceNAT pool IP feature " + - "is unsupported in this version of VPP (use 20.09 and newer)") - } - - // check tag length limit - if err := checkTagLength(dnatLabel); err != nil { - return err - } - - // parse local endpoint - lcIPAddr, err := ipTo4Address(mapping.LocalIps[0].LocalIp) - if err != nil { - return errors.Errorf("cannot configure DNAT static mapping %s: unable to parse local IP %s: %v", - dnatLabel, mapping.LocalIps[0].LocalIp, err) - } - lcPort := uint16(mapping.LocalIps[0].LocalPort) - lcVrf := mapping.LocalIps[0].VrfId - - // Check external interface (prioritized over external IP) - if mapping.ExternalInterface != "" { - // Check external interface - ifMeta, found := h.ifIndexes.LookupByName(mapping.ExternalInterface) - if !found { - return errors.Errorf("cannot configure static mapping for DNAT %s: required external interface %s is missing", - dnatLabel, mapping.ExternalInterface) - } - ifIdx = vpp_nat.InterfaceIndex(ifMeta.SwIfIndex) - } else { - // Parse external IP address - exIPAddr, err = ipTo4Address(mapping.ExternalIp) - if err != nil { - return errors.Errorf("cannot configure static mapping for DNAT %s: unable to parse external IP %s: %v", - dnatLabel, mapping.ExternalIp, err) - } - } - - // Resolve mapping (address only or address and port) - var addrOnly bool - if lcPort == 0 || mapping.ExternalPort == 0 { - addrOnly = true - } - - req := &vpp_nat.Nat44AddDelStaticMapping{ - Tag: dnatLabel, - LocalIPAddress: lcIPAddr, - ExternalIPAddress: exIPAddr, - Protocol: h.protocolNBValueToNumber(mapping.Protocol), - ExternalSwIfIndex: ifIdx, - VrfID: lcVrf, - Flags: setNat44Flags(&nat44Flags{ - isTwiceNat: mapping.TwiceNat == nat.DNat44_StaticMapping_ENABLED, - isSelfTwiceNat: mapping.TwiceNat == nat.DNat44_StaticMapping_SELF, - isOut2In: true, - isAddrOnly: addrOnly, - }), - IsAdd: isAdd, - } - - if !addrOnly { - req.LocalPort = lcPort - req.ExternalPort = uint16(mapping.ExternalPort) - } - - reply := &vpp_nat.Nat44AddDelStaticMappingReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// Calls VPP binary API to add/remove NAT44 static mapping with load balancing. -func (h *NatVppHandler) handleNat44StaticMappingLb(mapping *nat.DNat44_StaticMapping, dnatLabel string, isAdd bool) error { - // check tag length limit - if err := checkTagLength(dnatLabel); err != nil { - return err - } - - // parse external IP address - exIPAddrByte, err := ipTo4Address(mapping.ExternalIp) - if err != nil { - return errors.Errorf("cannot configure LB static mapping for DNAT %s: unable to parse external IP %s: %v", - dnatLabel, mapping.ExternalIp, err) - } - - // In this case, external port is required - if mapping.ExternalPort == 0 { - return errors.Errorf("cannot configure LB static mapping for DNAT %s: external port is not set", dnatLabel) - } - - // Transform local IP/Ports - var locals []vpp_nat.Nat44LbAddrPort - for _, local := range mapping.LocalIps { - if local.LocalPort == 0 { - return errors.Errorf("cannot set local IP/Port for DNAT mapping %s: port is missing", - dnatLabel) - } - - localIP, err := ipTo4Address(local.LocalIp) - if err != nil { - return errors.Errorf("cannot set local IP/Port for DNAT mapping %s: unable to parse local IP %v: %v", - dnatLabel, local.LocalIp, err) - } - - locals = append(locals, vpp_nat.Nat44LbAddrPort{ - Addr: localIP, - Port: uint16(local.LocalPort), - Probability: uint8(local.Probability), - VrfID: local.VrfId, - }) - } - - req := &vpp_nat.Nat44AddDelLbStaticMapping{ - Tag: dnatLabel, - Locals: locals, - //LocalNum: uint32(len(locals)), // should not be needed (will be set by struc) - ExternalAddr: exIPAddrByte, - ExternalPort: uint16(mapping.ExternalPort), - Protocol: h.protocolNBValueToNumber(mapping.Protocol), - Flags: setNat44Flags(&nat44Flags{ - isTwiceNat: mapping.TwiceNat == nat.DNat44_StaticMapping_ENABLED, - isSelfTwiceNat: mapping.TwiceNat == nat.DNat44_StaticMapping_SELF, - isOut2In: true, - }), - IsAdd: isAdd, - Affinity: mapping.SessionAffinity, - } - - reply := &vpp_nat.Nat44AddDelLbStaticMappingReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -// Calls VPP binary API to add/remove NAT44 identity mapping. -func (h *NatVppHandler) handleNat44IdentityMapping(mapping *nat.DNat44_IdentityMapping, dnatLabel string, isAdd bool) (err error) { - var ifIdx = NoInterface - var ipAddr vpp_nat.IP4Address - - // check tag length limit - if err := checkTagLength(dnatLabel); err != nil { - return err - } - - // get interface index - if mapping.Interface != "" { - ifMeta, found := h.ifIndexes.LookupByName(mapping.Interface) - if !found { - return errors.Errorf("failed to configure identity mapping for DNAT %s: addressed interface %s does not exist", - dnatLabel, mapping.Interface) - } - ifIdx = vpp_nat.InterfaceIndex(ifMeta.SwIfIndex) - } - - if ifIdx == NoInterface { - // Case with IP (optionally port). Verify and parse input IP/port - ipAddr, err = ipTo4Address(mapping.IpAddress) - if err != nil { - return errors.Errorf("failed to configure identity mapping for DNAT %s: unable to parse IP address %s: %v", - dnatLabel, mapping.IpAddress, err) - } - } - - var addrOnly bool - if mapping.Port == 0 { - addrOnly = true - } - - req := &vpp_nat.Nat44AddDelIdentityMapping{ - Tag: dnatLabel, - Flags: setNat44Flags(&nat44Flags{isAddrOnly: addrOnly}), - IPAddress: ipAddr, - Port: uint16(mapping.Port), - Protocol: h.protocolNBValueToNumber(mapping.Protocol), - SwIfIndex: ifIdx, - VrfID: mapping.VrfId, - IsAdd: isAdd, - } - - reply := &vpp_nat.Nat44AddDelIdentityMappingReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func setNat44Flags(flags *nat44Flags) vpp_nat.NatConfigFlags { - var flagsCfg vpp_nat.NatConfigFlags - if flags.isTwiceNat { - flagsCfg |= vpp_nat.NAT_IS_TWICE_NAT - } - if flags.isSelfTwiceNat { - flagsCfg |= vpp_nat.NAT_IS_SELF_TWICE_NAT - } - if flags.isOut2In { - flagsCfg |= vpp_nat.NAT_IS_OUT2IN_ONLY - } - if flags.isAddrOnly { - flagsCfg |= vpp_nat.NAT_IS_ADDR_ONLY - } - if flags.isOutside { - flagsCfg |= vpp_nat.NAT_IS_OUTSIDE - } - if flags.isInside { - flagsCfg |= vpp_nat.NAT_IS_INSIDE - } - if flags.isStatic { - flagsCfg |= vpp_nat.NAT_IS_STATIC - } - if flags.isExtHostValid { - flagsCfg |= vpp_nat.NAT_IS_EXT_HOST_VALID - } - return flagsCfg -} - -func ipTo4Address(ipStr string) (addr vpp_nat.IP4Address, err error) { - netIP := net.ParseIP(ipStr) - if netIP == nil { - return vpp_nat.IP4Address{}, fmt.Errorf("invalid IP: %q", ipStr) - } - if ip4 := netIP.To4(); ip4 != nil { - var ip4Addr vpp_nat.IP4Address - copy(ip4Addr[:], netIP.To4()) - addr = ip4Addr - } else { - return vpp_nat.IP4Address{}, fmt.Errorf("required IPv4, provided: %q", ipStr) - } - return -} - -// checkTagLength serves as a validator for static/identity mapping tag length -func checkTagLength(tag string) error { - if len(tag) > maxTagLen { - return errors.Errorf("DNAT label '%s' has %d bytes, max allowed is %d", - tag, len(tag), maxTagLen) - } - return nil -} diff --git a/plugins/vpp/natplugin/vppcalls/vpp2001/nat_vppcalls_test.go b/plugins/vpp/natplugin/vppcalls/vpp2001/nat_vppcalls_test.go deleted file mode 100644 index f4eb445e70..0000000000 --- a/plugins/vpp/natplugin/vppcalls/vpp2001/nat_vppcalls_test.go +++ /dev/null @@ -1,909 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "bytes" - "net" - "testing" - - . "github.com/onsi/gomega" - vpp_nat "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/nat" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls/vpp2001" - nat "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat" -) - -func TestSetNat44Forwarding(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_nat.Nat44ForwardingEnableDisableReply{}) - err := natHandler.SetNat44Forwarding(true) - - Expect(err).ShouldNot(HaveOccurred()) - - t.Logf("Msg: %+v (%#v)", ctx.MockChannel.Msg, ctx.MockChannel.Msg) - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44ForwardingEnableDisable) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.Enable).To(BeTrue()) -} - -func TestUnsetNat44Forwarding(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_nat.Nat44ForwardingEnableDisableReply{}) - err := natHandler.SetNat44Forwarding(false) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44ForwardingEnableDisable) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.Enable).To(BeFalse()) -} - -func TestSetNat44ForwardingError(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - // Incorrect reply object - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - err := natHandler.SetNat44Forwarding(true) - - Expect(err).Should(HaveOccurred()) -} - -func TestSetNat44ForwardingRetval(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_nat.Nat44ForwardingEnableDisableReply{ - Retval: 1, - }) - err := natHandler.SetNat44Forwarding(true) - - Expect(err).Should(HaveOccurred()) -} - -func TestEnableNat44InterfaceAsInside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelFeatureReply{}) - err := natHandler.EnableNat44Interface("if0", true, false) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeTrue()) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_INSIDE)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(1)) -} - -func TestEnableNat44InterfaceAsOutside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelFeatureReply{}) - err := natHandler.EnableNat44Interface("if1", false, false) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeTrue()) - Expect(msg.Flags).To(BeEquivalentTo(0)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(2)) -} - -func TestEnableNat44InterfaceError(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - // Incorrect reply object - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelAddressRangeReply{}) - err := natHandler.EnableNat44Interface("if1", false, false) - - Expect(err).Should(HaveOccurred()) -} - -func TestEnableNat44InterfaceRetval(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelFeatureReply{ - Retval: 1, - }) - err := natHandler.EnableNat44Interface("if1", false, false) - - Expect(err).Should(HaveOccurred()) -} - -func TestDisableNat44InterfaceAsInside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelFeatureReply{}) - err := natHandler.DisableNat44Interface("if0", true, false) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeFalse()) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_INSIDE)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(1)) -} - -func TestDisableNat44InterfaceAsOutside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelFeatureReply{}) - err := natHandler.DisableNat44Interface("if1", false, false) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeFalse()) - Expect(msg.Flags).To(BeEquivalentTo(0)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(2)) -} - -func TestEnableNat44InterfaceOutputAsInside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelOutputFeatureReply{}) - err := natHandler.EnableNat44Interface("if0", true, true) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelOutputFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeTrue()) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_INSIDE)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(1)) -} - -func TestEnableNat44InterfaceOutputAsOutside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelOutputFeatureReply{}) - err := natHandler.EnableNat44Interface("if1", false, true) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelOutputFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeTrue()) - Expect(msg.Flags).To(BeEquivalentTo(0)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(2)) -} - -func TestEnableNat44InterfaceOutputError(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - // Incorrect reply object - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - err := natHandler.EnableNat44Interface("if1", false, true) - - Expect(err).Should(HaveOccurred()) -} - -func TestEnableNat44InterfaceOutputRetval(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelOutputFeatureReply{ - Retval: 1, - }) - err := natHandler.EnableNat44Interface("if1", false, true) - - Expect(err).Should(HaveOccurred()) -} - -func TestDisableNat44InterfaceOutputAsInside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelOutputFeatureReply{}) - err := natHandler.DisableNat44Interface("if0", true, true) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelOutputFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeFalse()) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_INSIDE)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(1)) -} - -func TestDisableNat44InterfaceOutputAsOutside(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - ctx.MockVpp.MockReply(&vpp_nat.Nat44InterfaceAddDelOutputFeatureReply{}) - err := natHandler.DisableNat44Interface("if1", false, true) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44InterfaceAddDelOutputFeature) - Expect(ok).To(BeTrue()) - Expect(msg).ToNot(BeNil()) - Expect(msg.IsAdd).To(BeFalse()) - Expect(msg.Flags).To(BeEquivalentTo(0)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(2)) -} - -func TestAddNat44AddressPool(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - addr1 := net.ParseIP("10.0.0.1").To4() - addr2 := net.ParseIP("10.0.0.10").To4() - - // first IP only - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelAddressRangeReply{}) - err := natHandler.AddNat44AddressPool(0, addr1.String(), "", false) - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelAddressRange) - Expect(ok).To(BeTrue()) - Expect(msg.IsAdd).To(BeTrue()) - Expect(addressTo4IP(msg.FirstIPAddress)).To(BeEquivalentTo(addr1.String())) - Expect(addressTo4IP(msg.LastIPAddress)).To(BeEquivalentTo(addr1.String())) - Expect(msg.VrfID).To(BeEquivalentTo(0)) - Expect(msg.Flags).To(BeEquivalentTo(0)) - - // first IP + last IP - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelAddressRangeReply{}) - err = natHandler.AddNat44AddressPool(0, addr1.String(), addr2.String(), false) - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok = ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelAddressRange) - Expect(ok).To(BeTrue()) - Expect(msg.IsAdd).To(BeTrue()) - Expect(addressTo4IP(msg.FirstIPAddress)).To(BeEquivalentTo(addr1.String())) - Expect(addressTo4IP(msg.LastIPAddress)).To(BeEquivalentTo(addr2.String())) - Expect(msg.VrfID).To(BeEquivalentTo(0)) - Expect(msg.Flags).To(BeEquivalentTo(0)) -} - -func TestAddNat44AddressPoolError(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - addr := net.ParseIP("10.0.0.1").To4() - - // Incorrect reply object - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{}) - err := natHandler.AddNat44AddressPool(0, addr.String(), "", false) - - Expect(err).Should(HaveOccurred()) -} - -func TestAddNat44AddressPoolRetval(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - addr := net.ParseIP("10.0.0.1").To4() - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelAddressRangeReply{ - Retval: 1, - }) - err := natHandler.AddNat44AddressPool(0, addr.String(), "", false) - - Expect(err).Should(HaveOccurred()) -} - -func TestDelNat44AddressPool(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - addr := net.ParseIP("10.0.0.1").To4() - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelAddressRangeReply{}) - err := natHandler.DelNat44AddressPool(0, addr.String(), "", false) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelAddressRange) - Expect(ok).To(BeTrue()) - Expect(msg.IsAdd).To(BeFalse()) - Expect(addressTo4IP(msg.FirstIPAddress)).To(BeEquivalentTo(addr.String())) - Expect(addressTo4IP(msg.LastIPAddress)).To(BeEquivalentTo(addr.String())) - Expect(msg.VrfID).To(BeEquivalentTo(0)) - Expect(msg.Flags).To(BeEquivalentTo(0)) -} - -/* DEPRECATED - -func TestSetNat44VirtualReassemblyIPv4(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_nat.NatSetReassReply{}) - err := natHandler.SetVirtualReassemblyIPv4(&nat.VirtualReassembly{ - Timeout: 10, - MaxFragments: 20, - MaxReassemblies: 30, - DropFragments: true, - }) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.NatSetReass) - Expect(ok).To(BeTrue()) - Expect(msg.Timeout).To(BeEquivalentTo(10)) - Expect(msg.MaxFrag).To(BeEquivalentTo(20)) - Expect(msg.MaxReass).To(BeEquivalentTo(30)) - Expect(msg.DropFrag).To(BeEquivalentTo(1)) -} - -func TestSetNat44VirtualReassemblyIPv6(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_nat.NatSetReassReply{}) - err := natHandler.SetVirtualReassemblyIPv6(&nat.VirtualReassembly{ - Timeout: 5, - MaxFragments: 10, - MaxReassemblies: 15, - DropFragments: true, - }) - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.NatSetReass) - Expect(ok).To(BeTrue()) - Expect(msg.Timeout).To(BeEquivalentTo(5)) - Expect(msg.MaxFrag).To(BeEquivalentTo(10)) - Expect(msg.MaxReass).To(BeEquivalentTo(15)) - Expect(msg.DropFrag).To(BeEquivalentTo(1)) -}*/ - -func TestAddNat44StaticMapping(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - localIP := net.ParseIP("10.0.0.1").To4() - externalIP := net.ParseIP("10.0.0.2").To4() - - // DataContext - mapping := &nat.DNat44_StaticMapping{ - ExternalIp: externalIP.String(), - ExternalPort: 8080, - ExternalInterface: "if0", // overrides external IP - Protocol: nat.DNat44_TCP, - TwiceNat: nat.DNat44_StaticMapping_ENABLED, - LocalIps: []*nat.DNat44_StaticMapping_LocalIP{ - { - LocalIp: localIP.String(), - VrfId: 1, - LocalPort: 24, - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - err := natHandler.AddNat44StaticMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelStaticMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(msg.VrfID).To(BeEquivalentTo(1)) - Expect(msg.IsAdd).To(BeTrue()) - Expect(msg.LocalPort).To(BeEquivalentTo(24)) - Expect(msg.ExternalPort).To(BeEquivalentTo(8080)) - Expect(msg.Protocol).To(BeEquivalentTo(6)) - Expect(addressTo4IP(msg.ExternalIPAddress)).To(BeEquivalentTo("0.0.0.0")) - Expect(msg.ExternalSwIfIndex).To(BeEquivalentTo(1)) - Expect(addressTo4IP(msg.LocalIPAddress)).To(BeEquivalentTo(localIP.String())) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_TWICE_NAT + vpp_nat.NAT_IS_OUT2IN_ONLY)) -} - -func TestAddNat44IdentityMappingWithInterface(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - localIP := net.ParseIP("10.0.0.1").To4() - externalIP := net.ParseIP("10.0.0.2").To4() - - // DataContext - mapping := &nat.DNat44_StaticMapping{ - ExternalIp: externalIP.String(), - Protocol: nat.DNat44_TCP, - LocalIps: []*nat.DNat44_StaticMapping_LocalIP{ - { - LocalIp: localIP.String(), - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - err := natHandler.AddNat44StaticMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelStaticMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(msg.IsAdd).To(BeTrue()) - Expect(addressTo4IP(msg.ExternalIPAddress)).To(BeEquivalentTo(externalIP.String())) - Expect(addressTo4IP(msg.LocalIPAddress)).To(BeEquivalentTo(localIP.String())) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_OUT2IN_ONLY + vpp_nat.NAT_IS_ADDR_ONLY)) -} - -func TestAddNat44StaticMappingError(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - // Incorrect reply object - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelLbStaticMappingReply{}) - err := natHandler.AddNat44StaticMapping(&nat.DNat44_StaticMapping{}, "") - - Expect(err).Should(HaveOccurred()) -} - -func TestAddNat44StaticMappingRetval(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{ - Retval: 1, - }) - err := natHandler.AddNat44StaticMapping(&nat.DNat44_StaticMapping{}, "") - - Expect(err).Should(HaveOccurred()) -} - -func TestDelNat44StaticMapping(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - localIP := net.ParseIP("10.0.0.1").To4() - externalIP := net.ParseIP("10.0.0.2").To4() - - mapping := &nat.DNat44_StaticMapping{ - ExternalIp: externalIP.String(), - ExternalPort: 8080, - ExternalInterface: "if0", // overrides external IP - Protocol: nat.DNat44_TCP, - TwiceNat: nat.DNat44_StaticMapping_ENABLED, - LocalIps: []*nat.DNat44_StaticMapping_LocalIP{ - { - LocalIp: localIP.String(), - VrfId: 1, - LocalPort: 24, - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - err := natHandler.DelNat44StaticMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelStaticMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(msg.VrfID).To(BeEquivalentTo(1)) - Expect(msg.IsAdd).To(BeFalse()) - Expect(msg.LocalPort).To(BeEquivalentTo(24)) - Expect(msg.ExternalPort).To(BeEquivalentTo(8080)) - Expect(msg.Protocol).To(BeEquivalentTo(6)) - Expect(addressTo4IP(msg.ExternalIPAddress)).To(BeEquivalentTo("0.0.0.0")) - Expect(msg.ExternalSwIfIndex).To(BeEquivalentTo(1)) - Expect(addressTo4IP(msg.LocalIPAddress)).To(BeEquivalentTo(localIP.String())) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_TWICE_NAT + vpp_nat.NAT_IS_OUT2IN_ONLY)) -} - -func TestDelNat44StaticMappingAddrOnly(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - localIP := net.ParseIP("10.0.0.1").To4() - externalIP := net.ParseIP("10.0.0.2").To4() - - mapping := &nat.DNat44_StaticMapping{ - ExternalIp: externalIP.String(), - Protocol: nat.DNat44_TCP, - LocalIps: []*nat.DNat44_StaticMapping_LocalIP{ - { - LocalIp: localIP.String(), - }, - }, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - err := natHandler.DelNat44StaticMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelStaticMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(msg.IsAdd).To(BeFalse()) - Expect(addressTo4IP(msg.ExternalIPAddress)).To(BeEquivalentTo(externalIP.String())) - Expect(addressTo4IP(msg.LocalIPAddress)).To(BeEquivalentTo(localIP.String())) -} - -func TestAddNat44StaticMappingLb(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - externalIP := net.ParseIP("10.0.0.1").To4() - localIP1 := net.ParseIP("10.0.0.2").To4() - localIP2 := net.ParseIP("10.0.0.3").To4() - - mapping := &nat.DNat44_StaticMapping{ - ExternalIp: externalIP.String(), - ExternalPort: 8080, - ExternalInterface: "if0", - Protocol: nat.DNat44_TCP, - TwiceNat: nat.DNat44_StaticMapping_ENABLED, - LocalIps: localIPs(localIP1, localIP2), - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelLbStaticMappingReply{}) - err := natHandler.AddNat44StaticMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelLbStaticMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(msg.IsAdd).To(BeTrue()) - Expect(addressTo4IP(msg.ExternalAddr)).To(BeEquivalentTo(externalIP.String())) - Expect(msg.ExternalPort).To(BeEquivalentTo(8080)) - Expect(msg.Protocol).To(BeEquivalentTo(6)) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_TWICE_NAT + vpp_nat.NAT_IS_OUT2IN_ONLY)) - - // Local IPs - Expect(msg.Locals).To(HaveLen(2)) - expectedCount := 0 - for _, local := range msg.Locals { - localAddr := make(net.IP, net.IPv4len) - copy(localAddr, local.Addr[:]) - if bytes.Compare(localAddr, localIP1) == 0 && local.Port == 8080 && local.Probability == 35 { - expectedCount++ - } - copy(localAddr, local.Addr[:]) - if bytes.Compare(localAddr, localIP2) == 0 && local.Port == 8181 && local.Probability == 65 { - expectedCount++ - } - } - Expect(expectedCount).To(BeEquivalentTo(2)) -} - -func TestDelNat44StaticMappingLb(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - externalIP := net.ParseIP("10.0.0.1").To4() - localIP1 := net.ParseIP("10.0.0.2").To4() - localIP2 := net.ParseIP("10.0.0.3").To4() - - mapping := &nat.DNat44_StaticMapping{ - ExternalIp: externalIP.String(), - ExternalPort: 8080, - ExternalInterface: "if0", - Protocol: nat.DNat44_TCP, - TwiceNat: nat.DNat44_StaticMapping_ENABLED, - LocalIps: localIPs(localIP1, localIP2), - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelLbStaticMappingReply{}) - err := natHandler.DelNat44StaticMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelLbStaticMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(msg.IsAdd).To(BeFalse()) - Expect(addressTo4IP(msg.ExternalAddr)).To(BeEquivalentTo(externalIP.String())) - Expect(msg.ExternalPort).To(BeEquivalentTo(8080)) - Expect(msg.Protocol).To(BeEquivalentTo(6)) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_TWICE_NAT + vpp_nat.NAT_IS_OUT2IN_ONLY)) - - // Local IPs - Expect(msg.Locals).To(HaveLen(2)) - expectedCount := 0 - for _, local := range msg.Locals { - localAddr := make(net.IP, net.IPv4len) - copy(localAddr, local.Addr[:]) - if bytes.Compare(localAddr, localIP1) == 0 && local.Port == 8080 && local.Probability == 35 { - expectedCount++ - } - copy(localAddr, local.Addr[:]) - if bytes.Compare(localAddr, localIP2) == 0 && local.Port == 8181 && local.Probability == 65 { - expectedCount++ - } - } - Expect(expectedCount).To(BeEquivalentTo(2)) -} - -func TestAddNat44IdentityMapping(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - address := net.ParseIP("10.0.0.1").To4() - - mapping := &nat.DNat44_IdentityMapping{ - VrfId: 1, - Interface: "if0", // overrides IP address - IpAddress: address.String(), - Port: 9000, - Protocol: nat.DNat44_UDP, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{}) - err := natHandler.AddNat44IdentityMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelIdentityMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(msg.VrfID).To(BeEquivalentTo(1)) - Expect(addressTo4IP(msg.IPAddress)).To(BeEquivalentTo("0.0.0.0")) - Expect(msg.IsAdd).To(BeTrue()) - Expect(msg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(msg.Protocol).To(BeEquivalentTo(17)) - Expect(msg.Port).To(BeEquivalentTo(9000)) - Expect(msg.Flags).To(BeEquivalentTo(0)) -} - -func TestAddNat44IdentityMappingAddrOnly(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - // IPAddress == nil and Port == 0 means it's address only - mapping := &nat.DNat44_IdentityMapping{ - VrfId: 1, - Interface: "if0", // overrides IP address - Protocol: nat.DNat44_UDP, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{}) - err := natHandler.AddNat44IdentityMapping(mapping, "DNAT 1") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelIdentityMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 1")) - Expect(addressTo4IP(msg.IPAddress)).To(BeEquivalentTo("0.0.0.0")) - Expect(msg.IsAdd).To(BeTrue()) - Expect(msg.Protocol).To(BeEquivalentTo(17)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_ADDR_ONLY)) -} - -func TestAddNat44IdentityMappingNoInterface(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - address := net.ParseIP("10.0.0.1").To4() - - mapping := &nat.DNat44_IdentityMapping{ - VrfId: 1, - Protocol: nat.DNat44_UDP, - IpAddress: address.String(), - Port: 8989, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{}) - err := natHandler.AddNat44IdentityMapping(mapping, "DNAT 2") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelIdentityMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 2")) - Expect(addressTo4IP(msg.IPAddress)).To(BeEquivalentTo(address.String())) - Expect(msg.Port).To(BeEquivalentTo(8989)) - Expect(msg.SwIfIndex).To(BeEquivalentTo(vpp2001.NoInterface)) - Expect(msg.Flags).To(BeEquivalentTo(0)) -} - -func TestAddNat44IdentityMappingError(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - // Incorrect reply object - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - err := natHandler.AddNat44IdentityMapping(&nat.DNat44_IdentityMapping{}, "") - - Expect(err).Should(HaveOccurred()) -} - -func TestAddNat44IdentityMappingRetval(t *testing.T) { - ctx, natHandler, _, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{ - Retval: 1, - }) - err := natHandler.AddNat44IdentityMapping(&nat.DNat44_IdentityMapping{}, "") - - Expect(err).Should(HaveOccurred()) -} - -func TestDelNat44IdentityMapping(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - address := net.ParseIP("10.0.0.1").To4() - - mapping := &nat.DNat44_IdentityMapping{ - Interface: "if0", - IpAddress: address.String(), - Protocol: nat.DNat44_TCP, - VrfId: 1, - } - - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{}) - err := natHandler.DelNat44IdentityMapping(mapping, "DNAT 2") - - Expect(err).ShouldNot(HaveOccurred()) - - msg, ok := ctx.MockChannel.Msg.(*vpp_nat.Nat44AddDelIdentityMapping) - Expect(ok).To(BeTrue()) - Expect(msg.Tag).To(BeEquivalentTo("DNAT 2")) - Expect(msg.VrfID).To(BeEquivalentTo(1)) - Expect(addressTo4IP(msg.IPAddress)).To(BeEquivalentTo("0.0.0.0")) - Expect(msg.IsAdd).To(BeFalse()) - Expect(msg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(msg.Protocol).To(BeEquivalentTo(6)) - Expect(msg.Flags).To(BeEquivalentTo(vpp_nat.NAT_IS_ADDR_ONLY)) -} - -func TestNat44MappingLongTag(t *testing.T) { - ctx, natHandler, swIfIndexes, _ := natTestSetup(t) - defer ctx.TeardownTestCtx() - - swIfIndexes.Put("if0", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - normalTag := "normalTag" - longTag := "some-weird-tag-which-is-much-longer-than-allowed-sixty-four-bytes" - - localIP1 := net.ParseIP("10.0.0.1").To4() - localIP2 := net.ParseIP("20.0.0.1").To4() - externalIP := net.ParseIP("10.0.0.2").To4() - - mapping := &nat.DNat44_StaticMapping{ - LocalIps: []*nat.DNat44_StaticMapping_LocalIP{ - { - LocalIp: localIP1.String(), - }, - }, - ExternalIp: externalIP.String(), - } - lbMapping := &nat.DNat44_StaticMapping{ - LocalIps: localIPs(localIP1, localIP2), - ExternalIp: externalIP.String(), - ExternalPort: 8080, - Protocol: nat.DNat44_TCP, - TwiceNat: nat.DNat44_StaticMapping_ENABLED, - } - idMapping := &nat.DNat44_IdentityMapping{ - IpAddress: localIP1.String(), - Protocol: nat.DNat44_UDP, - VrfId: 1, - Interface: "if0", - } - - // 1. test - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelLbStaticMappingReply{}) - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{}) - // 2. test - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelStaticMappingReply{}) - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelLbStaticMappingReply{}) - ctx.MockVpp.MockReply(&vpp_nat.Nat44AddDelIdentityMappingReply{}) - - // Successful scenario (to ensure there is no other error) - err := natHandler.AddNat44StaticMapping(mapping, normalTag) - Expect(err).To(BeNil()) - err = natHandler.AddNat44StaticMapping(lbMapping, normalTag) - Expect(err).To(BeNil()) - err = natHandler.AddNat44IdentityMapping(idMapping, normalTag) - Expect(err).To(BeNil()) - - // Replace tags and test again - err = natHandler.AddNat44StaticMapping(mapping, longTag) - Expect(err).ToNot(BeNil()) - err = natHandler.AddNat44StaticMapping(lbMapping, longTag) - Expect(err).ToNot(BeNil()) - err = natHandler.AddNat44IdentityMapping(idMapping, longTag) - Expect(err).ToNot(BeNil()) -} - -func localIPs(addr1, addr2 net.IP) []*nat.DNat44_StaticMapping_LocalIP { - return []*nat.DNat44_StaticMapping_LocalIP{ - { - LocalIp: addr1.String(), - LocalPort: 8080, - Probability: 35, - }, - { - LocalIp: addr2.String(), - LocalPort: 8181, - Probability: 65, - }, - } -} - -func addressTo4IP(address vpp_nat.IP4Address) string { - ipAddr := make(net.IP, net.IPv4len) - copy(ipAddr[:], address[:]) - if ipAddr.To4() == nil { - return "" - } - return ipAddr.To4().String() -} diff --git a/plugins/vpp/natplugin/vppcalls/vpp2001/vppcalls_handler.go b/plugins/vpp/natplugin/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 78480072e7..0000000000 --- a/plugins/vpp/natplugin/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/idxmap" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - vpp_nat "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/nat" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls" -) - -func init() { - var msgs []govppapi.Message - msgs = append(msgs, vpp_nat.AllMessages()...) - - vppcalls.AddNatHandlerVersion(vpp2001.Version, msgs, func(c vpp.Client, ifIdx ifaceidx.IfaceMetadataIndex, dhcpIdx idxmap.NamedMapping, log logging.Logger) vppcalls.NatVppAPI { - ch, _ := c.NewAPIChannel() - return NewNatVppHandler(ch, ifIdx, dhcpIdx, log) - }) -} - -// NatVppHandler is accessor for NAT-related vppcalls methods. -type NatVppHandler struct { - callsChannel govppapi.Channel - ip vpp_ip.RPCService - nat vpp_nat.RPCService - ifIndexes ifaceidx.IfaceMetadataIndex - dhcpIndex idxmap.NamedMapping - log logging.Logger -} - -// NewNatVppHandler creates new instance of NAT vppcalls handler. -func NewNatVppHandler(callsChan govppapi.Channel, - ifIndexes ifaceidx.IfaceMetadataIndex, dhcpIndex idxmap.NamedMapping, log logging.Logger, -) vppcalls.NatVppAPI { - return &NatVppHandler{ - callsChannel: callsChan, - ip: vpp_ip.NewServiceClient(callsChan), - nat: vpp_nat.NewServiceClient(callsChan), - ifIndexes: ifIndexes, - dhcpIndex: dhcpIndex, - log: log, - } -} diff --git a/plugins/vpp/puntplugin/puntplugin.go b/plugins/vpp/puntplugin/puntplugin.go index 2088dd7022..0d606ba649 100644 --- a/plugins/vpp/puntplugin/puntplugin.go +++ b/plugins/vpp/puntplugin/puntplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls" vpp_punt "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/punt" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/puntplugin/vppcalls/vpp2001/dump_vppcalls.go b/plugins/vpp/puntplugin/vppcalls/vpp2001/dump_vppcalls.go deleted file mode 100644 index 2ef93259eb..0000000000 --- a/plugins/vpp/puntplugin/vppcalls/vpp2001/dump_vppcalls.go +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - "strings" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_punt "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/punt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls" - punt "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/punt" -) - -// DumpPuntRedirect dumps ip redirect punts -func (h *PuntVppHandler) DumpPuntRedirect() (punts []*punt.IPRedirect, err error) { - punt4, err := h.dumpPuntRedirect(false) - if err != nil { - return nil, err - } - punts = append(punts, punt4...) - - punt6, err := h.dumpPuntRedirect(true) - if err != nil { - return nil, err - } - punts = append(punts, punt6...) - - return punts, nil -} - -func (h *PuntVppHandler) dumpPuntRedirect(ipv6 bool) (punts []*punt.IPRedirect, err error) { - req := h.callsChannel.SendMultiRequest(&vpp_ip.IPPuntRedirectDump{ - SwIfIndex: ^interface_types.InterfaceIndex(0), - IsIPv6: ipv6, - }) - for { - d := &vpp_ip.IPPuntRedirectDetails{} - stop, err := req.ReceiveReply(d) - if stop { - break - } - if err != nil { - return nil, err - } - - rxIface, _, exists := h.ifIndexes.LookupBySwIfIndex(uint32(d.Punt.RxSwIfIndex)) - if !exists { - h.log.Warnf("RX interface (%v) not found", d.Punt.RxSwIfIndex) - continue - } - txIface, _, exists := h.ifIndexes.LookupBySwIfIndex(uint32(d.Punt.TxSwIfIndex)) - if !exists { - h.log.Warnf("TX interface (%v) not found", d.Punt.TxSwIfIndex) - continue - } - - var l3proto punt.L3Protocol - var nextHop string - - if d.Punt.Nh.Af == ip_types.ADDRESS_IP4 { - l3proto = punt.L3Protocol_IPV4 - addr := d.Punt.Nh.Un.GetIP4() - nextHop = net.IP(addr[:]).To4().String() - } else if d.Punt.Nh.Af == ip_types.ADDRESS_IP6 { - l3proto = punt.L3Protocol_IPV6 - addr := d.Punt.Nh.Un.GetIP6() - nextHop = net.IP(addr[:]).To16().String() - } else { - h.log.Warnf("invalid address family (%v)", d.Punt.Nh.Af) - continue - } - - punts = append(punts, &punt.IPRedirect{ - L3Protocol: l3proto, - RxInterface: rxIface, - TxInterface: txIface, - NextHop: nextHop, - }) - } - - return punts, nil -} - -// DumpExceptions returns dump of registered punt exceptions. -func (h *PuntVppHandler) DumpExceptions() (punts []*vppcalls.ExceptionDetails, err error) { - reasons, err := h.dumpPuntReasons() - if err != nil { - return nil, err - } - reasonMap := make(map[uint32]string, len(reasons)) - for _, r := range reasons { - reasonMap[r.ID] = r.Reason.Name - } - - if punts, err = h.dumpPuntExceptions(reasonMap); err != nil { - return nil, err - } - - return punts, nil -} - -func (h *PuntVppHandler) dumpPuntExceptions(reasons map[uint32]string) (punts []*vppcalls.ExceptionDetails, err error) { - req := h.callsChannel.SendMultiRequest(&vpp_punt.PuntSocketDump{ - Type: vpp_punt.PUNT_API_TYPE_EXCEPTION, - }) - for { - d := &vpp_punt.PuntSocketDetails{} - stop, err := req.ReceiveReply(d) - if stop { - break - } - if err != nil { - return nil, err - } - - if d.Punt.Type != vpp_punt.PUNT_API_TYPE_EXCEPTION { - h.log.Warnf("VPP returned invalid punt type in exception punt dump: %v", d.Punt.Type) - continue - } - - puntData := d.Punt.Punt.GetException() - reason := reasons[puntData.ID] - socketPath := strings.Trim(d.Pathname, "\x00") - - punts = append(punts, &vppcalls.ExceptionDetails{ - Exception: &punt.Exception{ - Reason: reason, - SocketPath: vppConfigSocketPath, - }, - SocketPath: socketPath, - }) - } - - return punts, nil -} - -// DumpRegisteredPuntSockets returns punt to host via registered socket entries -func (h *PuntVppHandler) DumpRegisteredPuntSockets() (punts []*vppcalls.PuntDetails, err error) { - if punts, err = h.dumpPuntL4(); err != nil { - return nil, err - } - - return punts, nil -} - -func (h *PuntVppHandler) dumpPuntL4() (punts []*vppcalls.PuntDetails, err error) { - req := h.callsChannel.SendMultiRequest(&vpp_punt.PuntSocketDump{ - Type: vpp_punt.PUNT_API_TYPE_L4, - }) - for { - d := &vpp_punt.PuntSocketDetails{} - stop, err := req.ReceiveReply(d) - if stop { - break - } - if err != nil { - return nil, err - } - - if d.Punt.Type != vpp_punt.PUNT_API_TYPE_L4 { - h.log.Warnf("VPP returned invalid punt type in L4 punt dump: %v", d.Punt.Type) - continue - } - - puntData := d.Punt.Punt.GetL4() - socketPath := strings.Trim(d.Pathname, "\x00") - - punts = append(punts, &vppcalls.PuntDetails{ - PuntData: &punt.ToHost{ - Port: uint32(puntData.Port), - L3Protocol: parseL3Proto(puntData.Af), - L4Protocol: parseL4Proto(puntData.Protocol), - SocketPath: vppConfigSocketPath, - }, - SocketPath: socketPath, - }) - } - - return punts, nil -} - -// DumpPuntReasons returns all known punt reasons from VPP -func (h *PuntVppHandler) DumpPuntReasons() (reasons []*vppcalls.ReasonDetails, err error) { - if reasons, err = h.dumpPuntReasons(); err != nil { - return nil, err - } - - return reasons, nil -} - -func (h *PuntVppHandler) dumpPuntReasons() (reasons []*vppcalls.ReasonDetails, err error) { - req := h.callsChannel.SendMultiRequest(&vpp_punt.PuntReasonDump{}) - for { - d := &vpp_punt.PuntReasonDetails{} - stop, err := req.ReceiveReply(d) - if stop { - break - } - if err != nil { - return nil, err - } - - reasons = append(reasons, &vppcalls.ReasonDetails{ - Reason: &punt.Reason{ - Name: d.Reason.Name, - }, - ID: d.Reason.ID, - }) - } - - return reasons, nil -} - -func parseL3Proto(p vpp_punt.AddressFamily) punt.L3Protocol { - switch p { - case ip_types.ADDRESS_IP4: - return punt.L3Protocol_IPV4 - case ip_types.ADDRESS_IP6: - return punt.L3Protocol_IPV6 - } - return punt.L3Protocol_UNDEFINED_L3 -} - -func parseL4Proto(p vpp_punt.IPProto) punt.L4Protocol { - switch p { - case ip_types.IP_API_PROTO_TCP: - return punt.L4Protocol_TCP - case ip_types.IP_API_PROTO_UDP: - return punt.L4Protocol_UDP - } - return punt.L4Protocol_UNDEFINED_L4 -} diff --git a/plugins/vpp/puntplugin/vppcalls/vpp2001/punt_vppcalls.go b/plugins/vpp/puntplugin/vppcalls/vpp2001/punt_vppcalls.go deleted file mode 100644 index 2730279aa4..0000000000 --- a/plugins/vpp/puntplugin/vppcalls/vpp2001/punt_vppcalls.go +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "strings" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_punt "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/punt" - punt "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/punt" -) - -const PuntSocketHeaderVersion = 1 - -// Socket path from the VPP startup config file, returned when a punt socket -// is retrieved. Limited to single entry as supported in the VPP. -var vppConfigSocketPath string - -// AddPunt configures new punt entry -func (h *PuntVppHandler) AddPunt(p *punt.ToHost) error { - return errors.Errorf("passive punt add is currently not available") -} - -// DeletePunt removes punt entry -func (h *PuntVppHandler) DeletePunt(p *punt.ToHost) error { - return errors.Errorf("passive punt del is currently not available") -} - -// AddPuntException adds new punt exception entry -func (h *PuntVppHandler) AddPuntException(p *punt.Exception) (string, error) { - return h.addDelPuntException(p, true) -} - -// DeletePuntException removes punt exception entry -func (h *PuntVppHandler) DeletePuntException(p *punt.Exception) error { - _, err := h.addDelPuntException(p, false) - return err -} - -func (h *PuntVppHandler) addDelPuntException(p *punt.Exception, isAdd bool) (pathName string, err error) { - reasons, err := h.dumpPuntReasons() - if err != nil { - return "", fmt.Errorf("dumping punt reasons failed: %v", err) - } - - h.log.Debugf("dumped %d punt reasons: %+v", len(reasons), reasons) - - var reasonID *uint32 - for _, r := range reasons { - if r.Reason.Name == p.Reason { - id := r.ID - reasonID = &id - break - } - } - if reasonID == nil { - return "", fmt.Errorf("punt reason %q not found", p.Reason) - } - - baPunt := getPuntExceptionConfig(*reasonID) - - if isAdd { - h.log.Debugf("adding punt exception: %+v", p) - pathName, err = h.handleRegisterPuntSocket(baPunt, p.SocketPath) - if err != nil { - return "", err - } - } else { - err = h.handleDeregisterPuntSocket(baPunt) - if err != nil { - return "", err - } - } - - return pathName, nil -} - -// RegisterPuntSocket registers new punt to unix domain socket entry -func (h *PuntVppHandler) RegisterPuntSocket(p *punt.ToHost) (pathName string, err error) { - ipProto := resolveL4Proto(p.L4Protocol) - - if p.L3Protocol == punt.L3Protocol_IPV4 || p.L3Protocol == punt.L3Protocol_ALL { - baPunt := getPuntL4Config(ip_types.ADDRESS_IP4, ipProto, uint16(p.Port)) - if pathName, err = h.handleRegisterPuntSocket(baPunt, p.SocketPath); err != nil { - return "", err - } - } - if p.L3Protocol == punt.L3Protocol_IPV6 || p.L3Protocol == punt.L3Protocol_ALL { - baPunt := getPuntL4Config(ip_types.ADDRESS_IP6, ipProto, uint16(p.Port)) - if pathName, err = h.handleRegisterPuntSocket(baPunt, p.SocketPath); err != nil { - return "", err - } - } - - return pathName, nil -} - -// DeregisterPuntSocket removes existing punt to socket registration -func (h *PuntVppHandler) DeregisterPuntSocket(p *punt.ToHost) error { - ipProto := resolveL4Proto(p.L4Protocol) - - if p.L3Protocol == punt.L3Protocol_IPV4 || p.L3Protocol == punt.L3Protocol_ALL { - baPunt := getPuntL4Config(ip_types.ADDRESS_IP4, ipProto, uint16(p.Port)) - if err := h.handleDeregisterPuntSocket(baPunt); err != nil { - return err - } - } - if p.L3Protocol == punt.L3Protocol_IPV6 || p.L3Protocol == punt.L3Protocol_ALL { - baPunt := getPuntL4Config(ip_types.ADDRESS_IP6, ipProto, uint16(p.Port)) - if err := h.handleDeregisterPuntSocket(baPunt); err != nil { - return err - } - } - - return nil -} - -func (h *PuntVppHandler) handleRegisterPuntSocket(punt vpp_punt.Punt, path string) (string, error) { - req := &vpp_punt.PuntSocketRegister{ - HeaderVersion: PuntSocketHeaderVersion, - Punt: punt, - Pathname: path, - } - reply := &vpp_punt.PuntSocketRegisterReply{} - - h.log.Debugf("registering punt socket: %+v (pathname: %s)", req.Punt, req.Pathname) - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return "", err - } - - // socket pathname from VPP config - pathName := strings.SplitN(string(reply.Pathname), "\x00", 2)[0] - - // VPP startup config socket path name is always the same - if vppConfigSocketPath != pathName { - h.log.Debugf("setting vpp punt socket path to: %q (%s)", pathName, vppConfigSocketPath) - vppConfigSocketPath = pathName - } - - return pathName, nil -} - -// DeregisterPuntSocket removes existing punt to socket registration -func (h *PuntVppHandler) handleDeregisterPuntSocket(punt vpp_punt.Punt) error { - req := &vpp_punt.PuntSocketDeregister{ - Punt: punt, - } - reply := &vpp_punt.PuntSocketDeregisterReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func getPuntExceptionConfig(reasonID uint32) vpp_punt.Punt { - p := vpp_punt.PuntException{ - ID: reasonID, - } - return vpp_punt.Punt{ - Type: vpp_punt.PUNT_API_TYPE_EXCEPTION, - Punt: vpp_punt.PuntUnionException(p), - } -} - -func getPuntL4Config(ipv vpp_punt.AddressFamily, ipProto vpp_punt.IPProto, port uint16) vpp_punt.Punt { - puntL4 := vpp_punt.PuntL4{ - Af: ipv, - Protocol: ipProto, - Port: port, - } - return vpp_punt.Punt{ - Type: vpp_punt.PUNT_API_TYPE_L4, - Punt: vpp_punt.PuntUnionL4(puntL4), - } -} - -// AddPuntRedirect adds new redirect entry -func (h *PuntVppHandler) AddPuntRedirect(puntCfg *punt.IPRedirect) error { - if puntCfg.L3Protocol == punt.L3Protocol_IPV4 || puntCfg.L3Protocol == punt.L3Protocol_ALL { - if err := h.handlePuntRedirectIPv4(puntCfg, true); err != nil { - return err - } - } - if puntCfg.L3Protocol == punt.L3Protocol_IPV6 || puntCfg.L3Protocol == punt.L3Protocol_ALL { - if err := h.handlePuntRedirectIPv6(puntCfg, true); err != nil { - return err - } - } - return nil -} - -// DeletePuntRedirect removes existing redirect entry -func (h *PuntVppHandler) DeletePuntRedirect(puntCfg *punt.IPRedirect) error { - if puntCfg.L3Protocol == punt.L3Protocol_IPV4 || puntCfg.L3Protocol == punt.L3Protocol_ALL { - if err := h.handlePuntRedirectIPv4(puntCfg, false); err != nil { - return err - } - } - if puntCfg.L3Protocol == punt.L3Protocol_IPV6 || puntCfg.L3Protocol == punt.L3Protocol_ALL { - if err := h.handlePuntRedirectIPv6(puntCfg, false); err != nil { - return err - } - } - return nil -} - -func (h *PuntVppHandler) handlePuntRedirectIPv4(punt *punt.IPRedirect, isAdd bool) error { - return h.handlePuntRedirect(punt, true, isAdd) -} - -func (h *PuntVppHandler) handlePuntRedirectIPv6(punt *punt.IPRedirect, isAdd bool) error { - return h.handlePuntRedirect(punt, false, isAdd) -} - -func (h *PuntVppHandler) handlePuntRedirect(punt *punt.IPRedirect, isIPv4, isAdd bool) error { - // rx interface - var rxIfIdx uint32 - if punt.RxInterface == "" { - rxIfIdx = ^uint32(0) - } else { - rxMetadata, exists := h.ifIndexes.LookupByName(punt.RxInterface) - if !exists { - return errors.Errorf("index not found for interface %s", punt.RxInterface) - } - rxIfIdx = rxMetadata.SwIfIndex - } - - // tx interface - txMetadata, exists := h.ifIndexes.LookupByName(punt.TxInterface) - if !exists { - return errors.Errorf("index not found for interface %s", punt.TxInterface) - } - - // next hop address - // - remove mask from IP address if necessary - nextHopStr := punt.NextHop - ipParts := strings.Split(punt.NextHop, "/") - if len(ipParts) > 1 { - h.log.Debugf("IP punt redirect next hop IP address %s is defined with mask, removing it") - nextHopStr = ipParts[0] - } - nextHop, err := ipToAddress(nextHopStr) - if err != nil { - return err - } - - req := &vpp_ip.IPPuntRedirect{ - IsAdd: isAdd, - Punt: vpp_ip.PuntRedirect{ - RxSwIfIndex: interface_types.InterfaceIndex(rxIfIdx), - TxSwIfIndex: interface_types.InterfaceIndex(txMetadata.SwIfIndex), - Nh: nextHop, - }, - } - reply := &vpp_ip.IPPuntRedirectReply{} - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil -} - -func resolveL4Proto(protocol punt.L4Protocol) vpp_punt.IPProto { - if protocol == punt.L4Protocol_UDP { - return ip_types.IP_API_PROTO_UDP - } - return ip_types.IP_API_PROTO_TCP -} - -func boolToUint(input bool) uint8 { - if input { - return 1 - } - return 0 -} diff --git a/plugins/vpp/puntplugin/vppcalls/vpp2001/punt_vppcalls_test.go b/plugins/vpp/puntplugin/vppcalls/vpp2001/punt_vppcalls_test.go deleted file mode 100644 index 5b1fd4e31b..0000000000 --- a/plugins/vpp/puntplugin/vppcalls/vpp2001/punt_vppcalls_test.go +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_punt "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/punt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - punt "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/punt" -) - -// TODO test below temporary disabled (re-enable with set_punt) -/* -func TestAddPunt(t *testing.T) { - ctx, puntHandler, _ := puntTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&ba_punt.SetPuntReply{}) - - err := puntHandler.AddPunt(&punt.ToHost{ - L3Protocol: punt.L3Protocol_IPv4, - L4Protocol: punt.L4Protocol_UDP, - Port: 9000, - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*ba_punt.SetPunt) - Expect(ok).To(BeTrue()) - Expect(vppMsg.IsAdd).To(Equal(uint8(1))) - Expect(vppMsg.Punt.IPv).To(Equal(uint8(4))) - Expect(vppMsg.Punt.L4Protocol).To(Equal(uint8(17))) - Expect(vppMsg.Punt.L4Port).To(Equal(uint16(9000))) -} - -func TestDeletePunt(t *testing.T) { - ctx, puntHandler, _ := puntTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&ba_punt.SetPuntReply{}) - - err := puntHandler.DeletePunt(&punt.ToHost{ - L3Protocol: punt.L3Protocol_IPv4, - L4Protocol: punt.L4Protocol_UDP, - Port: 9000, - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*ba_punt.SetPunt) - Expect(ok).To(BeTrue()) - Expect(vppMsg.IsAdd).To(Equal(uint8(0))) - Expect(vppMsg.Punt.IPv).To(Equal(uint8(4))) - Expect(vppMsg.Punt.L4Protocol).To(Equal(uint8(17))) - Expect(vppMsg.Punt.L4Port).To(Equal(uint16(9000))) -} -*/ - -func TestRegisterPuntSocket(t *testing.T) { - ctx, puntHandler, _ := puntTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_punt.PuntSocketRegisterReply{ - Pathname: "/othersock", - }) - - path, err := puntHandler.RegisterPuntSocket(&punt.ToHost{ - L3Protocol: punt.L3Protocol_IPV4, - L4Protocol: punt.L4Protocol_UDP, - Port: 9000, - SocketPath: "/test/path/socket", - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_punt.PuntSocketRegister) - Expect(ok).To(BeTrue()) - Expect(vppMsg.HeaderVersion).To(Equal(uint32(1))) - Expect(vppMsg.Punt.Punt.GetL4().Af).To(Equal(ip_types.ADDRESS_IP4)) - Expect(vppMsg.Punt.Punt.GetL4().Protocol).To(Equal(ip_types.IP_API_PROTO_UDP)) - Expect(vppMsg.Punt.Punt.GetL4().Port).To(Equal(uint16(9000))) - Expect(path).To(Equal("/othersock")) -} - -func TestRegisterPuntSocketAllIPv4(t *testing.T) { - ctx, puntHandler, _ := puntTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_punt.PuntSocketRegisterReply{ - Pathname: "/othersock", - }) - ctx.MockVpp.MockReply(&vpp_punt.PuntSocketRegisterReply{ - Pathname: "/othersock", - }) - - path, err := puntHandler.RegisterPuntSocket(&punt.ToHost{ - L3Protocol: punt.L3Protocol_ALL, - L4Protocol: punt.L4Protocol_UDP, - Port: 9000, - SocketPath: "/test/path/socket", - }) - - Expect(err).To(BeNil()) - for _, msg := range ctx.MockChannel.Msgs { - vppMsg, ok := msg.(*vpp_punt.PuntSocketRegister) - Expect(ok).To(BeTrue()) - - if vppMsg.Punt.Punt.GetL4().Af == ip_types.ADDRESS_IP4 { - Expect(vppMsg.HeaderVersion).To(Equal(uint32(1))) - Expect(vppMsg.Punt.Punt.GetL4().Protocol).To(Equal(ip_types.IP_API_PROTO_UDP)) - Expect(vppMsg.Punt.Punt.GetL4().Port).To(Equal(uint16(9000))) - Expect(path).To(Equal("/othersock")) - } - if vppMsg.Punt.Punt.GetL4().Af == ip_types.ADDRESS_IP6 { - Expect(vppMsg.HeaderVersion).To(Equal(uint32(1))) - Expect(vppMsg.Punt.Punt.GetL4().Protocol).To(Equal(ip_types.IP_API_PROTO_UDP)) - Expect(vppMsg.Punt.Punt.GetL4().Port).To(Equal(uint16(9000))) - Expect(path).To(Equal("/othersock")) - } - } -} - -func TestAddIPRedirect(t *testing.T) { - ctx, puntHandler, ifIndexes := puntTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPPuntRedirectReply{}) - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - ifIndexes.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - err := puntHandler.AddPuntRedirect(&punt.IPRedirect{ - L3Protocol: punt.L3Protocol_IPV4, - RxInterface: "if1", - TxInterface: "if2", - NextHop: "10.0.0.1", - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPPuntRedirect) - Expect(ok).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeTrue()) - Expect(vppMsg.Punt.Nh.Af).To(Equal(ip_types.ADDRESS_IP4)) - Expect(vppMsg.Punt.RxSwIfIndex).To(BeEquivalentTo(uint32(1))) - Expect(vppMsg.Punt.TxSwIfIndex).To(BeEquivalentTo(uint32(2))) - //Expect(vppMsg.Nh).To(Equal([]uint8(net.ParseIP("10.0.0.1").To4()))) -} - -func TestAddIPRedirectAll(t *testing.T) { - ctx, puntHandler, ifIndexes := puntTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPPuntRedirectReply{}) - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - err := puntHandler.AddPuntRedirect(&punt.IPRedirect{ - L3Protocol: punt.L3Protocol_IPV4, - TxInterface: "if1", - NextHop: "30.0.0.1", - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPPuntRedirect) - Expect(ok).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeTrue()) - Expect(vppMsg.Punt.Nh.Af).To(Equal(ip_types.ADDRESS_IP4)) - Expect(vppMsg.Punt.RxSwIfIndex).To(BeEquivalentTo(^uint32(0))) - Expect(vppMsg.Punt.TxSwIfIndex).To(BeEquivalentTo(uint32(1))) - //Expect(vppMsg.Nh).To(Equal([]uint8(net.ParseIP("30.0.0.1").To4()))) -} - -func TestDeleteIPRedirect(t *testing.T) { - ctx, puntHandler, ifIndexes := puntTestSetup(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&vpp_ip.IPPuntRedirectReply{}) - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - ifIndexes.Put("if2", &ifaceidx.IfaceMetadata{SwIfIndex: 2}) - - err := puntHandler.DeletePuntRedirect(&punt.IPRedirect{ - L3Protocol: punt.L3Protocol_IPV4, - RxInterface: "if1", - TxInterface: "if2", - NextHop: "10.0.0.1", - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ip.IPPuntRedirect) - Expect(ok).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeFalse()) - //Expect(vppMsg.IsIP6).To(Equal(uint8(0))) - Expect(vppMsg.Punt.Nh.Af).To(Equal(ip_types.ADDRESS_IP4)) - Expect(vppMsg.Punt.RxSwIfIndex).To(BeEquivalentTo(uint32(1))) - Expect(vppMsg.Punt.TxSwIfIndex).To(BeEquivalentTo(uint32(2))) - //Expect(vppMsg.Nh).To(Equal([]uint8(net.ParseIP("10.0.0.1").To4()))) -} - -func puntTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.PuntVppAPI, ifaceidx.IfaceMetadataIndexRW) { - ctx := vppmock.SetupTestCtx(t) - logger := logrus.NewLogger("test-log") - ifIndexes := ifaceidx.NewIfaceIndex(logger, "punt-if-idx") - puntHandler := vpp2001.NewPuntVppHandler(ctx.MockChannel, ifIndexes, logrus.DefaultLogger()) - return ctx, puntHandler, ifIndexes -} diff --git a/plugins/vpp/puntplugin/vppcalls/vpp2001/vppcalls_handler.go b/plugins/vpp/puntplugin/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 12b474701d..0000000000 --- a/plugins/vpp/puntplugin/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - vpp_ip "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_punt "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/punt" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/puntplugin/vppcalls" -) - -func init() { - var msgs []govppapi.Message - msgs = append(msgs, vpp_ip.AllMessages()...) - msgs = append(msgs, vpp_punt.AllMessages()...) - - vppcalls.AddHandlerVersion(vpp2001.Version, msgs, NewPuntVppHandler) -} - -// PuntVppHandler is accessor for punt-related vppcalls methods. -type PuntVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// NewPuntVppHandler creates new instance of punt vppcalls handler -func NewPuntVppHandler( - callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger, -) vppcalls.PuntVppAPI { - return &PuntVppHandler{ - callsChannel: callsChan, - ifIndexes: ifIndexes, - log: log, - } -} - -func ipToAddress(ipstr string) (addr vpp_ip.Address, err error) { - netIP := net.ParseIP(ipstr) - if netIP == nil { - return vpp_ip.Address{}, fmt.Errorf("invalid IP: %q", ipstr) - } - if ip4 := netIP.To4(); ip4 == nil { - addr.Af = ip_types.ADDRESS_IP6 - var ip6addr vpp_ip.IP6Address - copy(ip6addr[:], netIP.To16()) - addr.Un.SetIP6(ip6addr) - } else { - addr.Af = ip_types.ADDRESS_IP4 - var ip4addr vpp_ip.IP4Address - copy(ip4addr[:], ip4) - addr.Un.SetIP4(ip4addr) - } - return -} diff --git a/plugins/vpp/srplugin/srplugin.go b/plugins/vpp/srplugin/srplugin.go index ac18101bbc..8393ff509f 100644 --- a/plugins/vpp/srplugin/srplugin.go +++ b/plugins/vpp/srplugin/srplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Bell Canada, Pantheon Technologies and/or its affiliates. +// Copyright (c) 2021 Bell Canada, Pantheon Technologies and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -29,7 +29,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/descriptor" "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/srplugin/vppcalls/vpp2001/srv6.go b/plugins/vpp/srplugin/vppcalls/vpp2001/srv6.go deleted file mode 100644 index 7fd6d57712..0000000000 --- a/plugins/vpp/srplugin/vppcalls/vpp2001/srv6.go +++ /dev/null @@ -1,646 +0,0 @@ -// Copyright (c) 2019 Bell Canada, Pantheon Technologies and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package vpp2001_379 contains wrappers over VPP (version 20.01) binary APIs to simplify their usage -package vpp2001 - -import ( - "context" - "fmt" - "net" - "regexp" - "strconv" - "strings" - - "go.ligato.io/cn-infra/v2/logging" - - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_sr "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/sr" - ifs "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/interfaces" - srv6 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/srv6" -) - -// Constants for behavior function hardcoded into VPP (there can be also custom behavior functions implemented as VPP plugins) -// Constants are taken from VPP's vnet/srv6/sr.h (names are modified to Golang from original C form in VPP code) -const ( - BehaviorEnd uint8 = iota + 1 // Behavior of simple endpoint - BehaviorX // Behavior of endpoint with Layer-3 cross-connect - BehaviorT // Behavior of endpoint with specific IPv6 table lookup - BehaviorDfirst // Unused. Separator in between regular and D - BehaviorDX2 // Behavior of endpoint with decapulation and Layer-2 cross-connect (or DX2 with egress VLAN rewrite when VLAN notzero - not supported this variant yet) - BehaviorDX6 // Behavior of endpoint with decapsulation and IPv6 cross-connect - BehaviorDX4 // Behavior of endpoint with decapsulation and IPv4 cross-connect - BehaviorDT6 // Behavior of endpoint with decapsulation and specific IPv6 table lookup - BehaviorDT4 // Behavior of endpoint with decapsulation and specific IPv4 table lookup - BehaviorLast // seems unused, note in VPP: "Must always be the last one" -) - -// Constants for steering type -// Constants are taken from VPP's vnet/srv6/sr.h (names are modified to Golang from original C form in VPP code) -const ( - SteerTypeL2 uint8 = 2 - SteerTypeIPv4 uint8 = 4 - SteerTypeIPv6 uint8 = 6 -) - -// Constants for operation of SR policy modify binary API method -const ( - AddSRList uint8 = iota + 1 // Add SR List to an existing SR policy - DeleteSRList // Delete SR List from an existing SR policy - ModifyWeightOfSRList // Modify the weight of an existing SR List -) - -// AddLocalSid adds local sid into VPP -func (h *SRv6VppHandler) AddLocalSid(localSID *srv6.LocalSID) error { - return h.addDelLocalSid(false, localSID) -} - -// DeleteLocalSid deletes local sid in VPP -func (h *SRv6VppHandler) DeleteLocalSid(localSID *srv6.LocalSID) error { - return h.addDelLocalSid(true, localSID) -} - -func (h *SRv6VppHandler) addDelLocalSid(deletion bool, localSID *srv6.LocalSID) error { - h.log.WithFields(logging.Fields{"localSID": localSID.GetSid(), "delete": deletion, "installationVrfID": h.installationVrfID(localSID), "end function": h.endFunction(localSID)}). - Debug("Adding/deleting Local SID", localSID.GetSid()) - sidAddr, err := parseIPv6(localSID.GetSid()) // parsing to get some standard sid form - if err != nil { - return fmt.Errorf("sid address %s is not IPv6 address: %v", localSID.GetSid(), err) // calls from descriptor are already validated - } - if !deletion && localSID.GetEndFunctionAd() != nil { - return h.addSRProxy(sidAddr, localSID) - } - req := &vpp_sr.SrLocalsidAddDel{ - IsDel: boolToUint(deletion), - Localsid: vpp_sr.Srv6Sid{Addr: []byte(sidAddr)}, - } - req.FibTable = localSID.InstallationVrfId // where to install localsid entry/from where to remove installed localsid entry - if !deletion { - if err := h.writeEndFunction(req, localSID); err != nil { - return err - } - } - reply := &vpp_sr.SrLocalsidAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - - h.log.WithFields(logging.Fields{"localSID": sidAddr, "delete": deletion, "installationVrfID": h.installationVrfID(localSID), "end function": h.endFunction(localSID)}). - Debug("Added/deleted Local SID ", sidAddr) - - return nil -} - -// addSRProxy adds local sid with SR-proxy end function (End.AD). This functionality has no binary API in VPP, therefore -// CLI commands are used (VPE binary API that calls VPP's CLI). -func (h *SRv6VppHandler) addSRProxy(sidAddr net.IP, localSID *srv6.LocalSID) error { - // get VPP-internal names of IN and OUT interfaces - names, err := h.interfaceNameMapping() - if err != nil { - return fmt.Errorf("can't convert interface names from etcd to VPP-internal interface names:%v", err) - } - outInterface, found := names[localSID.GetEndFunctionAd().OutgoingInterface] - if !found { - return fmt.Errorf("can't find VPP-internal name for interface %v (name in etcd)", localSID.GetEndFunctionAd().OutgoingInterface) - } - inInterface, found := names[localSID.GetEndFunctionAd().IncomingInterface] - if !found { - return fmt.Errorf("can't find VPP-internal name for interface %v (name in etcd)", localSID.GetEndFunctionAd().IncomingInterface) - } - - // add SR-proxy using VPP CLI - var cmd string - if strings.TrimSpace(localSID.GetEndFunctionAd().L3ServiceAddress) == "" { // L2 service - cmd = fmt.Sprintf("sr localsid address %v fib-table %v behavior end.ad oif %v iif %v", sidAddr, localSID.InstallationVrfId, outInterface, inInterface) - } else { // L3 service - cmd = fmt.Sprintf("sr localsid address %v fib-table %v behavior end.ad nh %v oif %v iif %v", sidAddr, localSID.InstallationVrfId, localSID.GetEndFunctionAd().L3ServiceAddress, outInterface, inInterface) - } - data, err := h.RunCli(context.TODO(), cmd) - if err != nil { - return err - } - if len(strings.TrimSpace(string(data))) > 0 { - return fmt.Errorf("addition of dynamic segment routing proxy failed by returning nonblank space text in CLI: %v", string(data)) - } - return nil -} - -// interfaceNameMapping dumps from VPP internal names of interfaces and uses them to produce mapping from ligato interface names to vpp internal names. -func (h *SRv6VppHandler) interfaceNameMapping() (map[string]string, error) { - mapping := make(map[string]string) - reqCtx := h.callsChannel.SendMultiRequest(&vpp_ifs.SwInterfaceDump{}) - - for { - // get next interface info - ifDetails := &vpp_ifs.SwInterfaceDetails{} - stop, err := reqCtx.ReceiveReply(ifDetails) - if stop { - break // Break from the loop. - } - if err != nil { - return nil, fmt.Errorf("failed to dump interface: %v", err) - } - - // extract and compute names - ligatoName := strings.TrimRight(ifDetails.Tag, "\x00") - vppInternalName := strings.TrimRight(ifDetails.InterfaceName, "\x00") - if ifDetails.SupSwIfIndex == uint32(ifDetails.SwIfIndex) && // no subinterface (subinterface are not DPDK) - guessInterfaceType(strings.TrimRight(ifDetails.InterfaceName, "\x00")) == ifs.Interface_DPDK { - // fill name for physical interfaces (they are mostly without tag) - ligatoName = vppInternalName - } - - mapping[ligatoName] = vppInternalName - } - return mapping, nil -} - -func (h *SRv6VppHandler) installationVrfID(localSID *srv6.LocalSID) string { - if localSID != nil { - return fmt.Sprint(localSID.InstallationVrfId) - } - return "" -} - -func (h *SRv6VppHandler) endFunction(localSID *srv6.LocalSID) string { - switch ef := localSID.GetEndFunction().(type) { - case *srv6.LocalSID_BaseEndFunction: - return fmt.Sprintf("End{psp: %v}", ef.BaseEndFunction.Psp) - case *srv6.LocalSID_EndFunctionX: - return fmt.Sprintf("X{psp: %v, OutgoingInterface: %v, NextHop: %v}", ef.EndFunctionX.Psp, ef.EndFunctionX.OutgoingInterface, ef.EndFunctionX.NextHop) - case *srv6.LocalSID_EndFunctionT: - return fmt.Sprintf("T{psp: %v, vrf: %v}", ef.EndFunctionT.Psp, ef.EndFunctionT.VrfId) - case *srv6.LocalSID_EndFunctionDx2: - return fmt.Sprintf("DX2{VlanTag: %v, OutgoingInterface: %v}", ef.EndFunctionDx2.VlanTag, ef.EndFunctionDx2.OutgoingInterface) - case *srv6.LocalSID_EndFunctionDx4: - return fmt.Sprintf("DX4{OutgoingInterface: %v, NextHop: %v}", ef.EndFunctionDx4.OutgoingInterface, ef.EndFunctionDx4.NextHop) - case *srv6.LocalSID_EndFunctionDx6: - return fmt.Sprintf("DX6{OutgoingInterface: %v, NextHop: %v}", ef.EndFunctionDx6.OutgoingInterface, ef.EndFunctionDx6.NextHop) - case *srv6.LocalSID_EndFunctionDt4: - return fmt.Sprintf("DT4{vrf: %v}", ef.EndFunctionDt4.VrfId) - case *srv6.LocalSID_EndFunctionDt6: - return fmt.Sprintf("DT6{vrf: %v}", ef.EndFunctionDt6.VrfId) - case *srv6.LocalSID_EndFunctionAd: - return fmt.Sprintf("AD{L3ServiceAddress: %v, OutgoingInterface: %v, IncomingInterface: %v}", ef.EndFunctionAd.L3ServiceAddress, ef.EndFunctionAd.OutgoingInterface, ef.EndFunctionAd.IncomingInterface) - case nil: - return "" - default: - return "unknown end function" - } -} - -func (h *SRv6VppHandler) writeEndFunction(req *vpp_sr.SrLocalsidAddDel, localSID *srv6.LocalSID) error { - switch ef := localSID.EndFunction.(type) { - case *srv6.LocalSID_BaseEndFunction: - req.Behavior = BehaviorEnd - req.EndPsp = boolToUint(ef.BaseEndFunction.Psp) - case *srv6.LocalSID_EndFunctionX: - req.Behavior = BehaviorX - req.EndPsp = boolToUint(ef.EndFunctionX.Psp) - ifMeta, exists := h.ifIndexes.LookupByName(ef.EndFunctionX.OutgoingInterface) - if !exists { - return fmt.Errorf("for interface %v doesn't exist sw index", ef.EndFunctionX.OutgoingInterface) - } - req.SwIfIndex = ifMeta.SwIfIndex - nhAddr, err := parseIPv6(ef.EndFunctionX.NextHop) // parses also ipv4 addresses but into ipv6 address form - if err != nil { - return err - } - if nhAddr4 := nhAddr.To4(); nhAddr4 != nil { // ipv4 address in ipv6 address form? - req.NhAddr4 = nhAddr4 - } else { - req.NhAddr6 = []byte(nhAddr) - } - case *srv6.LocalSID_EndFunctionT: - req.Behavior = BehaviorT - req.EndPsp = boolToUint(ef.EndFunctionT.Psp) - req.SwIfIndex = ef.EndFunctionT.VrfId - case *srv6.LocalSID_EndFunctionDx2: - req.Behavior = BehaviorDX2 - req.VlanIndex = ef.EndFunctionDx2.VlanTag - ifMeta, exists := h.ifIndexes.LookupByName(ef.EndFunctionDx2.OutgoingInterface) - if !exists { - return fmt.Errorf("for interface %v doesn't exist sw index", ef.EndFunctionDx2.OutgoingInterface) - } - req.SwIfIndex = ifMeta.SwIfIndex - case *srv6.LocalSID_EndFunctionDx4: - req.Behavior = BehaviorDX4 - ifMeta, exists := h.ifIndexes.LookupByName(ef.EndFunctionDx4.OutgoingInterface) - if !exists { - return fmt.Errorf("for interface %v doesn't exist sw index", ef.EndFunctionDx4.OutgoingInterface) - } - req.SwIfIndex = ifMeta.SwIfIndex - nhAddr, err := parseIPv6(ef.EndFunctionDx4.NextHop) // parses also IPv4 - if err != nil { - return err - } - nhAddr4 := nhAddr.To4() - if nhAddr4 == nil { - return fmt.Errorf("next hop of DX4 end function (%v) is not valid IPv4 address", ef.EndFunctionDx4.NextHop) - } - req.NhAddr4 = []byte(nhAddr4) - case *srv6.LocalSID_EndFunctionDx6: - req.Behavior = BehaviorDX6 - ifMeta, exists := h.ifIndexes.LookupByName(ef.EndFunctionDx6.OutgoingInterface) - if !exists { - return fmt.Errorf("for interface %v doesn't exist sw index", ef.EndFunctionDx6.OutgoingInterface) - } - req.SwIfIndex = ifMeta.SwIfIndex - nhAddr6, err := parseIPv6(ef.EndFunctionDx6.NextHop) - if err != nil { - return err - } - req.NhAddr6 = []byte(nhAddr6) - case *srv6.LocalSID_EndFunctionDt4: - req.Behavior = BehaviorDT4 - req.SwIfIndex = ef.EndFunctionDt4.VrfId - case *srv6.LocalSID_EndFunctionDt6: - req.Behavior = BehaviorDT6 - req.SwIfIndex = ef.EndFunctionDt6.VrfId - case nil: - return fmt.Errorf("End function not set. Please configure end function for local SID %v ", localSID.GetSid()) - default: - return fmt.Errorf("unknown end function (model link type %T)", ef) // EndFunction_AD is handled elsewhere - } - - return nil -} - -// SetEncapsSourceAddress sets for SRv6 in VPP the source address used for encapsulated packet -func (h *SRv6VppHandler) SetEncapsSourceAddress(address string) error { - h.log.Debugf("Configuring encapsulation source address to address %v", address) - ipAddress, err := parseIPv6(address) - if err != nil { - return err - } - req := &vpp_sr.SrSetEncapSource{ - EncapsSource: []byte(ipAddress), - } - reply := &vpp_sr.SrSetEncapSourceReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - - h.log.WithFields(logging.Fields{"Encapsulation source address": address}). - Debug("Encapsulation source address configured.") - - return nil -} - -// AddPolicy adds SRv6 policy into VPP (including all policy's segment lists). -func (h *SRv6VppHandler) AddPolicy(policy *srv6.Policy) error { - if err := h.addBasePolicyWithFirstSegmentList(policy); err != nil { - return fmt.Errorf("can't create Policy with first segment list (Policy: %+v): %v", policy, err) - } - if err := h.addOtherSegmentLists(policy); err != nil { - return fmt.Errorf("can't add all segment lists to created policy %+v: %v", policy, err) - } - return nil -} - -func (h *SRv6VppHandler) addBasePolicyWithFirstSegmentList(policy *srv6.Policy) error { - h.log.Debugf("Adding SR policy %+v", policy) - bindingSid, err := parseIPv6(policy.GetBsid()) // already validated - if err != nil { - return fmt.Errorf("binding sid address %s is not IPv6 address: %v", policy.GetBsid(), err) // calls from descriptor are already validated - } - if len(policy.SegmentLists) == 0 { - return fmt.Errorf("policy must have defined at least one segment list (Policy: %+v)", policy) // calls from descriptor are already validated - } - sids, err := h.convertPolicySegment(policy.SegmentLists[0]) - if err != nil { - return err - } - // Note: Weight in sr.SrPolicyAdd is leftover from API changes that moved weight into sr.Srv6SidList (it is weight of sid list not of the whole policy) - req := &vpp_sr.SrPolicyAdd{ - BsidAddr: []byte(bindingSid), - Sids: *sids, - IsEncap: boolToUint(policy.SrhEncapsulation), - Type: boolToUint(policy.SprayBehaviour), - FibTable: policy.InstallationVrfId, - } - reply := &vpp_sr.SrPolicyAddReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - - h.log.WithFields(logging.Fields{"binding SID": bindingSid, "list of next SIDs": policy.SegmentLists[0].Segments}). - Debug("base SR policy (policy with just one segment list) added") - - return nil -} - -func (h *SRv6VppHandler) addOtherSegmentLists(policy *srv6.Policy) error { - for _, sl := range policy.SegmentLists[1:] { - if err := h.AddPolicySegmentList(sl, policy); err != nil { - return fmt.Errorf("failed to add policy segment %+v: %v", sl, err) - } - } - return nil -} - -// DeletePolicy deletes SRv6 policy given by binding SID -func (h *SRv6VppHandler) DeletePolicy(bindingSid net.IP) error { - h.log.Debugf("Deleting SR policy with binding SID %v ", bindingSid) - req := &vpp_sr.SrPolicyDel{ - BsidAddr: vpp_sr.Srv6Sid{Addr: []byte(bindingSid)}, // TODO add ability to define policy also by index (SrPolicyIndex) - } - reply := &vpp_sr.SrPolicyDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - - h.log.WithFields(logging.Fields{"binding SID": bindingSid}).Debug("SR policy deleted") - - return nil -} - -// AddPolicySegmentList adds segment list to SRv6 policy in VPP -func (h *SRv6VppHandler) AddPolicySegmentList(segmentList *srv6.Policy_SegmentList, policy *srv6.Policy) error { - h.log.Debugf("Adding segment %+v to SR policy %+v", segmentList, policy) - err := h.modPolicy(AddSRList, policy, segmentList, 0) - if err == nil { - h.log.WithFields(logging.Fields{"binding SID": policy.Bsid, "list of next SIDs": segmentList.Segments}). - Debug("SR policy modified(added another segment list)") - } - return err -} - -// DeletePolicySegmentList removes segment list (with VPP-internal index ) from SRv6 policy in VPP -func (h *SRv6VppHandler) DeletePolicySegmentList(segmentList *srv6.Policy_SegmentList, segmentVPPIndex uint32, policy *srv6.Policy) error { - h.log.Debugf("Removing segment %+v (vpp-internal index %v) from SR policy %+v", segmentList, segmentVPPIndex, policy) - err := h.modPolicy(DeleteSRList, policy, segmentList, segmentVPPIndex) - if err == nil { - h.log.WithFields(logging.Fields{"binding SID": policy.Bsid, "list of next SIDs": segmentList.Segments, "segmentListIndex": segmentVPPIndex}). - Debug("SR policy modified(removed segment list)") - } - return err -} - -func (h *SRv6VppHandler) modPolicy(operation uint8, policy *srv6.Policy, segmentList *srv6.Policy_SegmentList, segmentListIndex uint32) error { - bindingSid, err := parseIPv6(policy.GetBsid()) - if err != nil { - return fmt.Errorf("binding sid address %s is not IPv6 address: %v", policy.GetBsid(), err) // calls from descriptor are already validated - } - sids, err := h.convertPolicySegment(segmentList) - if err != nil { - return err - } - - // Note: Weight in sr.SrPolicyMod is leftover from API changes that moved weight into sr.Srv6SidList (it is weight of sid list not of the whole policy) - req := &vpp_sr.SrPolicyMod{ - BsidAddr: []byte(bindingSid), // TODO add ability to define policy also by index (SrPolicyIndex) - Operation: operation, - Sids: *sids, - FibTable: policy.InstallationVrfId, - } - if operation == DeleteSRList || operation == ModifyWeightOfSRList { - req.SlIndex = segmentListIndex - } - - reply := &vpp_sr.SrPolicyModReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - return nil -} - -func (h *SRv6VppHandler) convertPolicySegment(segmentList *srv6.Policy_SegmentList) (*vpp_sr.Srv6SidList, error) { - var segments []vpp_sr.Srv6Sid - for _, sid := range segmentList.Segments { - // parse to IPv6 address - parserSid, err := parseIPv6(sid) - if err != nil { - return nil, err - } - - // add sid to segment list - ipv6Segment := vpp_sr.Srv6Sid{ - Addr: make([]byte, 16), // sr.Srv6Sid.Addr = [16]byte - } - copy(ipv6Segment.Addr, parserSid) - segments = append(segments, ipv6Segment) - } - return &vpp_sr.Srv6SidList{ - NumSids: uint8(len(segments)), - Sids: segments, - Weight: segmentList.Weight, - }, nil -} - -// RetrievePolicyIndexInfo retrieves index of policy and its segment lists -func (h *SRv6VppHandler) RetrievePolicyIndexInfo(policy *srv6.Policy) (policyIndex uint32, segmentListIndexes map[*srv6.Policy_SegmentList]uint32, err error) { - // dump sr policies using VPP CLI - data, err := h.RunCli(context.TODO(), "sh sr policies") - if err != nil { - return ^uint32(0), nil, fmt.Errorf("can't dump index data from VPP: %v", err) - } - - // do necessary parsing to extract index of segment list - dumpStr := strings.ToLower(string(data)) - segmentListIndexes = make(map[*srv6.Policy_SegmentList]uint32) - - for _, policyStr := range strings.Split(dumpStr, "-----------") { - policyHeader := regexp.MustCompile(fmt.Sprintf("\\[(\\d+)\\]\\.-\\s+bsid:\\s*%s", strings.ToLower(strings.TrimSpace(policy.GetBsid())))) - if policyMatch := policyHeader.FindStringSubmatch(policyStr); policyMatch != nil { - parsed, err := strconv.ParseUint(policyMatch[1], 10, 32) - if err != nil { - return ^uint32(0), nil, fmt.Errorf("can't parse policy index %q (dump: %s)", policyMatch[1], dumpStr) - } - policyIndex = uint32(parsed) - - for _, sl := range policy.SegmentLists { - slRE := regexp.MustCompile(fmt.Sprintf("\\[(\\d+)\\].- < %s,[^:>]*> weight: %d", strings.ToLower(strings.Join(sl.Segments, ", ")), sl.Weight)) - if slMatch := slRE.FindStringSubmatch(policyStr); slMatch != nil { - parsed, err := strconv.ParseUint(slMatch[1], 10, 32) - if err != nil { - return ^uint32(0), nil, fmt.Errorf("can't parse segment policy index %q (dump: %s)", slMatch[1], dumpStr) - } - segmentListIndexes[sl] = uint32(parsed) - continue - } - return ^uint32(0), nil, fmt.Errorf("can't find index for segment list %+v (policy bsid %v) in dump %q", sl, policy.GetBsid(), dumpStr) - } - return policyIndex, segmentListIndexes, nil - } - } - return ^uint32(0), nil, fmt.Errorf("can't find index for policy with bsid %v in dump %q", policy.GetBsid(), dumpStr) -} - -// AddSteering sets in VPP steering into SRv6 policy. -func (h *SRv6VppHandler) AddSteering(steering *srv6.Steering) error { - return h.addDelSteering(false, steering) -} - -// RemoveSteering removes in VPP steering into SRv6 policy. -func (h *SRv6VppHandler) RemoveSteering(steering *srv6.Steering) error { - return h.addDelSteering(true, steering) -} - -func (h *SRv6VppHandler) addDelSteering(delete bool, steering *srv6.Steering) error { - // defining operation strings for logging - operationProgressing, operationFinished := "Adding", "Added" - if delete { - operationProgressing, operationFinished = "Removing", "Removed" - } - - // logging info about operation with steering - switch t := steering.Traffic.(type) { - case *srv6.Steering_L3Traffic_: - h.log.Debugf("%v steering for l3 traffic with destination %v to SR policy (binding SID %v, policy index %v)", - operationProgressing, t.L3Traffic.PrefixAddress, steering.GetPolicyBsid(), steering.GetPolicyIndex()) - case *srv6.Steering_L2Traffic_: - h.log.Debugf("%v steering for l2 traffic from interface %v to SR policy (binding SID %v, policy index %v)", - operationProgressing, t.L2Traffic.InterfaceName, steering.GetPolicyBsid(), steering.GetPolicyIndex()) - } - - // converting policy reference - var policyBSIDAddr []byte // undefined reference - var policyIndex = uint32(0) // undefined reference - switch ref := steering.PolicyRef.(type) { - case *srv6.Steering_PolicyBsid: - bsid, err := parseIPv6(ref.PolicyBsid) - if err != nil { - return fmt.Errorf("can't parse binding SID %q to IP address: %v ", ref.PolicyBsid, err) - } - policyBSIDAddr = []byte(bsid) - case *srv6.Steering_PolicyIndex: - policyIndex = ref.PolicyIndex - case nil: - return fmt.Errorf("policy reference must be provided") - default: - return fmt.Errorf("unknown policy reference type (link type %+v)", ref) - } - - // converting target traffic info - var prefixAddr []byte - steerType := SteerTypeIPv6 - tableID := uint32(0) - maskWidth := uint32(0) - intIndex := uint32(0) - switch t := steering.Traffic.(type) { - case *srv6.Steering_L3Traffic_: - ip, ipnet, err := net.ParseCIDR(t.L3Traffic.PrefixAddress) - if err != nil { - return fmt.Errorf("can't parse ip prefix %q: %v", t.L3Traffic.PrefixAddress, err) - } - if ip.To4() != nil { // IPv4 address - steerType = SteerTypeIPv4 - } - tableID = t.L3Traffic.InstallationVrfId - prefixAddr = []byte(ip.To16()) - ms, _ := ipnet.Mask.Size() - maskWidth = uint32(ms) - case *srv6.Steering_L2Traffic_: - steerType = SteerTypeL2 - ifMeta, exists := h.ifIndexes.LookupByName(t.L2Traffic.InterfaceName) - if !exists { - return fmt.Errorf("for interface %v doesn't exist sw index", t.L2Traffic.InterfaceName) - } - intIndex = ifMeta.SwIfIndex - case nil: - return fmt.Errorf("traffic type must be provided") - default: - return fmt.Errorf("unknown traffic type (link type %+v)", t) - } - req := &vpp_sr.SrSteeringAddDel{ - IsDel: boolToUint(delete), - TableID: tableID, - BsidAddr: policyBSIDAddr, // policy (to which we want to steer routing into) identified by policy binding sid (alternativelly it can be used policy index) - SrPolicyIndex: policyIndex, // policy (to which we want to steer routing into) identified by policy index (alternativelly it can be used policy binding sid) - TrafficType: steerType, // type of traffic to steer - PrefixAddr: prefixAddr, // destination prefix address (L3 traffic type only) - MaskWidth: maskWidth, // destination ip prefix mask (L3 traffic type only) - SwIfIndex: intIndex, // incoming interface (L2 traffic type only) - } - reply := &vpp_sr.SrSteeringAddDelReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - if reply.Retval != 0 { - return fmt.Errorf("vpp call %q returned: %d", reply.GetMessageName(), reply.Retval) - } - - h.log.WithFields(logging.Fields{"steer type": steerType, "L3 prefix address bytes": prefixAddr, - "L2 interface index": intIndex, "policy binding SID": policyBSIDAddr, "policy index": policyIndex}). - Debugf("%v steering to SR policy ", operationFinished) - - return nil -} - -func boolToUint(input bool) uint8 { - if input { - return uint8(1) - } - return uint8(0) -} - -// parseIPv6 parses string to IPv6 address (including IPv4 address converted to IPv6 address) -func parseIPv6(str string) (net.IP, error) { - ip := net.ParseIP(str) - if ip == nil { - return nil, fmt.Errorf(" %q is not ip address", str) - } - ipv6 := ip.To16() - if ipv6 == nil { - return nil, fmt.Errorf(" %q is not ipv6 address", str) - } - return ipv6, nil -} - -// guessInterfaceType attempts to guess the correct interface type from its internal name (as given by VPP). -// This is required mainly for those interface types, that do not provide dump binary API, -// such as loopback of af_packet. -func guessInterfaceType(ifName string) ifs.Interface_Type { - switch { - case strings.HasPrefix(ifName, "loop"), - strings.HasPrefix(ifName, "local"): - return ifs.Interface_SOFTWARE_LOOPBACK - case strings.HasPrefix(ifName, "memif"): - return ifs.Interface_MEMIF - case strings.HasPrefix(ifName, "tap"): - return ifs.Interface_TAP - case strings.HasPrefix(ifName, "host"): - return ifs.Interface_AF_PACKET - case strings.HasPrefix(ifName, "vxlan"): - return ifs.Interface_VXLAN_TUNNEL - case strings.HasPrefix(ifName, "ipsec"): - return ifs.Interface_IPSEC_TUNNEL - case strings.HasPrefix(ifName, "vmxnet3"): - return ifs.Interface_VMXNET3_INTERFACE - default: - return ifs.Interface_DPDK - } -} diff --git a/plugins/vpp/srplugin/vppcalls/vpp2001/srv6_dump.go b/plugins/vpp/srplugin/vppcalls/vpp2001/srv6_dump.go deleted file mode 100644 index b9c73ce0bd..0000000000 --- a/plugins/vpp/srplugin/vppcalls/vpp2001/srv6_dump.go +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2019 Pantheon.tech -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - "github.com/go-errors/errors" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/sr" - srv6 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/srv6" -) - -// DumpLocalSids retrieves all localsids -func (h *SRv6VppHandler) DumpLocalSids() (localsids []*srv6.LocalSID, err error) { - h.log.Debug("Dumping LocalSIDs") - - reqCtx := h.callsChannel.SendMultiRequest(&sr.SrLocalsidsDump{}) - for { - // retrieve dump for another localsid - dumpReply := &sr.SrLocalsidsDetails{} - stop, err := reqCtx.ReceiveReply(dumpReply) - if stop { - break - } - if err != nil { - return nil, errors.Errorf("error while retrieving localsid details:%v", err) - } - - // convert dumped localsid details into modeled Localsid struct - sid, error := h.convertDumpedSid(&dumpReply.Addr) - if error != nil { - return localsids, errors.Errorf("can't properly handle sid address "+ - "of dumped localsid %v due to: %v", dumpReply, err) - } - localsid := &srv6.LocalSID{ - InstallationVrfId: dumpReply.FibTable, - Sid: sid.String(), - } - if err := h.fillEndFunction(localsid, dumpReply); err != nil { - return localsids, errors.Errorf("can't properly handle end function "+ - "of dumped localsid %v due to: %v", dumpReply, err) - } - - // collect all dumped localsids - localsids = append(localsids, localsid) - } - - return localsids, nil -} - -// convertDumpedSid extract from dumped structure SID value and converts it to IPv6 (net.IP) -func (h *SRv6VppHandler) convertDumpedSid(srv6Sid *sr.Srv6Sid) (net.IP, error) { - if srv6Sid == nil || srv6Sid.Addr == nil { - return nil, errors.New("can't convert sid from nil dumped address (or nil srv6sid)") - } - sid := net.IP(srv6Sid.Addr).To16() - if sid == nil { - return nil, errors.Errorf("can't convert dumped SID bytes(%v) to net.IP", srv6Sid.Addr) - } - return sid, nil -} - -// fillEndFunction create end function part of NB-modeled localsid from SB-dumped structure -func (h *SRv6VppHandler) fillEndFunction(localSID *srv6.LocalSID, dumpReply *sr.SrLocalsidsDetails) error { - switch uint8(dumpReply.Behavior) { - case BehaviorEnd: - localSID.EndFunction = &srv6.LocalSID_BaseEndFunction{ - BaseEndFunction: &srv6.LocalSID_End{ - Psp: uintToBool(dumpReply.EndPsp), - }, - } - case BehaviorX: - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(dumpReply.XconnectIfaceOrVrfTable) - if !exists { - return errors.Errorf("there is no interface with sw index %v", dumpReply.XconnectIfaceOrVrfTable) - } - localSID.EndFunction = &srv6.LocalSID_EndFunctionX{ - EndFunctionX: &srv6.LocalSID_EndX{ - Psp: uintToBool(dumpReply.EndPsp), - OutgoingInterface: ifName, - NextHop: h.nextHop(dumpReply), - }, - } - case BehaviorT: - localSID.EndFunction = &srv6.LocalSID_EndFunctionT{ - EndFunctionT: &srv6.LocalSID_EndT{ - Psp: uintToBool(dumpReply.EndPsp), - VrfId: dumpReply.XconnectIfaceOrVrfTable, - }, - } - case BehaviorDX2: - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(dumpReply.XconnectIfaceOrVrfTable) - if !exists { - return errors.Errorf("there is no interface with sw index %v", dumpReply.XconnectIfaceOrVrfTable) - } - localSID.EndFunction = &srv6.LocalSID_EndFunctionDx2{ - EndFunctionDx2: &srv6.LocalSID_EndDX2{ - VlanTag: dumpReply.VlanIndex, - OutgoingInterface: ifName, - }, - } - case BehaviorDX4: - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(dumpReply.XconnectIfaceOrVrfTable) - if !exists { - return errors.Errorf("there is no interface with sw index %v", dumpReply.XconnectIfaceOrVrfTable) - } - localSID.EndFunction = &srv6.LocalSID_EndFunctionDx4{ - EndFunctionDx4: &srv6.LocalSID_EndDX4{ - OutgoingInterface: ifName, - NextHop: h.nextHop(dumpReply), - }, - } - case BehaviorDX6: - ifName, _, exists := h.ifIndexes.LookupBySwIfIndex(dumpReply.XconnectIfaceOrVrfTable) - if !exists { - return errors.Errorf("there is no interface with sw index %v", dumpReply.XconnectIfaceOrVrfTable) - } - localSID.EndFunction = &srv6.LocalSID_EndFunctionDx6{ - EndFunctionDx6: &srv6.LocalSID_EndDX6{ - OutgoingInterface: ifName, - NextHop: h.nextHop(dumpReply), - }, - } - case BehaviorDT4: - localSID.EndFunction = &srv6.LocalSID_EndFunctionDt4{ - EndFunctionDt4: &srv6.LocalSID_EndDT4{ - VrfId: dumpReply.XconnectIfaceOrVrfTable, - }, - } - case BehaviorDT6: - localSID.EndFunction = &srv6.LocalSID_EndFunctionDt6{ - EndFunctionDt6: &srv6.LocalSID_EndDT6{ - VrfId: dumpReply.XconnectIfaceOrVrfTable, - }, - } - default: - return errors.Errorf("localsid with unknown or unsupported behavior (%v)", dumpReply.Behavior) - } - - return nil -} - -// nextHop transforms SB dump data about next hop to NB modeled structure -func (h *SRv6VppHandler) nextHop(dumpReply *sr.SrLocalsidsDetails) string { - nh4 := net.IP(dumpReply.XconnectNhAddr4) - nh6 := net.IP(dumpReply.XconnectNhAddr6) - nhStr := "" - // default is no next hop address (i.e. L2 xconnect) - if nh4 != nil && !nh4.Equal(net.IPv4zero) { - nhStr = nh4.String() - } else if nh6 != nil && !nh6.Equal(net.IPv6zero) { - nhStr = nh6.String() - } - return nhStr -} - -func uintToBool(input uint8) bool { - return input != 0 -} diff --git a/plugins/vpp/srplugin/vppcalls/vpp2001/srv6_test.go b/plugins/vpp/srplugin/vppcalls/vpp2001/srv6_test.go deleted file mode 100644 index a0bcbdc15c..0000000000 --- a/plugins/vpp/srplugin/vppcalls/vpp2001/srv6_test.go +++ /dev/null @@ -1,1519 +0,0 @@ -// Copyright (c) 2019 Bell Canada, Pantheon Technologies and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "fmt" - "net" - "testing" - - govppapi "git.fd.io/govpp.git/api" - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interfaces" - vpp_sr "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/sr" - vpp_vpe "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - srv6 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/srv6" -) - -const ( - ifaceA = "A" - ifaceB = "B" - ifaceBOutOfidxs = "B" - swIndexA uint32 = 1 - invalidIPAddress = "XYZ" - memif1 = "memif1/1" - memif2 = "memif2/2" -) - -var ( - sidA = *sid("A::") - sidB = *sid("B::") - sidC = *sid("C::") - nextHop = net.ParseIP("B::").To16() - nextHopIPv4 = net.ParseIP("1.2.3.4").To4() -) - -// TODO add tests for new nhAddr4 field in end behaviours -// TestAddLocalSID tests all cases for method AddLocalSID -func TestAddLocalSID(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - FailInVPP bool - FailInVPPDump bool - ExpectFailure bool - cliMode bool // sr-proxy can be se only using CLI -> using VPE binary API to send VPP CLI commands - MockInterfaceDump []govppapi.Message - Input *srv6.LocalSID - Expected govppapi.Message - }{ - { - Name: "addition with end behaviour", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_BaseEndFunction{ - BaseEndFunction: &srv6.LocalSID_End{ - Psp: true, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorEnd, - FibTable: 10, // installationVrfId - EndPsp: 1, - }, - }, - { - Name: "addition with endX behaviour (ipv6 next hop address)", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionX{ - EndFunctionX: &srv6.LocalSID_EndX{ - Psp: true, - NextHop: nextHop.String(), - OutgoingInterface: ifaceA, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorX, - FibTable: 10, // installationVrfId - EndPsp: 1, - SwIfIndex: swIndexA, - NhAddr6: nextHop, - }, - }, - { - Name: "addition with endX behaviour (ipv4 next hop address)", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionX{ - EndFunctionX: &srv6.LocalSID_EndX{ - Psp: true, - NextHop: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorX, - FibTable: 10, // installationVrfId - EndPsp: 1, - SwIfIndex: swIndexA, - NhAddr4: nextHopIPv4, - }, - }, - { - Name: "addition with endT behaviour", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionT{ - EndFunctionT: &srv6.LocalSID_EndT{ - Psp: true, - VrfId: 11, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorT, - FibTable: 10, // installationVrfId - SwIfIndex: 11, - EndPsp: 1, - }, - }, - { - Name: "addition with endDX2 behaviour", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx2{ - EndFunctionDx2: &srv6.LocalSID_EndDX2{ - VlanTag: 1, - OutgoingInterface: ifaceA, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorDX2, - FibTable: 10, // installationVrfId - EndPsp: 0, - VlanIndex: 1, - SwIfIndex: swIndexA, - }, - }, - { - Name: "addition with endDX4 behaviour", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx4{ - EndFunctionDx4: &srv6.LocalSID_EndDX4{ - NextHop: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorDX4, - FibTable: 10, // installationVrfId - EndPsp: 0, - SwIfIndex: swIndexA, - NhAddr4: nextHopIPv4, - }, - }, - { - Name: "addition with endDX6 behaviour", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx6{ - EndFunctionDx6: &srv6.LocalSID_EndDX6{ - NextHop: nextHop.String(), - OutgoingInterface: ifaceA, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorDX6, - FibTable: 10, // installationVrfId - EndPsp: 0, - SwIfIndex: swIndexA, - NhAddr6: nextHop, - }, - }, - { - Name: "addition with endDT4 behaviour", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDt4{ - EndFunctionDt4: &srv6.LocalSID_EndDT4{ - VrfId: 5, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorDT4, - FibTable: 10, // installationVrfId - SwIfIndex: 5, - EndPsp: 0, - }, - }, - { - Name: "addition with endDT6 behaviour", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDt6{ - EndFunctionDt6: &srv6.LocalSID_EndDT6{ - VrfId: 5, - }, - }, - }, - Expected: &vpp_sr.SrLocalsidAddDel{ - IsDel: 0, - Localsid: sidA, - Behavior: vpp2001.BehaviorDT6, - FibTable: 10, // installationVrfId - SwIfIndex: 5, - EndPsp: 0, - }, - }, - { - Name: "addition with endAD behaviour (+ memif interface name translation)", - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: memif1}, - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: memif2}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - Expected: &vpp_vpe.CliInband{ - Cmd: fmt.Sprintf("sr localsid address %v fib-table 10 behavior end.ad nh %v oif %v iif %v", sidToStr(sidA), nextHopIPv4.String(), memif1, memif2), - }, - }, - { - Name: "addition with endAD behaviour for L2 sr-unaware service", - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: memif1}, - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: memif2}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ //missing L3ServiceAddress means it is L2 service - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - Expected: &vpp_vpe.CliInband{ - Cmd: fmt.Sprintf("sr localsid address %v fib-table 10 behavior end.ad oif %v iif %v", sidToStr(sidA), memif1, memif2), - }, - }, - { - Name: "etcd-to-vpp-internal interface name translation for endAD behaviour (local and tap kind of interfaces)", - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: "local0"}, - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: "tap0"}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - Expected: &vpp_vpe.CliInband{ - Cmd: fmt.Sprintf("sr localsid address %v fib-table 10 behavior end.ad nh %v oif %v iif %v", sidToStr(sidA), nextHopIPv4.String(), "local0", "tap0"), - }, - }, - { - Name: "etcd-to-vpp-internal interface name translation for endAD behaviour (host and vxlan kind of interfaces)", - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: "host0"}, - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: "vxlan0"}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - Expected: &vpp_vpe.CliInband{ - Cmd: fmt.Sprintf("sr localsid address %v fib-table 10 behavior end.ad nh %v oif %v iif %v", sidToStr(sidA), nextHopIPv4.String(), "host0", "vxlan0"), - }, - }, - { - Name: "etcd-to-vpp-internal interface name translation for endAD behaviour (ipsec and vmxnet3 kind of interfaces)", - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: "ipsec0"}, - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: "vmxnet3-0"}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - Expected: &vpp_vpe.CliInband{ - Cmd: fmt.Sprintf("sr localsid address %v fib-table 10 behavior end.ad nh %v oif %v iif %v", sidToStr(sidA), nextHopIPv4.String(), "ipsec0", "vmxnet3-0"), - }, - }, - { - Name: "etcd-to-vpp-internal interface name translation for endAD behaviour (loop and unknown kind of interfaces)", - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: "loop0"}, - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: "unknown0"}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: "unknown0", // interface name is taken from vpp internal name - }, - }, - }, - Expected: &vpp_vpe.CliInband{ - Cmd: fmt.Sprintf("sr localsid address %v fib-table 10 behavior end.ad nh %v oif %v iif %v", sidToStr(sidA), nextHopIPv4.String(), "loop0", "unknown0"), - }, - }, - { - Name: "fail due to missing end function", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 0, - }, - }, - { - Name: "failure propagation from VPP (doing main VPP call)", - FailInVPP: true, - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 0, - EndFunction: &srv6.LocalSID_BaseEndFunction{ - BaseEndFunction: &srv6.LocalSID_End{ - Psp: true, - }, - }, - }, - }, - { - Name: "failure propagation from VPP (doing main VPP call) for SR-proxy (CLI using VPE binary API)", - FailInVPP: true, - ExpectFailure: true, - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: memif1}, - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: memif2}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - }, - { - Name: "failure propagation from VPP Dump call", - FailInVPPDump: true, - ExpectFailure: true, - cliMode: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - }, - { - Name: "missing SR-proxy outgoing interface in VPP interface dump", - ExpectFailure: true, - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceB, InterfaceName: memif2}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - }, - { - Name: "missing SR-proxy incoming interface in VPP interface dump", - ExpectFailure: true, - cliMode: true, - MockInterfaceDump: []govppapi.Message{ - &vpp_ifs.SwInterfaceDetails{Tag: ifaceA, InterfaceName: memif1}, - }, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionAd{ - EndFunctionAd: &srv6.LocalSID_EndAD{ - L3ServiceAddress: nextHopIPv4.String(), - OutgoingInterface: ifaceA, - IncomingInterface: ifaceB, - }, - }, - }, - }, - { - Name: "missing interface in swIndexes (addition with endX behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionX{ - EndFunctionX: &srv6.LocalSID_EndX{ - Psp: true, - NextHop: nextHop.String(), - OutgoingInterface: ifaceBOutOfidxs, - }, - }, - }, - }, - { - Name: "invalid IP address (addition with endX behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionX{ - EndFunctionX: &srv6.LocalSID_EndX{ - Psp: true, - NextHop: invalidIPAddress, - OutgoingInterface: ifaceA, - }, - }, - }, - }, - { - Name: "missing interface in swIndexes (addition with endDX2 behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx2{ - EndFunctionDx2: &srv6.LocalSID_EndDX2{ - VlanTag: 1, - OutgoingInterface: ifaceBOutOfidxs, - }, - }, - }, - }, - { - Name: "missing interface in swIndexes (addition with endDX4 behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx4{ - EndFunctionDx4: &srv6.LocalSID_EndDX4{ - NextHop: nextHopIPv4.String(), - OutgoingInterface: ifaceBOutOfidxs, - }, - }, - }, - }, - { - Name: "invalid IP address (addition with endDX4 behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx4{ - EndFunctionDx4: &srv6.LocalSID_EndDX4{ - NextHop: invalidIPAddress, - OutgoingInterface: ifaceA, - }, - }, - }, - }, - { - Name: "rejection of IPv6 addresses (addition with endDX4 behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx4{ - EndFunctionDx4: &srv6.LocalSID_EndDX4{ - NextHop: nextHop.String(), - OutgoingInterface: ifaceA, - }, - }, - }, - }, - { - Name: "missing interface in swIndexes (addition with endDX6 behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx6{ - EndFunctionDx6: &srv6.LocalSID_EndDX6{ - NextHop: nextHop.String(), - OutgoingInterface: ifaceBOutOfidxs, - }, - }, - }, - }, - { - Name: "invalid IP address (addition with endDX6 behaviour)", - ExpectFailure: true, - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_EndFunctionDx6{ - EndFunctionDx6: &srv6.LocalSID_EndDX6{ - NextHop: invalidIPAddress, - OutgoingInterface: ifaceA, - }, - }, - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply - if td.MockInterfaceDump != nil { - if td.FailInVPPDump { - ctx.MockVpp.MockReply(&vpp_sr.SrPolicyDelReply{}) //unexpected type of message creates error (swInterfaceDetail doesn't have way how to indicate failure) - } else { - ctx.MockVpp.MockReply(td.MockInterfaceDump...) - ctx.MockVpp.MockReply(&vpp_vpe.ControlPingReply{}) - } - } - if td.cliMode && !td.FailInVPPDump { // SR-proxy can be set only using VPP CLI (-> using VPE binary API to deliver command to VPP) - if td.FailInVPP { - ctx.MockVpp.MockReply(&vpp_vpe.CliInbandReply{Retval: 1}) - } else { - ctx.MockVpp.MockReply(&vpp_vpe.CliInbandReply{}) - } - } else { // normal SR binary API - if td.FailInVPP { - ctx.MockVpp.MockReply(&vpp_sr.SrLocalsidAddDelReply{Retval: 1}) - } else { - ctx.MockVpp.MockReply(&vpp_sr.SrLocalsidAddDelReply{}) - } - } - // make the call - err := vppCalls.AddLocalSid(td.Input) - // verify result - if td.ExpectFailure { - Expect(err).Should(HaveOccurred()) - } else { - Expect(err).ShouldNot(HaveOccurred()) - Expect(ctx.MockChannel.Msg).To(Equal(td.Expected)) - } - }) - } -} - -// TestDeleteLocalSID tests all cases for method DeleteLocalSID -func TestDeleteLocalSID(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - Fail bool - Input *srv6.LocalSID - MockReply govppapi.Message - Verify func(error, govppapi.Message) - }{ - { - Name: "simple delete of local sid (using vrf table with id 0)", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 0, - EndFunction: &srv6.LocalSID_BaseEndFunction{ - BaseEndFunction: &srv6.LocalSID_End{ - Psp: true, - }, - }, - }, - MockReply: &vpp_sr.SrLocalsidAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrLocalsidAddDel{ - IsDel: 1, - Localsid: sidA, - FibTable: 0, - })) - }, - }, - { - Name: "simple delete of local sid (using vrf table with nonzero id)", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 10, - EndFunction: &srv6.LocalSID_BaseEndFunction{ - BaseEndFunction: &srv6.LocalSID_End{ - Psp: true, - }, - }, - }, - MockReply: &vpp_sr.SrLocalsidAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrLocalsidAddDel{ - IsDel: 1, - Localsid: sidA, - FibTable: 10, - })) - }, - }, - { - Name: "failure propagation from VPP", - Input: &srv6.LocalSID{ - Sid: sidToStr(sidA), - InstallationVrfId: 0, - EndFunction: &srv6.LocalSID_BaseEndFunction{ - BaseEndFunction: &srv6.LocalSID_End{ - Psp: true, - }, - }, - }, - MockReply: &vpp_sr.SrLocalsidAddDelReply{Retval: 1}, - Verify: func(err error, msg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare for case - ctx.MockVpp.MockReply(td.MockReply) - // make the call and verify - err := vppCalls.DeleteLocalSid(td.Input) - td.Verify(err, ctx.MockChannel.Msg) - }) - } -} - -// TestSetEncapsSourceAddress tests all cases for method SetEncapsSourceAddress -func TestSetEncapsSourceAddress(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - Fail bool - Address string - MockReply govppapi.Message - Verify func(error, govppapi.Message) - }{ - { - Name: "simple SetEncapsSourceAddress", - Address: nextHop.String(), - MockReply: &vpp_sr.SrSetEncapSourceReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrSetEncapSource{ - EncapsSource: nextHop, - })) - }, - }, - { - Name: "invalid IP address", - Address: invalidIPAddress, - MockReply: &vpp_sr.SrSetEncapSourceReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "failure propagation from VPP", - Address: nextHop.String(), - MockReply: &vpp_sr.SrSetEncapSourceReply{Retval: 1}, - Verify: func(err error, msg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - - ctx.MockVpp.MockReply(td.MockReply) - err := vppCalls.SetEncapsSourceAddress(td.Address) - td.Verify(err, ctx.MockChannel.Msg) - }) - } -} - -// TestAddPolicy tests all cases for method AddPolicy -func TestAddPolicy(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - Fail bool - Policy *srv6.Policy - MockReplies []govppapi.Message - Verify func(error, []govppapi.Message) - }{ - { - Name: "simple SetAddPolicy", - Policy: policy(sidA.Addr, 10, false, true, policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr)), - MockReplies: []govppapi.Message{&vpp_sr.SrPolicyAddReply{}}, - Verify: func(err error, catchedMsgs []govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsgs).To(HaveLen(1)) - Expect(catchedMsgs[0]).To(Equal(&vpp_sr.SrPolicyAdd{ - BsidAddr: sidA.Addr, - FibTable: 10, // installationVrfId - Type: boolToUint(false), - IsEncap: boolToUint(true), - Sids: vpp_sr.Srv6SidList{ - Weight: 1, - NumSids: 3, - Sids: []vpp_sr.Srv6Sid{{Addr: sidA.Addr}, {Addr: sidB.Addr}, {Addr: sidC.Addr}}, - }, - })) - }, - }, - { - Name: "adding policy with multiple segment lists", - Policy: policy(sidA.Addr, 10, false, true, - policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr), policySegmentList(1, sidB.Addr, sidC.Addr, sidA.Addr)), - MockReplies: []govppapi.Message{&vpp_sr.SrPolicyAddReply{}, &vpp_sr.SrPolicyModReply{}}, - Verify: func(err error, catchedMsgs []govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsgs).To(HaveLen(2)) - Expect(catchedMsgs[0]).To(Equal(&vpp_sr.SrPolicyAdd{ - BsidAddr: sidA.Addr, - FibTable: 10, // installationVrfId - Type: boolToUint(false), - IsEncap: boolToUint(true), - Sids: vpp_sr.Srv6SidList{ - Weight: 1, - NumSids: 3, - Sids: []vpp_sr.Srv6Sid{{Addr: sidA.Addr}, {Addr: sidB.Addr}, {Addr: sidC.Addr}}, - }, - })) - Expect(catchedMsgs[1]).To(Equal(&vpp_sr.SrPolicyMod{ - BsidAddr: sidA.Addr, - Operation: vpp2001.AddSRList, - FibTable: 10, // installationVrfId - Sids: vpp_sr.Srv6SidList{ - Weight: 1, - NumSids: 3, - Sids: []vpp_sr.Srv6Sid{{Addr: sidB.Addr}, {Addr: sidC.Addr}, {Addr: sidA.Addr}}, - }, - })) - }, - }, - { - Name: "failing when adding policy with empty segment lists", - Policy: policy(sidA.Addr, 10, false, true), - MockReplies: []govppapi.Message{&vpp_sr.SrPolicyAddReply{}}, - Verify: func(err error, catchedMsgs []govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "invalid binding SID in policy", - Policy: &srv6.Policy{ - Bsid: invalidIPAddress, - InstallationVrfId: 10, - SprayBehaviour: false, - SrhEncapsulation: true, - SegmentLists: []*srv6.Policy_SegmentList{ - { - Weight: 1, - Segments: []string{sidToStr(sidA), invalidIPAddress, sidToStr(sidC)}, - }, - }, - }, - MockReplies: []govppapi.Message{&vpp_sr.SrPolicyAddReply{}}, - Verify: func(err error, catchedMsgs []govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "invalid SID (not IP address) in first segment list", - Policy: policy(sidA.Addr, 10, false, true, - &srv6.Policy_SegmentList{ - Weight: 1, - Segments: []string{sidToStr(sidA), invalidIPAddress, sidToStr(sidC)}, - }), - MockReplies: []govppapi.Message{&vpp_sr.SrPolicyAddReply{}}, - Verify: func(err error, catchedMsgs []govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "invalid SID (not IP address) in non-first segment list", - Policy: policy(sidA.Addr, 10, false, true, - policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr), - &srv6.Policy_SegmentList{ - Weight: 1, - Segments: []string{sidToStr(sidA), invalidIPAddress, sidToStr(sidC)}, - }), - MockReplies: []govppapi.Message{&vpp_sr.SrPolicyAddReply{}, &vpp_sr.SrPolicyModReply{}}, - Verify: func(err error, catchedMsgs []govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "failure propagation from VPP", - Policy: policy(sidA.Addr, 0, true, true, policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr)), - MockReplies: []govppapi.Message{&vpp_sr.SrPolicyAddReply{Retval: 1}}, - Verify: func(err error, msgs []govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply, make call and verify - for _, reply := range td.MockReplies { - ctx.MockVpp.MockReply(reply) - } - err := vppCalls.AddPolicy(td.Policy) - td.Verify(err, ctx.MockChannel.Msgs) - }) - } -} - -// TestDeletePolicy tests all cases for method DeletePolicy -func TestDeletePolicy(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - BSID net.IP - MockReply govppapi.Message - Verify func(error, govppapi.Message) - }{ - { - Name: "simple delete of policy", - BSID: sidA.Addr, - MockReply: &vpp_sr.SrPolicyDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrPolicyDel{ - BsidAddr: sidA, - })) - }, - }, - { - Name: "failure propagation from VPP", - BSID: sidA.Addr, - MockReply: &vpp_sr.SrPolicyDelReply{Retval: 1}, - Verify: func(err error, msg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // data and prepare case - policy := policy(td.BSID, 0, true, true, policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr)) - vppCalls.AddPolicy(policy) - ctx.MockVpp.MockReply(td.MockReply) - // make the call and verify - err := vppCalls.DeletePolicy(td.BSID) - td.Verify(err, ctx.MockChannel.Msg) - }) - } -} - -// TestAddPolicySegmentList tests all cases for method AddPolicySegment -func TestAddPolicySegmentList(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - Policy *srv6.Policy - PolicySegmentList *srv6.Policy_SegmentList - MockReply govppapi.Message - Verify func(error, govppapi.Message) - }{ - { - Name: "simple addition of policy segment", - Policy: policy(sidA.Addr, 10, false, true), - PolicySegmentList: policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr), - MockReply: &vpp_sr.SrPolicyModReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrPolicyMod{ - BsidAddr: sidA.Addr, - Operation: vpp2001.AddSRList, - FibTable: 10, // installationVrfId - Sids: vpp_sr.Srv6SidList{ - Weight: 1, - NumSids: 3, - Sids: []vpp_sr.Srv6Sid{{Addr: sidA.Addr}, {Addr: sidB.Addr}, {Addr: sidC.Addr}}, - }, - })) - }, - }, - { - Name: "invalid SID (not IP address) in segment list", - Policy: policy(sidA.Addr, 10, false, true), - PolicySegmentList: &srv6.Policy_SegmentList{ - Weight: 1, - Segments: []string{sidToStr(sidA), invalidIPAddress, sidToStr(sidC)}, - }, - MockReply: &vpp_sr.SrPolicyModReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "invalid binding SID (not IP address) in policy", - Policy: &srv6.Policy{ - Bsid: invalidIPAddress, - InstallationVrfId: 10, - SprayBehaviour: false, - SrhEncapsulation: true, - }, - PolicySegmentList: policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr), - MockReply: &vpp_sr.SrPolicyModReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "failure propagation from VPP", - Policy: policy(sidA.Addr, 0, true, true), - PolicySegmentList: policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr), - MockReply: &vpp_sr.SrPolicyModReply{Retval: 1}, - Verify: func(err error, msg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply, make call and verify - ctx.MockVpp.MockReply(td.MockReply) - err := vppCalls.AddPolicySegmentList(td.PolicySegmentList, td.Policy) - td.Verify(err, ctx.MockChannel.Msg) - }) - } -} - -// TestDeletePolicySegmentList tests all cases for method DeletePolicySegment -func TestDeletePolicySegmentList(t *testing.T) { - // Prepare different cases - cases := []struct { - Name string - Policy *srv6.Policy - PolicySegmentList *srv6.Policy_SegmentList - SegmentIndex uint32 - MockReply govppapi.Message - Verify func(error, govppapi.Message) - }{ - { - Name: "simple deletion of policy segment", - Policy: policy(sidA.Addr, 10, false, true, policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr)), - PolicySegmentList: policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr), - SegmentIndex: 111, - MockReply: &vpp_sr.SrPolicyModReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrPolicyMod{ - BsidAddr: sidA.Addr, - Operation: vpp2001.DeleteSRList, - SlIndex: 111, - FibTable: 10, // installationVrfId - Sids: vpp_sr.Srv6SidList{ - Weight: 1, - NumSids: 3, - Sids: []vpp_sr.Srv6Sid{{Addr: sidA.Addr}, {Addr: sidB.Addr}, {Addr: sidC.Addr}}, - }, - })) - }, - }, - { - Name: "invalid SID (not IP address) in segment list", - Policy: policy(sidA.Addr, 10, false, true, - &srv6.Policy_SegmentList{ - Weight: 1, - Segments: []string{sidToStr(sidA), invalidIPAddress, sidToStr(sidC)}, - }), - PolicySegmentList: &srv6.Policy_SegmentList{ - Weight: 1, - Segments: []string{sidToStr(sidA), invalidIPAddress, sidToStr(sidC)}, - }, - SegmentIndex: 111, - MockReply: &vpp_sr.SrPolicyModReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "failure propagation from VPP", - Policy: policy(sidA.Addr, 0, true, true, policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr)), - PolicySegmentList: policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr), - SegmentIndex: 111, - MockReply: &vpp_sr.SrPolicyModReply{Retval: 1}, - Verify: func(err error, msg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply, make call and verify - ctx.MockVpp.MockReply(td.MockReply) - err := vppCalls.DeletePolicySegmentList(td.PolicySegmentList, td.SegmentIndex, td.Policy) - td.Verify(err, ctx.MockChannel.Msg) - }) - } -} - -// TestAddSteering tests all cases for method AddSteering -func TestAddSteering(t *testing.T) { - testAddRemoveSteering(t, false) -} - -// TestRemoveSteering tests all cases for method RemoveSteering -func TestRemoveSteering(t *testing.T) { - testAddRemoveSteering(t, true) -} - -func testAddRemoveSteering(t *testing.T, removal bool) { - action := "addition" - if removal { - action = "removal" - } - // Prepare different cases - cases := []struct { - Name string - Steering *srv6.Steering - MockReply govppapi.Message - Verify func(error, govppapi.Message) - }{ - { - Name: action + " of IPv6 L3 steering", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: sidToStr(sidA), - }, - Traffic: &srv6.Steering_L3Traffic_{ - L3Traffic: &srv6.Steering_L3Traffic{ - InstallationVrfId: 10, - PrefixAddress: "1::/64", - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrSteeringAddDel{ - IsDel: boolToUint(removal), - BsidAddr: sidA.Addr, - SrPolicyIndex: uint32(0), - TableID: 10, - TrafficType: vpp2001.SteerTypeIPv6, - PrefixAddr: net.ParseIP("1::").To16(), - MaskWidth: 64, - })) - }, - }, - { - Name: action + " of IPv4 L3 steering", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: sidToStr(sidA), - }, - Traffic: &srv6.Steering_L3Traffic_{ - L3Traffic: &srv6.Steering_L3Traffic{ - InstallationVrfId: 10, - PrefixAddress: "1.2.3.4/24", - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrSteeringAddDel{ - IsDel: boolToUint(removal), - BsidAddr: sidA.Addr, - SrPolicyIndex: uint32(0), - TableID: 10, - TrafficType: vpp2001.SteerTypeIPv4, - PrefixAddr: net.ParseIP("1.2.3.4").To16(), - MaskWidth: 24, - })) - }, - }, - { - Name: action + " of L2 steering", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: sidToStr(sidA), - }, - Traffic: &srv6.Steering_L2Traffic_{ - L2Traffic: &srv6.Steering_L2Traffic{ - InterfaceName: ifaceA, - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrSteeringAddDel{ - IsDel: boolToUint(removal), - BsidAddr: sidA.Addr, - SrPolicyIndex: uint32(0), - TrafficType: vpp2001.SteerTypeL2, - SwIfIndex: swIndexA, - })) - }, - }, - { - Name: action + " of IPv6 L3 steering with Policy referencing by index", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyIndex{ - PolicyIndex: 20, - }, - Traffic: &srv6.Steering_L3Traffic_{ - L3Traffic: &srv6.Steering_L3Traffic{ - InstallationVrfId: 10, - PrefixAddress: "1::/64", - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).ShouldNot(HaveOccurred()) - Expect(catchedMsg).To(Equal(&vpp_sr.SrSteeringAddDel{ - IsDel: boolToUint(removal), - BsidAddr: nil, - SrPolicyIndex: uint32(20), - TableID: 10, - TrafficType: vpp2001.SteerTypeIPv6, - PrefixAddr: net.ParseIP("1::").To16(), - MaskWidth: 64, - })) - }, - }, - { - Name: "missing policy reference ( " + action + " of IPv6 L3 steering)", - Steering: &srv6.Steering{ - Traffic: &srv6.Steering_L3Traffic_{ - L3Traffic: &srv6.Steering_L3Traffic{ - InstallationVrfId: 10, - PrefixAddress: "1::/64", - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "missing traffic ( " + action + " of IPv6 L3 steering)", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: sidToStr(sidA), - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "invalid prefix (" + action + " of IPv4 L3 steering)", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: sidToStr(sidA), - }, - Traffic: &srv6.Steering_L3Traffic_{ - L3Traffic: &srv6.Steering_L3Traffic{ - InstallationVrfId: 10, - PrefixAddress: invalidIPAddress, - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "interface without index (" + action + " of L2 steering)", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: sidToStr(sidA), - }, - Traffic: &srv6.Steering_L2Traffic_{ - L2Traffic: &srv6.Steering_L2Traffic{ - InterfaceName: ifaceBOutOfidxs, - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "invalid BSID (not IP address) as policy reference", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: invalidIPAddress, - }, - Traffic: &srv6.Steering_L3Traffic_{ - L3Traffic: &srv6.Steering_L3Traffic{ - InstallationVrfId: 10, - PrefixAddress: "1::/64", - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{}, - Verify: func(err error, catchedMsg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - { - Name: "failure propagation from VPP", - Steering: &srv6.Steering{ - PolicyRef: &srv6.Steering_PolicyBsid{ - PolicyBsid: sidToStr(sidA), - }, - Traffic: &srv6.Steering_L3Traffic_{ - L3Traffic: &srv6.Steering_L3Traffic{ - InstallationVrfId: 10, - PrefixAddress: "1::/64", - }, - }, - }, - MockReply: &vpp_sr.SrSteeringAddDelReply{Retval: 1}, - Verify: func(err error, msg govppapi.Message) { - Expect(err).Should(HaveOccurred()) - }, - }, - } - - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply, make call and verify - ctx.MockVpp.MockReply(td.MockReply) - var err error - if removal { - err = vppCalls.RemoveSteering(td.Steering) - } else { - err = vppCalls.AddSteering(td.Steering) - } - td.Verify(err, ctx.MockChannel.Msg) - }) - } -} - -// RetrievePolicyIndexInfo tests all cases for method RetrievePolicyIndexInfo -func TestRetrievePolicyIndexInfo(t *testing.T) { - correctCLIOutput := ` -[4].- BSID: a:: - - Behavior: SRH insertion - - Type: Spray - - FIB table: 0 - - Segment Lists: - - [2].- < a::, b::, c::,  > weight: 1 - [3].- < b::, b::, c::,  > weight: 1 - [4].- < c::, b::, c::,  > weight: 1 - ------------ -` - correctPolicyIndex := uint32(4) - segmentListABC := policySegmentList(1, sidA.Addr, sidB.Addr, sidC.Addr) - segmentListBBC := policySegmentList(1, sidB.Addr, sidB.Addr, sidC.Addr) - notExistingSegmentListCCC := policySegmentList(1, sidC.Addr, sidC.Addr, sidC.Addr) - - // Prepare different cases - cases := []struct { - Name string - Policy *srv6.Policy - MockReply govppapi.Message - ExpectedPolicyIndex uint32 - ExpectedSegmentListIndexes map[*srv6.Policy_SegmentList]uint32 - ExpectingFailure bool - }{ - { - Name: "basic successful index retrieval", - Policy: policy(sidA.Addr, 10, false, true, segmentListABC, segmentListBBC), - MockReply: &vpp_vpe.CliInbandReply{ - Reply: correctCLIOutput, - Retval: 0, - }, - ExpectedPolicyIndex: correctPolicyIndex, - ExpectedSegmentListIndexes: map[*srv6.Policy_SegmentList]uint32{segmentListABC: uint32(2), segmentListBBC: uint32(3)}, - }, - { - Name: "failure propagation from VPP", - Policy: policy(sidA.Addr, 10, false, true, segmentListABC, segmentListBBC), - MockReply: &vpp_vpe.CliInbandReply{Retval: 1}, - ExpectingFailure: true, - }, - { - Name: "searching for not existing policy ", - Policy: policy(sidC.Addr, 10, false, true, segmentListABC, segmentListBBC), - MockReply: &vpp_vpe.CliInbandReply{ - Reply: correctCLIOutput, - Retval: 0, - }, - ExpectingFailure: true, - }, - { - Name: "searching for not existing policy segment list", - Policy: policy(sidA.Addr, 10, false, true, notExistingSegmentListCCC), - MockReply: &vpp_vpe.CliInbandReply{ - Reply: correctCLIOutput, - Retval: 0, - }, - ExpectingFailure: true, - }, - } - // Run all cases - for _, td := range cases { - t.Run(td.Name, func(t *testing.T) { - ctx, vppCalls := setup(t) - defer teardown(ctx) - // prepare reply, make call and verify - ctx.MockVpp.MockReply(td.MockReply) - resultPolicyIndex, resultSlIndexes, err := vppCalls.RetrievePolicyIndexInfo(td.Policy) - Expect(ctx.MockChannel.Msg).To(Equal(&vpp_vpe.CliInband{ - Cmd: "sh sr policies", - })) - if td.ExpectingFailure { - Expect(err).Should(HaveOccurred()) - } else { - Expect(err).ShouldNot(HaveOccurred()) - Expect(resultPolicyIndex).To(Equal(td.ExpectedPolicyIndex)) - Expect(resultSlIndexes).To(Equal(td.ExpectedSegmentListIndexes)) - } - }) - } -} - -func setup(t *testing.T) (*vppmock.TestCtx, vppcalls.SRv6VppAPI) { - ctx := vppmock.SetupTestCtx(t) - log := logrus.NewLogger("test") - swIfIndex := ifaceidx.NewIfaceIndex(log, "test") - swIfIndex.Put(ifaceA, &ifaceidx.IfaceMetadata{SwIfIndex: swIndexA}) - vppCalls := vpp2001.NewSRv6VppHandler(ctx.MockVPPClient, swIfIndex, log) - return ctx, vppCalls -} - -func teardown(ctx *vppmock.TestCtx) { - ctx.TeardownTestCtx() -} - -func sid(str string) *vpp_sr.Srv6Sid { - bsid, err := parseIPv6(str) - if err != nil { - panic(fmt.Sprintf("can't parse %q into SRv6 BSID (IPv6 address)", str)) - } - return &vpp_sr.Srv6Sid{ - Addr: bsid, - } -} - -// parseIPv6 parses string to IPv6 address (including IPv4 address converted to IPv6 address) -func parseIPv6(str string) (net.IP, error) { - ip := net.ParseIP(str) - if ip == nil { - return nil, fmt.Errorf(" %q is not ip address", str) - } - ipv6 := ip.To16() - if ipv6 == nil { - return nil, fmt.Errorf(" %q is not ipv6 address", str) - } - return ipv6, nil -} - -func policy(bsid srv6.SID, installationVrfId uint32, sprayBehaviour bool, srhEncapsulation bool, segmentLists ...*srv6.Policy_SegmentList) *srv6.Policy { - return &srv6.Policy{ - Bsid: bsid.String(), - InstallationVrfId: installationVrfId, - SprayBehaviour: sprayBehaviour, - SrhEncapsulation: srhEncapsulation, - SegmentLists: segmentLists, - } -} - -func policySegmentList(weight uint32, sids ...srv6.SID) *srv6.Policy_SegmentList { - segments := make([]string, len(sids)) - for i, sid := range sids { - segments[i] = sid.String() - } - - return &srv6.Policy_SegmentList{ - Weight: weight, - Segments: segments, - } -} - -func boolToUint(input bool) uint8 { - if input { - return uint8(1) - } - return uint8(0) -} - -func sidToStr(sid vpp_sr.Srv6Sid) string { - return srv6.SID(sid.Addr).String() -} diff --git a/plugins/vpp/srplugin/vppcalls/vpp2001/vppcalls_handlers.go b/plugins/vpp/srplugin/vppcalls/vpp2001/vppcalls_handlers.go deleted file mode 100644 index ed3c01b8d2..0000000000 --- a/plugins/vpp/srplugin/vppcalls/vpp2001/vppcalls_handlers.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - core_vppcalls "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls" - core_vpp2001 "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/sr" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/vpe" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/srplugin/vppcalls" -) - -func init() { - msgs := vpp.Messages( - sr.AllMessages, - vpe.AllMessages, // using also vpe -> need to have correct vpp version also for vpe - ) - vppcalls.AddHandlerVersion(vpp2001.Version, msgs.AllMessages(), NewSRv6VppHandler) -} - -// SRv6VppHandler is accessor for SRv6-related vppcalls methods -type SRv6VppHandler struct { - core_vppcalls.VppCoreAPI - - log logging.Logger - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex -} - -// NewSRv6VppHandler creates new instance of SRv6 vppcalls handler -func NewSRv6VppHandler(c vpp.Client, ifIdx ifaceidx.IfaceMetadataIndex, log logging.Logger) vppcalls.SRv6VppAPI { - vppChan, err := c.NewAPIChannel() - if err != nil { - logging.Warnf("failed to create API channel") - return nil - } - return &SRv6VppHandler{ - callsChannel: vppChan, - ifIndexes: ifIdx, - log: log, - VppCoreAPI: core_vpp2001.NewVpeHandler(vppChan), - } -} diff --git a/plugins/vpp/stnplugin/stnplugin.go b/plugins/vpp/stnplugin/stnplugin.go index f84640e228..d092a20b78 100644 --- a/plugins/vpp/stnplugin/stnplugin.go +++ b/plugins/vpp/stnplugin/stnplugin.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ import ( "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/descriptor/adapter" "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls" - _ "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls/vpp2001" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls/vpp2005" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls/vpp2009" _ "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls/vpp2101" diff --git a/plugins/vpp/stnplugin/vppcalls/vpp2001/dump_stn_vppcalls.go b/plugins/vpp/stnplugin/vppcalls/vpp2001/dump_stn_vppcalls.go deleted file mode 100644 index 6f880e05ba..0000000000 --- a/plugins/vpp/stnplugin/vppcalls/vpp2001/dump_stn_vppcalls.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "net" - - "github.com/pkg/errors" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls" - - vpp_stn "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/stn" - stn "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/stn" -) - -// DumpSTNRules implements STN handler, it returns all STN rules present on the VPP -func (h *StnVppHandler) DumpSTNRules() ([]*vppcalls.StnDetails, error) { - var stnDetails []*vppcalls.StnDetails - - req := &vpp_stn.StnRulesDump{} - reqCtx := h.callsChannel.SendMultiRequest(req) - for { - msg := &vpp_stn.StnRulesDetails{} - stop, err := reqCtx.ReceiveReply(msg) - if stop { - break - } - if err != nil { - return nil, errors.Errorf("error reading STN rules from the VPP: %v", err) - } - ifName, _, found := h.ifIndexes.LookupBySwIfIndex(uint32(msg.SwIfIndex)) - if !found { - h.log.Warnf("STN dump: interface name not found for index %d", msg.SwIfIndex) - } - - var stnIP net.IP - if msg.IPAddress.Af == ip_types.ADDRESS_IP4 { - stnAddr := msg.IPAddress.Un.GetIP4() - stnIP = net.IP(stnAddr[:]) - } else { - stnAddr := msg.IPAddress.Un.GetIP6() - stnIP = net.IP(stnAddr[:]) - } - - stnRule := &stn.Rule{ - IpAddress: stnIP.String(), - Interface: ifName, - } - stnMeta := &vppcalls.StnMeta{ - IfIdx: uint32(msg.SwIfIndex), - } - - stnDetails = append(stnDetails, &vppcalls.StnDetails{ - Rule: stnRule, - Meta: stnMeta, - }) - } - - return stnDetails, nil -} - -func uintToBool(value uint8) bool { - if value == 0 { - return false - } - return true -} diff --git a/plugins/vpp/stnplugin/vppcalls/vpp2001/stn_vppcalls.go b/plugins/vpp/stnplugin/vppcalls/vpp2001/stn_vppcalls.go deleted file mode 100644 index 306d5656a8..0000000000 --- a/plugins/vpp/stnplugin/vppcalls/vpp2001/stn_vppcalls.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - "fmt" - "net" - "strings" - - "github.com/pkg/errors" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/interface_types" - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_stn "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/stn" - stn "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/stn" -) - -// AddSTNRule implements STN handler, adds a new STN rule to the VPP. -func (h *StnVppHandler) AddSTNRule(stnRule *stn.Rule) error { - return h.addDelStnRule(stnRule, true) -} - -// DeleteSTNRule implements STN handler, removes the provided STN rule from the VPP. -func (h *StnVppHandler) DeleteSTNRule(stnRule *stn.Rule) error { - return h.addDelStnRule(stnRule, false) -} - -func (h *StnVppHandler) addDelStnRule(stnRule *stn.Rule, isAdd bool) error { - // get interface index - ifaceMeta, found := h.ifIndexes.LookupByName(stnRule.Interface) - if !found { - return errors.New("failed to get interface metadata") - } - swIfIndex := ifaceMeta.GetIndex() - - // remove mask from IP address if necessary - ipAddr := stnRule.IpAddress - ipParts := strings.Split(ipAddr, "/") - if len(ipParts) > 1 { - h.log.Debugf("STN IP address %s is defined with mask, removing it") - ipAddr = ipParts[0] - } - - // parse IP address - ip, err := ipToAddress(ipAddr) - if err != nil { - return err - } - - // add STN rule - req := &vpp_stn.StnAddDelRule{ - IPAddress: ip, - SwIfIndex: interface_types.InterfaceIndex(swIfIndex), - IsAdd: isAdd, - } - reply := &vpp_stn.StnAddDelRuleReply{} - - if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { - return err - } - - return nil - -} - -func ipToAddress(address string) (dhcpAddr ip_types.Address, err error) { - netIP := net.ParseIP(address) - if netIP == nil { - return ip_types.Address{}, fmt.Errorf("invalid IP: %q", address) - } - if ip4 := netIP.To4(); ip4 == nil { - dhcpAddr.Af = ip_types.ADDRESS_IP6 - var ip6addr ip_types.IP6Address - copy(ip6addr[:], netIP.To16()) - dhcpAddr.Un.SetIP6(ip6addr) - } else { - dhcpAddr.Af = ip_types.ADDRESS_IP4 - var ip4addr ip_types.IP4Address - copy(ip4addr[:], ip4) - dhcpAddr.Un.SetIP4(ip4addr) - } - return -} diff --git a/plugins/vpp/stnplugin/vppcalls/vpp2001/stn_vppcalls_test.go b/plugins/vpp/stnplugin/vppcalls/vpp2001/stn_vppcalls_test.go deleted file mode 100644 index 888d1b0c41..0000000000 --- a/plugins/vpp/stnplugin/vppcalls/vpp2001/stn_vppcalls_test.go +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001_test - -import ( - "testing" - - . "github.com/onsi/gomega" - "go.ligato.io/cn-infra/v2/logging/logrus" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/ip_types" - vpp_stn "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/stn" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls" - "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls/vpp2001" - "go.ligato.io/vpp-agent/v3/plugins/vpp/vppmock" - stn "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/stn" -) - -func TestAddStnRule(t *testing.T) { - ctx, stnHandler, ifIndexes := stnTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_stn.StnAddDelRuleReply{}) - - err := stnHandler.AddSTNRule(&stn.Rule{ - Interface: "if1", - IpAddress: "10.0.0.1", - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_stn.StnAddDelRule) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.IPAddress.Un.GetIP4()).To(BeEquivalentTo(ip_types.IP4Address{10, 0, 0, 1})) - Expect(vppMsg.IPAddress.Af).To(Equal(ip_types.ADDRESS_IP4)) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestAddStnRuleIPv6(t *testing.T) { - ctx, stnHandler, ifIndexes := stnTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_stn.StnAddDelRuleReply{}) - - err := stnHandler.AddSTNRule(&stn.Rule{ - Interface: "if1", - IpAddress: "2001:db8:0:1:1:1:1:1", - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_stn.StnAddDelRule) - Expect(ok).To(BeTrue()) - Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1)) - Expect(vppMsg.IPAddress.Un.GetIP6()).To(BeEquivalentTo(ip_types.IP6Address{32, 1, 13, 184, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1})) - Expect(vppMsg.IPAddress.Af).To(Equal(ip_types.ADDRESS_IP6)) - Expect(vppMsg.IsAdd).To(BeTrue()) -} - -func TestAddStnRuleInvalidIP(t *testing.T) { - ctx, stnHandler, ifIndexes := stnTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_stn.StnAddDelRuleReply{}) - - err := stnHandler.AddSTNRule(&stn.Rule{ - Interface: "if1", - IpAddress: "invalid-ip", - }) - - Expect(err).ToNot(BeNil()) -} - -func TestAddStnRuleError(t *testing.T) { - ctx, stnHandler, ifIndexes := stnTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_stn.StnAddDelRule{}) - - err := stnHandler.AddSTNRule(&stn.Rule{ - Interface: "if1", - IpAddress: "10.0.0.1", - }) - - Expect(err).ToNot(BeNil()) -} - -func TestAddStnRuleRetval(t *testing.T) { - ctx, stnHandler, ifIndexes := stnTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_stn.StnAddDelRuleReply{ - Retval: 1, - }) - - err := stnHandler.AddSTNRule(&stn.Rule{ - Interface: "if1", - IpAddress: "10.0.0.1", - }) - - Expect(err).ToNot(BeNil()) -} - -func TestDelStnRule(t *testing.T) { - ctx, stnHandler, ifIndexes := stnTestSetup(t) - defer ctx.TeardownTestCtx() - - ifIndexes.Put("if1", &ifaceidx.IfaceMetadata{SwIfIndex: 1}) - - ctx.MockVpp.MockReply(&vpp_stn.StnAddDelRuleReply{}) - - err := stnHandler.DeleteSTNRule(&stn.Rule{ - Interface: "if1", - IpAddress: "10.0.0.1", - }) - - Expect(err).To(BeNil()) - vppMsg, ok := ctx.MockChannel.Msg.(*vpp_stn.StnAddDelRule) - Expect(ok).To(BeTrue()) - Expect(vppMsg.IsAdd).To(BeFalse()) -} - -func stnTestSetup(t *testing.T) (*vppmock.TestCtx, vppcalls.StnVppAPI, ifaceidx.IfaceMetadataIndexRW) { - ctx := vppmock.SetupTestCtx(t) - logger := logrus.NewLogger("test-log") - ifIndexes := ifaceidx.NewIfaceIndex(logger, "stn-if-idx") - stnHandler := vpp2001.NewStnVppHandler(ctx.MockChannel, ifIndexes, logrus.DefaultLogger()) - return ctx, stnHandler, ifIndexes -} diff --git a/plugins/vpp/stnplugin/vppcalls/vpp2001/vppcalls_handler.go b/plugins/vpp/stnplugin/vppcalls/vpp2001/vppcalls_handler.go deleted file mode 100644 index 0be3fad654..0000000000 --- a/plugins/vpp/stnplugin/vppcalls/vpp2001/vppcalls_handler.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vpp2001 - -import ( - govppapi "git.fd.io/govpp.git/api" - "go.ligato.io/cn-infra/v2/logging" - - "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001" - vpp_stn "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2001/stn" - "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" - "go.ligato.io/vpp-agent/v3/plugins/vpp/stnplugin/vppcalls" -) - -func init() { - var msgs []govppapi.Message - msgs = append(msgs, vpp_stn.AllMessages()...) - - vppcalls.AddStnHandlerVersion(vpp2001.Version, msgs, NewStnVppHandler) -} - -// StnVppHandler is accessor for STN-related vppcalls methods -type StnVppHandler struct { - callsChannel govppapi.Channel - ifIndexes ifaceidx.IfaceMetadataIndex - log logging.Logger -} - -// NewStnVppHandler creates new instance of STN vppcalls handler -func NewStnVppHandler( - callsChan govppapi.Channel, ifIndexes ifaceidx.IfaceMetadataIndex, log logging.Logger, -) vppcalls.StnVppAPI { - return &StnVppHandler{ - callsChannel: callsChan, - ifIndexes: ifIndexes, - log: log, - } -} diff --git a/scripts/genbinapi.sh b/scripts/genbinapi.sh index a36018f350..1aee3774f3 100755 --- a/scripts/genbinapi.sh +++ b/scripts/genbinapi.sh @@ -4,16 +4,6 @@ set -euo pipefail export VPP_API_DIR=${VPP_API_DIR:-/usr/share/vpp/api} export VPP_VERSION= -binapidir=$(basename "$VPP_BINAPI") -if [ "$binapidir" == "vpp2001" ] -then - ( - cd $(mktemp -d) - echo "module x" > go.mod - GO111MODULE=on go get -v git.fd.io/govpp.git/cmd/binapi-generator@v0.3.5 - ) -fi - # Generate binapi go generate -x ./"${VPP_BINAPI}" diff --git a/tests/integration/vpp/000_initial_test.go b/tests/integration/vpp/000_initial_test.go index a97acf3022..e5d6349249 100644 --- a/tests/integration/vpp/000_initial_test.go +++ b/tests/integration/vpp/000_initial_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,9 +15,10 @@ package vpp import ( + "testing" + . "github.com/onsi/gomega" "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls" - "testing" ) func TestPing(t *testing.T) { @@ -55,9 +56,8 @@ func TestGetPlugins(t *testing.T) { t.Logf("%d plugins: %v", len(plugins), plugins) Expect(plugins).ToNot(BeEmpty()) - // GetModules return empty list with VPP 20.01 - /*modules, err := vpp.GetModules(test.Ctx) + modules, err := vpp.GetModules(test.Ctx) Expect(err).ToNot(HaveOccurred()) t.Logf("%d modules: %v", len(modules), modules) - Expect(modules).ToNot(BeEmpty())*/ + Expect(modules).ToNot(BeEmpty()) } diff --git a/tests/integration/vpp/022_ip_neighbor_test.go b/tests/integration/vpp/022_ip_neighbor_test.go index 2c2a18df4a..64dec79257 100644 --- a/tests/integration/vpp/022_ip_neighbor_test.go +++ b/tests/integration/vpp/022_ip_neighbor_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ func TestIPNeighbor(t *testing.T) { test := setupVPP(t) defer test.teardownVPP() + // TODO update this test if test.versionInfo.Release() >= "20.01" { t.Skipf("SKIP for VPP %s>=20.01", test.versionInfo.Release()) } diff --git a/tests/integration/vpp/032_ip6nd_test.go b/tests/integration/vpp/032_ip6nd_test.go index cc0e87ea4f..506f9fcbb9 100644 --- a/tests/integration/vpp/032_ip6nd_test.go +++ b/tests/integration/vpp/032_ip6nd_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,10 +33,6 @@ func TestIP6ND(t *testing.T) { test := setupVPP(t) defer test.teardownVPP() - if test.versionInfo.Release() < "20.01" { - t.Skipf("SKIP for VPP %s<20.01", test.versionInfo.Release()) - } - ih := ifplugin_vppcalls.CompatibleInterfaceVppHandler(test.vppClient, logrus.NewLogger("test")) const ifName = "loop1" ifIdx, err := ih.AddLoopbackInterface(ifName) diff --git a/tests/integration/vpp/040_acl_test.go b/tests/integration/vpp/040_acl_test.go index 71fe93f1ea..f2e3916521 100644 --- a/tests/integration/vpp/040_acl_test.go +++ b/tests/integration/vpp/040_acl_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -259,6 +259,7 @@ func TestCRUDIPAcl(t *testing.T) { t.Logf("%v", ifaces[1]) t.Logf("%v", ifaces[2]) //this does not work for VPP 19.04 and maybe also other version + //checked for VPP 21.06 - still does not work //Expect(ifaces[0].Ingress).To(Equal([]string{ifName})) //Expect(ifaces[2].Egress).To(Equal([]string{ifName2})) @@ -604,6 +605,7 @@ func TestCRUDMacIPAcl(t *testing.T) { t.Logf("%v", ifaces[1]) t.Logf("%v", ifaces[2]) //this does not work for VPP 19.04 and maybe also other version + //checked for VPP 21.06 - still does not work //Expect(ifaces[0].Ingress).To(Equal([]string{ifName})) //Expect(ifaces[2].Egress).To(Equal([]string{ifName2})) diff --git a/tests/integration/vpp/100_gtpu_test.go b/tests/integration/vpp/100_gtpu_test.go index 40bcbc1197..e380423d7e 100644 --- a/tests/integration/vpp/100_gtpu_test.go +++ b/tests/integration/vpp/100_gtpu_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019 EMnify +// Copyright (c) 2021 EMnify // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -30,20 +30,6 @@ func TestGtpu(t *testing.T) { ctx := setupVPP(t) defer ctx.teardownVPP() - // The dump gtpu interface details API is broken in some of the VPP versions. - // See https://gerrit.fd.io/r/c/vpp/+/22904 and https://gerrit.fd.io/r/c/vpp/+/23054 - dumpAPIOk := true - release := ctx.versionInfo.Release() - if release <= "19.08" { - if ctx.versionInfo.Version < "19.08.1-255" { - dumpAPIOk = false - } - } else if release <= "20.01" { - if ctx.versionInfo.Version < "20.01-rc0~496" { - dumpAPIOk = false - } - } - h := ifplugin_vppcalls.CompatibleInterfaceVppHandler(ctx.vppClient, logrus.NewLogger("test")) tests := []struct { @@ -151,45 +137,41 @@ func TestGtpu(t *testing.T) { } } - if dumpAPIOk { - ifaces, err := h.DumpInterfaces(ctx.Ctx) - if err != nil { - t.Fatalf("dumping interfaces failed: %v", err) - } - iface, ok := ifaces[ifIdx] - if !ok { - t.Fatalf("GTP-U interface was not found in dump") - } + ifaces, err := h.DumpInterfaces(ctx.Ctx) + if err != nil { + t.Fatalf("dumping interfaces failed: %v", err) + } + iface, ok := ifaces[ifIdx] + if !ok { + t.Fatalf("GTP-U interface was not found in dump") + } - if iface.Interface.GetType() != interfaces.Interface_GTPU_TUNNEL { - t.Fatalf("Interface is not a GTPU tunnel") - } + if iface.Interface.GetType() != interfaces.Interface_GTPU_TUNNEL { + t.Fatalf("Interface is not a GTPU tunnel") + } - gtpu := iface.Interface.GetGtpu() - if test.gtpu.SrcAddr != gtpu.SrcAddr { - t.Fatalf("expected source address <%s>, got: <%s>", test.gtpu.SrcAddr, gtpu.SrcAddr) - } - if test.gtpu.DstAddr != gtpu.DstAddr { - t.Fatalf("expected destination address <%s>, got: <%s>", test.gtpu.DstAddr, gtpu.DstAddr) - } - if test.gtpu.Teid != gtpu.Teid { - t.Fatalf("expected TEID <%d>, got: <%d>", test.gtpu.Teid, gtpu.Teid) - } - if test.gtpu.Multicast != gtpu.Multicast { - t.Fatalf("expected multicast interface name <%s>, got: <%s>", test.gtpu.Multicast, gtpu.Multicast) - } - if test.gtpu.EncapVrfId != gtpu.EncapVrfId { - t.Fatalf("expected GTP-U EncapVrfId <%d>, got: <%d>", test.gtpu.EncapVrfId, gtpu.EncapVrfId) - } - testDecapNext := test.gtpu.DecapNextNode - if testDecapNext == uint32(interfaces.GtpuLink_DEFAULT) { - testDecapNext = uint32(interfaces.GtpuLink_L2) - } - if testDecapNext != gtpu.DecapNextNode { - t.Fatalf("expected GTP-U DecapNextNode <%v>, got: <%v>", testDecapNext, gtpu.DecapNextNode) - } - } else { - t.Logf("GTP-U: DumpInterfaces skipped because of a broken API in VPP %s", ctx.versionInfo.Version) + gtpu := iface.Interface.GetGtpu() + if test.gtpu.SrcAddr != gtpu.SrcAddr { + t.Fatalf("expected source address <%s>, got: <%s>", test.gtpu.SrcAddr, gtpu.SrcAddr) + } + if test.gtpu.DstAddr != gtpu.DstAddr { + t.Fatalf("expected destination address <%s>, got: <%s>", test.gtpu.DstAddr, gtpu.DstAddr) + } + if test.gtpu.Teid != gtpu.Teid { + t.Fatalf("expected TEID <%d>, got: <%d>", test.gtpu.Teid, gtpu.Teid) + } + if test.gtpu.Multicast != gtpu.Multicast { + t.Fatalf("expected multicast interface name <%s>, got: <%s>", test.gtpu.Multicast, gtpu.Multicast) + } + if test.gtpu.EncapVrfId != gtpu.EncapVrfId { + t.Fatalf("expected GTP-U EncapVrfId <%d>, got: <%d>", test.gtpu.EncapVrfId, gtpu.EncapVrfId) + } + testDecapNext := test.gtpu.DecapNextNode + if testDecapNext == uint32(interfaces.GtpuLink_DEFAULT) { + testDecapNext = uint32(interfaces.GtpuLink_L2) + } + if testDecapNext != gtpu.DecapNextNode { + t.Fatalf("expected GTP-U DecapNextNode <%v>, got: <%v>", testDecapNext, gtpu.DecapNextNode) } err = h.DelGtpuTunnel(ifName, test.gtpu) @@ -197,15 +179,13 @@ func TestGtpu(t *testing.T) { t.Fatalf("delete GTP-U tunnel failed: %v\n", err) } - if dumpAPIOk { - ifaces, err := h.DumpInterfaces(ctx.Ctx) - if err != nil { - t.Fatalf("dumping interfaces failed: %v", err) - } + ifaces, err = h.DumpInterfaces(ctx.Ctx) + if err != nil { + t.Fatalf("dumping interfaces failed: %v", err) + } - if _, ok := ifaces[ifIdx]; ok { - t.Fatalf("GTP-U interface was found in dump after removing") - } + if _, ok := ifaces[ifIdx]; ok { + t.Fatalf("GTP-U interface was found in dump after removing") } }) } diff --git a/tests/integration/vpp/120_ipip_test.go b/tests/integration/vpp/120_ipip_test.go index 524fa8b57a..e422808087 100644 --- a/tests/integration/vpp/120_ipip_test.go +++ b/tests/integration/vpp/120_ipip_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -30,16 +30,6 @@ func TestIPIP(t *testing.T) { ctx := setupVPP(t) defer ctx.teardownVPP() - p2mpSupported := true // determines point-to-multipoint support - - release := ctx.versionInfo.Release() - if release < "20.01" { - t.Skipf("IPIP: skipped for VPP < 20.01 (%s)", release) - } - if release < "20.05" { - p2mpSupported = false // point-to-multipoint support comes in VPP 20.05 - } - h := ifplugin_vppcalls.CompatibleInterfaceVppHandler(ctx.vppClient, logrus.NewLogger("test")) tests := []struct { @@ -122,9 +112,6 @@ func TestIPIP(t *testing.T) { } for i, test := range tests { t.Run(test.name, func(t *testing.T) { - if !p2mpSupported && test.ipip.TunnelMode == interfaces.IPIPLink_POINT_TO_MULTIPOINT { - t.Skipf("IPIP: p2mp skipped for VPP < 20.05 (%s)", release) - } ifName := fmt.Sprintf("ipip%d", i) ifIdx, err := h.AddIpipTunnel(ifName, 0, test.ipip) diff --git a/tests/integration/vpp/130_ipsec_test.go b/tests/integration/vpp/130_ipsec_test.go index 186429e942..aff360ec18 100644 --- a/tests/integration/vpp/130_ipsec_test.go +++ b/tests/integration/vpp/130_ipsec_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. +// Copyright (c) 2021 Cisco and/or its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,9 +16,10 @@ package vpp import ( "fmt" - "github.com/golang/protobuf/proto" "testing" + "github.com/golang/protobuf/proto" + "go.ligato.io/cn-infra/v2/logging/logrus" "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" @@ -35,19 +36,8 @@ func TestIPSec(t *testing.T) { ctx := setupVPP(t) defer ctx.teardownVPP() - p2mpSupported := true // determines point-to-multipoint support - saDumpAPIOk := true // determines if SA dump API is working spdIfaceDumpOk := false // determines if ipsec_spd_interface_dump works correctly - release := ctx.versionInfo.Release() - if release < "20.01" { - t.Skipf("IPSec: skipped for VPP < 20.01 (%s)", release) - } - if release < "20.05" { - saDumpAPIOk = false // tunnel protection SA dump broken in VPP 20.01 - p2mpSupported = false // point-to-multipoint support comes in VPP 20.05 - } - ifIndexes := ifaceidx.NewIfaceIndex(logrus.NewLogger("test"), "test-ifidx") ifHandler := ifplugin_vppcalls.CompatibleInterfaceVppHandler(ctx.vppClient, logrus.NewLogger("test-if")) ipsecHandler := ipsec_vppcalls.CompatibleIPSecVppHandler(ctx.vppClient, ifIndexes, logrus.NewLogger("test-ipsec")) @@ -92,32 +82,32 @@ func TestIPSec(t *testing.T) { Index: 100, }, spOut: &ipsec.SecurityPolicy{ - SpdIndex: 100, - SaIndex: 10, - Priority: 0, - IsOutbound: true, - RemoteAddrStart: "10.10.1.1", - RemoteAddrStop: "10.10.1.255", - LocalAddrStart: "10.10.2.1", - LocalAddrStop: "10.10.2.255", - Protocol: 0, - Action: ipsec.SecurityPolicy_PROTECT, + SpdIndex: 100, + SaIndex: 10, + Priority: 0, + IsOutbound: true, + RemoteAddrStart: "10.10.1.1", + RemoteAddrStop: "10.10.1.255", + LocalAddrStart: "10.10.2.1", + LocalAddrStop: "10.10.2.255", + Protocol: 0, + Action: ipsec.SecurityPolicy_PROTECT, }, spIn: &ipsec.SecurityPolicy{ - SpdIndex: 100, - SaIndex: 20, - Priority: 0, - IsOutbound: false, - RemoteAddrStart: "10.10.1.1", - RemoteAddrStop: "10.10.1.255", - LocalAddrStart: "10.10.2.1", - LocalAddrStop: "10.10.2.255", - Protocol: 0, - RemotePortStart: 1000, - RemotePortStop: 5000, - LocalPortStart: 2000, - LocalPortStop: 7000, - Action: ipsec.SecurityPolicy_PROTECT, + SpdIndex: 100, + SaIndex: 20, + Priority: 0, + IsOutbound: false, + RemoteAddrStart: "10.10.1.1", + RemoteAddrStop: "10.10.1.255", + LocalAddrStart: "10.10.2.1", + LocalAddrStop: "10.10.2.255", + Protocol: 0, + RemotePortStart: 1000, + RemotePortStop: 5000, + LocalPortStart: 2000, + LocalPortStop: 7000, + Action: ipsec.SecurityPolicy_PROTECT, }, tp: &ipsec.TunnelProtection{ SaOut: []uint32{10}, @@ -156,32 +146,32 @@ func TestIPSec(t *testing.T) { Index: 101, }, spOut: &ipsec.SecurityPolicy{ - SpdIndex: 101, - SaIndex: 1, - Priority: 0, - IsOutbound: true, - RemoteAddrStart: "2001:1000::1", - RemoteAddrStop: "2001:1000::1000", - LocalAddrStart: "2001:2000::1", - LocalAddrStop: "2001:2000::1000", - Protocol: 0, - Action: ipsec.SecurityPolicy_PROTECT, + SpdIndex: 101, + SaIndex: 1, + Priority: 0, + IsOutbound: true, + RemoteAddrStart: "2001:1000::1", + RemoteAddrStop: "2001:1000::1000", + LocalAddrStart: "2001:2000::1", + LocalAddrStop: "2001:2000::1000", + Protocol: 0, + Action: ipsec.SecurityPolicy_PROTECT, }, spIn: &ipsec.SecurityPolicy{ - SpdIndex: 101, - SaIndex: 2, - Priority: 0, - IsOutbound: false, - RemoteAddrStart: "2001:1000::1", - RemoteAddrStop: "2001:1000::1000", - LocalAddrStart: "2001:2000::1", - LocalAddrStop: "2001:2000::1000", - Protocol: 0, - RemotePortStart: 1000, - RemotePortStop: 5000, - LocalPortStart: 2000, - LocalPortStop: 7000, - Action: ipsec.SecurityPolicy_PROTECT, + SpdIndex: 101, + SaIndex: 2, + Priority: 0, + IsOutbound: false, + RemoteAddrStart: "2001:1000::1", + RemoteAddrStop: "2001:1000::1000", + LocalAddrStart: "2001:2000::1", + LocalAddrStop: "2001:2000::1000", + Protocol: 0, + RemotePortStart: 1000, + RemotePortStop: 5000, + LocalPortStart: 2000, + LocalPortStop: 7000, + Action: ipsec.SecurityPolicy_PROTECT, }, }, { @@ -214,32 +204,32 @@ func TestIPSec(t *testing.T) { Index: 102, }, spOut: &ipsec.SecurityPolicy{ - SpdIndex: 102, - SaIndex: 100, - Priority: 0, - IsOutbound: true, - RemoteAddrStart: "10.10.1.1", - RemoteAddrStop: "10.10.1.255", - LocalAddrStart: "10.10.2.1", - LocalAddrStop: "10.10.2.255", - Protocol: 0, - Action: ipsec.SecurityPolicy_PROTECT, + SpdIndex: 102, + SaIndex: 100, + Priority: 0, + IsOutbound: true, + RemoteAddrStart: "10.10.1.1", + RemoteAddrStop: "10.10.1.255", + LocalAddrStart: "10.10.2.1", + LocalAddrStop: "10.10.2.255", + Protocol: 0, + Action: ipsec.SecurityPolicy_PROTECT, }, spIn: &ipsec.SecurityPolicy{ - SpdIndex: 102, - SaIndex: 101, - Priority: 0, - IsOutbound: false, - RemoteAddrStart: "10.10.1.1", - RemoteAddrStop: "10.10.1.255", - LocalAddrStart: "10.10.2.1", - LocalAddrStop: "10.10.2.255", - Protocol: 0, - RemotePortStart: 1000, - RemotePortStop: 5000, - LocalPortStart: 2000, - LocalPortStop: 7000, - Action: ipsec.SecurityPolicy_PROTECT, + SpdIndex: 102, + SaIndex: 101, + Priority: 0, + IsOutbound: false, + RemoteAddrStart: "10.10.1.1", + RemoteAddrStop: "10.10.1.255", + LocalAddrStart: "10.10.2.1", + LocalAddrStop: "10.10.2.255", + Protocol: 0, + RemotePortStart: 1000, + RemotePortStop: 5000, + LocalPortStart: 2000, + LocalPortStop: 7000, + Action: ipsec.SecurityPolicy_PROTECT, }, tp: &ipsec.TunnelProtection{ SaOut: []uint32{100}, @@ -250,9 +240,6 @@ func TestIPSec(t *testing.T) { } for i, test := range tests { t.Run(test.name, func(t *testing.T) { - if !p2mpSupported && test.ipip.TunnelMode == interfaces.IPIPLink_POINT_TO_MULTIPOINT { - t.Skipf("IPIP: p2mp skipped for VPP < 20.05 (%s)", release) - } // create IPIP tunnel + SAs + tunnel protection + SPs ifName := fmt.Sprintf("ipip%d", i) ifIdx, err := ifHandler.AddIpipTunnel(ifName, 0, test.ipip) @@ -316,13 +303,9 @@ func TestIPSec(t *testing.T) { if tpList[0].Interface != ifName { t.Fatalf("Invalid interface name in tunnel protections: %s", tpList[0].Interface) } - if saDumpAPIOk { - if tpList[0].SaIn[0] != test.saIn.Index || tpList[0].SaOut[0] != test.saOut.Index { - t.Fatalf("tunnel protection SA mismatch (%d != %d || %d != %d)", - tpList[0].SaIn[0], test.saIn.Index, tpList[0].SaOut[0], test.saOut.Index) - } - } else { - t.Logf("IPIP: SA index check skipped because of a broken API in VPP %s", ctx.versionInfo.Version) + if tpList[0].SaIn[0] != test.saIn.Index || tpList[0].SaOut[0] != test.saOut.Index { + t.Fatalf("tunnel protection SA mismatch (%d != %d || %d != %d)", + tpList[0].SaIn[0], test.saIn.Index, tpList[0].SaOut[0], test.saOut.Index) } if tpList[0].NextHopAddr != test.tp.NextHopAddr { t.Fatalf("tunnel protection next hop mismatch (%v != %v)", tpList[0].NextHopAddr, test.tp.NextHopAddr) diff --git a/tests/integration/vpp/150_nat_test.go b/tests/integration/vpp/150_nat_test.go index 653ba2a2e8..5fa5a7dbc0 100644 --- a/tests/integration/vpp/150_nat_test.go +++ b/tests/integration/vpp/150_nat_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2019 Pantheon.tech +// Copyright (c) 2021 Pantheon.tech // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,9 @@ package vpp import ( + "net" + "testing" + . "github.com/onsi/gomega" idxmap_mem "go.ligato.io/cn-infra/v2/idxmap/mem" "go.ligato.io/cn-infra/v2/logging/logrus" @@ -23,12 +26,9 @@ import ( nat_vppcalls "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls" nat "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/nat" "google.golang.org/protobuf/proto" - "net" - "testing" ) const ( - vpp2001 = "20.01" vpp2005 = "20.05" vpp2009 = "20.09" vpp2101 = "21.01" @@ -39,7 +39,7 @@ func TestNat44Global(t *testing.T) { ctx := setupVPP(t) defer ctx.teardownVPP() - unsupportedVPPVersions := []string{vpp2001, vpp2005, vpp2009} + unsupportedVPPVersions := []string{vpp2005, vpp2009} // in older versions is used VPP startup config // exclude test testing feature not supported in currently tested VPP version for _, excludedVPPVersion := range unsupportedVPPVersions { @@ -139,7 +139,7 @@ func TestNat44StaticMapping(t *testing.T) { }, { name: "NAT44 static mapping with twice nat and twice NAT pool IP", - excludeUnsupportedVPPVersions: []string{vpp2001, vpp2005}, + excludeUnsupportedVPPVersions: []string{vpp2005}, input: &nat.DNat44_StaticMapping{ Protocol: nat.DNat44_TCP, ExternalIp: externalIP.String(), diff --git a/tests/integration/vpp/180_dns_test.go b/tests/integration/vpp/180_dns_test.go index 973908184f..a3b6ee135b 100644 --- a/tests/integration/vpp/180_dns_test.go +++ b/tests/integration/vpp/180_dns_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020 Pantheon.tech +// Copyright (c) 2021 Pantheon.tech // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -44,9 +44,6 @@ func TestDNSServerCRUD(t *testing.T) { // ignoring unsupported VPP versions release := ctx.versionInfo.Release() - if release < "20.01" { - t.Skipf("DNS: skipped for VPP < 20.01 (%s) due to missing support", release) - } // get VPP handler dnsHandler := vppcalls.CompatibleDNSHandler(ctx.vppClient, logrus.NewLogger("test-dns")) diff --git a/vpp.env b/vpp.env index c67726ace1..7ca0b57dcd 100644 --- a/vpp.env +++ b/vpp.env @@ -1,11 +1,6 @@ VPP_REPO_URL=https://github.com/FDio/vpp.git VPP_DEFAULT=2009 -# VPP 20.01 -VPP_2001_IMAGE=ligato/vpp-base:20.01 -VPP_2001_BINAPI=plugins/vpp/binapi/vpp2001 -VPP_2001_BRANCH=stable/2001 - # VPP 20.05 VPP_2005_IMAGE=ligato/vpp-base:20.05 VPP_2005_BINAPI=plugins/vpp/binapi/vpp2005